fixes to terrain shader
Handle emission and light model ambient value. Test if shininess is 0 to avoid pow(0, 0), which is undefined.
This commit is contained in:
parent
a3adbc74cb
commit
30f844c961
2 changed files with 5 additions and 3 deletions
|
@ -10,7 +10,7 @@ void main()
|
|||
{
|
||||
vec3 n, halfV;
|
||||
float NdotL, NdotHV, fogFactor;
|
||||
vec4 color = ambient;
|
||||
vec4 color = ambient + gl_FrontMaterial.emission;
|
||||
vec4 texel;
|
||||
vec4 fragColor;
|
||||
|
||||
|
@ -20,8 +20,9 @@ void main()
|
|||
color += diffuse * NdotL;
|
||||
halfV = normalize(halfVector);
|
||||
NdotHV = max(dot(n, halfV), 0.0);
|
||||
color += gl_FrontMaterial.specular * gl_LightSource[0].specular
|
||||
* pow(NdotHV, gl_FrontMaterial.shininess);
|
||||
if (gl_FrontMaterial.shininess > 0.0)
|
||||
color += gl_FrontMaterial.specular * gl_LightSource[0].specular
|
||||
* pow(NdotHV, gl_FrontMaterial.shininess);
|
||||
}
|
||||
texel = texture2D(texture, gl_TexCoord[0].st);
|
||||
fragColor = color * texel;
|
||||
|
|
|
@ -22,5 +22,6 @@ void main()
|
|||
halfVector = normalize(gl_LightSource[0].halfVector.xyz);
|
||||
diffuse = gl_Color * gl_LightSource[0].diffuse;
|
||||
ambient = gl_Color * gl_LightSource[0].ambient;
|
||||
ambient += gl_Color * gl_LightModel.ambient;
|
||||
fogCoord = abs(ecPosition.z);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue