1
0
Fork 0

transition.frag: fix shading

ubershader.frag: fix ambient
Signed-off-by: Emilian Huminiuc <emilianh@gmail.com>
This commit is contained in:
Emilian Huminiuc 2012-06-28 14:37:45 +03:00
parent 4587dc8bc5
commit c001b6d679
2 changed files with 34 additions and 11 deletions

View file

@ -44,6 +44,7 @@ void main()
float L1;
float L2;
float wetness;
float pf;
vec3 n;
vec3 lightDir;
@ -58,7 +59,7 @@ void main()
lightDir = gl_LightSource[0].position.xyz;
halfVector = gl_LightSource[0].halfVector.xyz;
color = gl_Color;
//color = gl_Color;
specular = vec4(0.0);
cover = min(min(min(min(CloudCover0, CloudCover1),CloudCover2),CloudCover3),CloudCover4);
@ -75,15 +76,36 @@ void main()
n = (2.0 * gl_Color.a - 1.0) * Vnormal;
n = normalize(n);
NdotL = dot(n, lightDir);
if (NdotL > 0.0) {
color += diffuse_term * NdotL;
NdotHV = max(dot(n, halfVector), 0.0);
// NdotL = dot(n, lightDir);
// if (NdotL > 0.0) {
// color += diffuse_term * NdotL;
// NdotHV = max(dot(n, halfVector), 0.0);
// if (gl_FrontMaterial.shininess > 0.0)
// specular.rgb = (gl_FrontMaterial.specular.rgb
// * gl_LightSource[0].specular.rgb
// * pow(NdotHV, gl_FrontMaterial.shininess));
// }
float nDotVP = max(0.0, dot(n, normalize(gl_LightSource[0].position.xyz)));
float nDotHV = max(0.0, dot(n, normalize(gl_LightSource[0].halfVector.xyz)));
vec4 Diffuse = gl_LightSource[0].diffuse * nDotVP;
if (nDotVP == 0.0)
pf = 0.0;
else
pf = pow(nDotHV, gl_FrontMaterial.shininess);
if (gl_FrontMaterial.shininess > 0.0)
specular.rgb = (gl_FrontMaterial.specular.rgb
* gl_LightSource[0].specular.rgb
* pow(NdotHV, gl_FrontMaterial.shininess));
}
specular = gl_FrontMaterial.specular * gl_LightSource[0].specular * pf;
color = gl_FrontMaterial.emission +
gl_Color * (gl_LightModel.ambient + gl_LightSource[0].ambient) +
Diffuse * gl_FrontMaterial.diffuse;
color += specular * gl_FrontMaterial.specular;
color.a = diffuse_term.a;
// This shouldn't be necessary, but our lighting becomes very

View file

@ -167,7 +167,8 @@ void main (void)
// set ambient adjustment to remove bluiness with user input
float ambient_offset = clamp(amb_correction, -1.0, 1.0);
vec4 ambient_Correction = vec4(gl_LightSource[0].ambient.rg, gl_LightSource[0].ambient.b * 0.6, 0.5)
vec4 ambient = gl_LightModel.ambient + gl_LightSource[0].ambient;
vec4 ambient_Correction = vec4(ambient.rg, ambient.b * 0.6, 1.0)
* ambient_offset ;
ambient_Correction = clamp(ambient_Correction, -1.0, 1.0);