Skip to content

Commit

Permalink
Corrected reflection vector calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ssell committed Nov 2, 2016
1 parent a0735f9 commit 925222b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Resources/OcularCore/Shaders/OcularLighting.hlsl
Expand Up @@ -47,7 +47,14 @@ float4 calcLambertianDiffuse(in float4 color)
*/
float4 calcReflectionVector(in float4 normal, in float4 toLight)
{
return normalize(2.0f * dot(normal, toLight) * normal - toLight);
// Source: Real-Time Rendering, 3rd Edition (p 230, figure 7.30)
// and https://www.opengl.org/sdk/docs/man4/html/reflect.xhtml

// Note that in Real-Time Rendering, l is the incoming light
// direction vector, where here we use the direction vector
// pointing to the light source.

return (toLight - 2.0f * dot(normal, toLight) * normal);
}

/**
Expand Down

0 comments on commit 925222b

Please sign in to comment.