From cf0f7c298ccbbb9a228f2cfc7a32ae03cb891710 Mon Sep 17 00:00:00 2001 From: "gral@who.net" Date: Fri, 3 Sep 2010 09:37:52 +0200 Subject: [PATCH] Fix: bringing back constantColor in crop shaders --- Shaders/crop.frag | 4 +++- Shaders/crop.vert | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Shaders/crop.frag b/Shaders/crop.frag index 555e673a2..c3534bc41 100644 --- a/Shaders/crop.frag +++ b/Shaders/crop.frag @@ -9,6 +9,8 @@ uniform sampler3D NoiseTex; uniform sampler2D SampleTex; uniform sampler1D ColorsTex; +varying vec4 constantColor; + uniform float snowlevel; // From /sim/rendering/snow-level-m const float scale = 1.0; @@ -57,7 +59,7 @@ void main (void) c1 = mix(c1, clamp(n+nvL[2]*4.1+vec4(0.1, 0.1, nvL[2]*2.2, 1.0), 0.7, 1.0), smoothstep(snowlevel+300.0, snowlevel+360.0, (rawpos.z)+nvL[1]*3000.0)); vec3 diffuse = gl_Color.rgb * max(0.0, dot(VNormal, gl_LightSource[0].position.xyz)); - vec4 ambient_light = gl_LightSource[0].diffuse * vec4(diffuse, 1.0); + vec4 ambient_light = constantColor + gl_LightSource[0].diffuse * vec4(diffuse, 1.0); c1 *= ambient_light; vec4 finalColor = c1; diff --git a/Shaders/crop.vert b/Shaders/crop.vert index b5c7314a5..9e70bfa6d 100644 --- a/Shaders/crop.vert +++ b/Shaders/crop.vert @@ -4,6 +4,7 @@ varying vec4 rawpos; varying vec4 ecPosition; varying vec3 VNormal; varying vec3 Normal; +varying vec4 constantColor; void main(void) { @@ -14,6 +15,10 @@ void main(void) VNormal = normalize(gl_NormalMatrix * gl_Normal); Normal = normalize(gl_Normal); - gl_FrontColor = gl_Color; + gl_FrontColor = gl_Color; + + constantColor = gl_FrontMaterial.emission + + gl_Color * (gl_LightModel.ambient + gl_LightSource[0].ambient); + gl_Position = ftransform(); } \ No newline at end of file