• Advertisement
Sign in to follow this  

[DirectX 10] Blinn-Phong lighting explanation

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

When I implemented lighting in my game engine, I used some code I found on the Internet without understanding it very well...

So now I want to make everything about the Blinn-Phong lighting clear:

This is my shader for calculating Parallel Light:
(The end of shader might seem strange because Im implementing Light Pre-Pass)

float4 ParallelLight(Surface v, Light L, float3 eyePos)
float3 litColor = float3(1.0f,1.0f,1.0f);

float3 lightVec = -normalize(L.dir);

float NdL = dot(v.normal, lightVec);
float3 reflectionVector = normalize(reflect(-lightVec, v.normal));
float3 directionToCamera = normalize(eyePos - v.pos);
float specPower = max(v.spec.a, 10.0f);
float specFactor = pow(saturate(dot(reflectionVector, directionToCamera)), specPower);

return float4(L.diffuse.x * NdL, L.diffuse.y * NdL, L.diffuse.z * NdL, specFactor * NdL);

->N.L (N.L):
For what I've understood N.L = dot(pixel normal in world space(I guess), light direction vector

Ive seen this on many articles but I dont know if I calculate this, because I dont know what N.H^n is...

->Half vector (half vector between light vector and view vector):
Ive seen this in wikipedia but I don't understand the point of it...


So can anyone explain me this terms and others that might be important?

Ive found this shader on Wikipedia: http://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model
And it is a lot simpler, so do this shader give realistic results?

Share this post

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

  • Advertisement