# Convert D3DLIGHT_SPOT to use per-pixel lighting

This topic is 5421 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi! I finally succeeded in setting up my lights. But in my opinion, the standard per-vertex lighting looks quite ugly and unrealistic when applied to faces with pretty few vertices. So now I want to convert my light(s) to use per-pixel lighting in shader (v1.1-1.3 if possible, my card doesn't support higher versions). But I'm a complete shader-newbie, so I need your guidance. This is my light:
ltFlashlight.Type			= D3DLIGHT_SPOT;
ltFlashlight.Diffuse.r		= ltFlashlight.Ambient.r = 1.0f;
ltFlashlight.Diffuse.g		= ltFlashlight.Ambient.g = 1.0f;
ltFlashlight.Diffuse.b		= ltFlashlight.Ambient.b = 1.0f;
ltFlashlight.Diffuse.a		= ltFlashlight.Ambient.a = 0.0f;
ltFlashlight.Range			= 500.0f;
ltFlashlight.Position		= vecLight;
ltFlashlight.Direction		= vLook;	ltFlashlight.Falloff		= 1.0f;
ltFlashlight.Attenuation0	= 1.0f;
ltFlashlight.Attenuation1	= 0.0f;
ltFlashlight.Attenuation2	= 0.0f;
ltFlashlight.Phi			= 1.0f;
ltFlashlight.Theta			= 0.5f;


Furthermore I have: - proper vertex normals - eye and lookat position - world/view/proj-matrix Now I want to write a shader to convert my per-vertex lighting to be lit per-pixel. I hope you can explain me how to do this. One note to the end: I read some tutorials about loading/compiling .psh or .fx (HLSL) files, so you may focus on the actual shader. I hope I can accomplish the rest by myself. thanks in advance!

• 18
• 29
• 11
• 21
• 16