Sign in to follow this  

HLSL Diffuse Lighting Factor

This topic is 3379 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

This topic is 3379 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this