SinglePass Lighting: fix colorramp feature

experimental
shadowislord 10 years ago
parent d3b71cd946
commit 331e71f261
  1. 13
      jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag
  2. 6
      jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert

@ -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);
}

@ -160,8 +160,14 @@ void main(){
}
#endif
vec2 v = computeLighting(wvNormal, viewDir, lightDir.xyz, lightDir.w * spotFallOff, m_Shininess);
#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

Loading…
Cancel
Save