Commit 1ce2866d authored by Christopher Tenter's avatar Christopher Tenter

more accurate half vector for specular lighting in shader

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15890 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 45d501dc
......@@ -25,7 +25,7 @@ vec3 LitPointLight(vec3 vPosition,
cLight += ldotn * cLightDiffuse * g_cDiffuse;
// specular
vec3 h = normalize(vec3(0, 0, 1) + vLightDir);
vec3 h = normalize(vLightDir - normalize(vPosition)); // half vector between light and view direction
float hdotn = max(dot(h, vNormal), 0.0);
cLight += (pow(hdotn, SHININESS) * cLightSpecular) * g_cSpecular;
......@@ -37,7 +37,8 @@ vec3 LitPointLight(vec3 vPosition,
}
vec3 LitDirLight(vec3 vNormal,
vec3 LitDirLight(vec3 vPosition,
vec3 vNormal,
vec3 vLightDir,
vec3 cLightAmbient,
vec3 cLightDiffuse,
......@@ -51,7 +52,7 @@ vec3 LitDirLight(vec3 vNormal,
cLight += ldotn * cLightDiffuse * g_cDiffuse;
// specular
vec3 h = normalize(vec3(0, 0, 1) + vLightDir);
vec3 h = normalize(vLightDir - normalize(vPosition)); // half vector between light and view direction
float hdotn = max(dot(h, vNormal), 0.0);
cLight += (pow(hdotn, SHININESS) * cLightSpecular) * g_cSpecular;
......@@ -84,7 +85,7 @@ vec3 LitSpotLight(vec3 vPosition,
cLight += ldotn * cLightDiffuse * g_cDiffuse;
// specular
vec3 h = normalize(vec3(0, 0, 1) + vLightDir);
vec3 h = normalize(vLightDir - normalize(vPosition)); // half vector between light and view direction
float hdotn = max(dot(h, vNormal), 0.0);
cLight += (pow(hdotn, SHININESS) * cLightSpecular) * g_cSpecular;
......
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