Commit 4c7c4c8f authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - added viewAlign function to orient normals towards the camera. Useful...

[ADD] - added viewAlign function to orient normals towards the camera. Useful for back AND front face light.
parent fa184ed8
...@@ -259,5 +259,17 @@ vec3 getGradientViewAligned( in sampler3D sampler, in vec3 pos, in vec3 viewDir ...@@ -259,5 +259,17 @@ vec3 getGradientViewAligned( in sampler3D sampler, in vec3 pos, in vec3 viewDir
return getGradientViewAligned( sampler, pos, viewDir, 0.005 ); return getGradientViewAligned( sampler, pos, viewDir, 0.005 );
} }
/**
* Re-orient the specified vector to point towards the camera. This should be done AFTER modelview transformation.
*
* \param v the vector to re-orient
*
* \return the new vector. Only normalized if v was normalized.
*/
vec3 viewAlign( vec3 v )
{
return sign( dot( v, vec3( 0.0, 0.0, 1.0 ) ) ) * v;
}
#endif // WGESHADINGTOOLS_GLSL #endif // WGESHADINGTOOLS_GLSL
...@@ -43,7 +43,7 @@ void main() ...@@ -43,7 +43,7 @@ void main()
#endif #endif
// do light // do light
float light = blinnPhongIlluminationIntensity( normalize( -v_normal ) ); float light = blinnPhongIlluminationIntensity( normalize( viewAlign( v_normal ) ) );
// opacity of the surface // opacity of the surface
col.rgb = light * col.rgb; col.rgb = light * col.rgb;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment