Jump to content
  • Advertisement
Sign in to follow this  
FoxHunter2

Convert D3DLIGHT_SPOT to use per-pixel lighting

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

If you intended to correct an error in the post then please contact us.

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!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!