mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-10 04:11:25 +00:00
Merge pull request #2265 from Capostrophic/material
Fix shader specular lighting (again)
This commit is contained in:
commit
0c95ffab8f
1 changed files with 4 additions and 3 deletions
|
@ -74,9 +74,10 @@ vec4 doLighting(vec3 viewPos, vec3 viewNormal, vec4 vertexColor, out vec3 shadow
|
||||||
vec3 getSpecular(vec3 viewNormal, vec3 viewDirection, float shininess, vec3 matSpec)
|
vec3 getSpecular(vec3 viewNormal, vec3 viewDirection, float shininess, vec3 matSpec)
|
||||||
{
|
{
|
||||||
vec3 lightDir = normalize(gl_LightSource[0].position.xyz);
|
vec3 lightDir = normalize(gl_LightSource[0].position.xyz);
|
||||||
float NdotL = max(dot(viewNormal, lightDir), 0.0);
|
float NdotL = dot(viewNormal, lightDir);
|
||||||
if (NdotL < 0.0)
|
if (NdotL <= 0.0)
|
||||||
return vec3(0.,0.,0.);
|
return vec3(0.,0.,0.);
|
||||||
vec3 halfVec = normalize(lightDir - viewDirection);
|
vec3 halfVec = normalize(lightDir - viewDirection);
|
||||||
return pow(max(dot(viewNormal, halfVec), 0.0), shininess) * gl_LightSource[0].specular.xyz * matSpec;
|
float NdotH = dot(viewNormal, halfVec);
|
||||||
|
return pow(max(NdotH, 0.0), max(1e-4, shininess)) * gl_LightSource[0].specular.xyz * matSpec;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue