Commit e00cd322 authored by Kersten Schuster's avatar Kersten Schuster

Apply two-sided lighting to specular components, too - if enabled.

parent 89efcc24
......@@ -37,7 +37,11 @@ vec3 LitPointLight(vec3 vPosition,
// specular
vec3 h = normalize(vLightDir - vec3(0,0,-1)); // half vector between light and view direction
#ifdef TWO_SIDED_LIGHTING
float hdotn = max(abs(dot(h, vNormal)), 0.001); // small epsilon to avoid undefined pow(0, 0) if shininess is also 0
#else
float hdotn = max(dot(h, vNormal), 0.001); // small epsilon to avoid undefined pow(0, 0) if shininess is also 0
#endif
cLight += (pow(hdotn, SHININESS) * cLightSpecular) * g_cSpecular;
......@@ -68,7 +72,11 @@ vec3 LitDirLight(vec3 vPosition,
// specular
vec3 h = normalize(vLightDir - vec3(0,0,-1)); // half vector between light and view direction
float hdotn = max(dot(h, vNormal), 0.001); // small epsilon to avoid undefined pow(0, 0) if shininess is also 0
#ifdef TWO_SIDED_LIGHTING
float hdotn = max(abs(dot(h, vNormal)), 0.001); // small epsilon to avoid undefined pow(0, 0) if shininess is also 0
#else
float hdotn = max(dot(h, vNormal), 0.001); // small epsilon to avoid undefined pow(0, 0) if shininess is also 0
#endif
cLight += (pow(hdotn, SHININESS) * cLightSpecular) * g_cSpecular;
return cLight;
......@@ -105,7 +113,11 @@ vec3 LitSpotLight(vec3 vPosition,
// specular
vec3 h = normalize(vLightDir - vec3(0,0,-1)); // half vector between light and view direction
float hdotn = max(dot(h, vNormal), 0.001); // small epsilon to avoid undefined pow(0, 0) if shininess is also 0
#ifdef TWO_SIDED_LIGHTING
float hdotn = max(abs(dot(h, vNormal)), 0.001); // small epsilon to avoid undefined pow(0, 0) if shininess is also 0
#else
float hdotn = max(dot(h, vNormal), 0.001); // small epsilon to avoid undefined pow(0, 0) if shininess is also 0
#endif
cLight += (pow(hdotn, SHININESS) * cLightSpecular) * g_cSpecular;
// attenuate
......
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