Jump to content
  • Advertisement
Sign in to follow this  
hotpixel

HLSL Diffuse Lighting Factor

This topic is 3596 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 everyone, I have these two methods in an fx file that both diffuse the light depending on the normal, light position and light direction. They have both been stolen from various microsoft samples, could anyone please tell me which one is the best one, or if they are both the same or if you have a better way of doing it (bearing in mind I'm trying to keep things as simple as possible). I understand what the first one is doing but I don't have a clue about the second;
Quote:
float Diffuse1(float3 Pos3D, float3 Normal) {   float3 LightDir = normalize(LightPos - Pos3D);   return dot(LightDir, Normal); } float3 Diffuse2(float3 Normal, float4 pos3D) {   float CosTheta;   float3 LightDir = normalize(LightPos - Pos3D);   // N.L Clamped   CosTheta = max(0.0f, dot(Normal, lhtDir.xyz));   // propogate scalar result to vector   return (CosTheta); }
thanks, Andy

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!