From 01227d31b022302c986acbeb0cb4a3af359c30eb Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Tue, 22 Sep 2015 22:10:16 -0400 Subject: [PATCH] Lighting: fix colorramp feature --- .../main/resources/Common/MatDefs/Light/Lighting.frag | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag index d2ade5199..0aa4d3f36 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag @@ -154,8 +154,9 @@ void main(){ #ifdef VERTEX_LIGHTING vec2 light = vertexLightValues.xy; #ifdef COLORRAMP - light.x = texture2D(m_ColorRamp, vec2(light.x, 0.0)).r; - light.y = texture2D(m_ColorRamp, vec2(light.y, 0.0)).r; + diffuseColor.rgb *= texture2D(m_ColorRamp, vec2(light.x, 0.0)).rgb; + specularColor.rgb *= texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb; + light.xy = vec2(1.0); #endif gl_FragColor.rgb = AmbientSum * diffuseColor.rgb + @@ -183,8 +184,9 @@ void main(){ vec2 light = computeLighting(normal, viewDir, lightDir.xyz, lightDir.w * spotFallOff, m_Shininess) ; #ifdef COLORRAMP - diffuseColor.rgb *= texture2D(m_ColorRamp, vec2(light.x, 0.0)).rgb; - specularColor.rgb *= texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb; + diffuseColor.rgb *= texture2D(m_ColorRamp, vec2(light.x, 0.0)).rgb; + specularColor.rgb *= texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb; + light.xy = vec2(1.0); #endif // Workaround, since it is not possible to modify varying variables