@@ -19,16 +19,21 @@ void main()
1919 // This 3x3 matrix should have the rotation components only. We need it to transform the fragment normals into world space.
2020 mat3 mGlobal3x3 = mat3 (mGlobal);
2121
22- // Dot product of the sunlight vector and the normal vector of this surface
23- float flLightDot = dot (vecSunlight, normalize (mGlobal3x3* vecFragmentNormal));
22+ // Transform the local space fragment normal into a global space vector and normalize it.
23+ // http://youtu.be/0zmLe4SssJc
24+ vec3 vecGlobalNormal = normalize (mGlobal3x3* vecFragmentNormal);
2425
25- // Remap the light values so that the negative result becomes positive
26- float flLight = RemapVal(flLightDot, - 1.0 , 0.0 , 0.9 , 0.4 );
26+ // Dot product of the sunlight vector and the normal vector of this surface.
27+ // http://youtu.be/0zmLe4SssJc
28+ float flLightDot = dot (- vecSunlight, vecGlobalNormal);
29+
30+ // Remap the light values so that they are a little softer
31+ float flLight = RemapVal(flLightDot, 1.0 , 0.0 , 0.9 , 0.4 );
2732
2833 // Multiply that by the color to make a shadow
2934 vec4 vecDiffuse = vecColor * flLight;
3035
31- // Add in a diffuse if there is one
36+ // Add in a diffuse if there is one. http://youtu.be/aw6Vi-_hwy0
3237 if (bDiffuse)
3338 vecDiffuse *= texture(iDiffuse, vecFragmentTexCoord0);
3439
0 commit comments