From 331e71f2616f115d57e43d234f174d4474bd724c Mon Sep 17 00:00:00 2001 From: shadowislord Date: Tue, 24 Feb 2015 23:09:38 -0500 Subject: [PATCH] SinglePass Lighting: fix colorramp feature --- .../resources/Common/MatDefs/Light/SPLighting.frag | 13 +++++++------ .../resources/Common/MatDefs/Light/SPLighting.vert | 10 ++++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag index 9e3881028..11834ffc0 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag @@ -178,11 +178,6 @@ void main(){ vec4 refColor = Optics_GetEnvColor(m_EnvMap, refVec.xyz); #endif -// #ifdef COLORRAMP -// diffuseColor.rgb *= texture2D(m_ColorRamp, vec2(light.x, 0.0)).rgb; -// specularColor.rgb *= texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb; -// #endif - for( int i = 0;i < NB_LIGHTS; i+=3){ vec4 lightColor = g_LightData[i]; vec4 lightData1 = g_LightData[i+1]; @@ -221,7 +216,13 @@ void main(){ light.y = 1.0; #endif - gl_FragColor.rgb += DiffuseSum.rgb * lightColor.rgb * diffuseColor.rgb * vec3(light.x) + + #ifdef COLORRAMP + DiffuseSum2.rgb *= texture2D(m_ColorRamp, vec2(light.x, 0.0)).rgb; + SpecularSum2.rgb *= texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb; + light.xy = vec2(1.0); + #endif + + gl_FragColor.rgb += DiffuseSum2.rgb * lightColor.rgb * diffuseColor.rgb * vec3(light.x) + SpecularSum2.rgb * lightColor.rgb * specularColor.rgb * vec3(light.y); } diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert index 1303aa2b6..b0d8828a5 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert @@ -160,8 +160,14 @@ void main(){ } #endif vec2 v = computeLighting(wvNormal, viewDir, lightDir.xyz, lightDir.w * spotFallOff, m_Shininess); - diffuseAccum +=v.x * diffuseColor; - specularAccum += v.y * specularColor; + + #ifdef COLORRAMP + diffuseAccum += texture2D(m_ColorRamp, vec2(light.x, 0.0)).rgb * diffuseColor; + specularAccum += texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb * specularColor; + #else + diffuseAccum += v.x * diffuseColor; + specularAccum += v.y * specularColor; + #endif } #endif