From 462aeefb36ea1f2d3a4d89a52d4ddabddf0b4a72 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Fri, 1 May 2015 13:47:04 -0500 Subject: [PATCH] opengl crashfix: cannot self-multiply a uniform. use a temp-variable. --- .../shaders/common/lighting/advanced/gl/pointLightP.glsl | 5 +++-- .../game/shaders/common/lighting/advanced/gl/spotLightP.glsl | 5 +++-- .../game/shaders/common/lighting/advanced/pointLightP.hlsl | 5 +++-- .../game/shaders/common/lighting/advanced/spotLightP.hlsl | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Templates/Full/game/shaders/common/lighting/advanced/gl/pointLightP.glsl b/Templates/Full/game/shaders/common/lighting/advanced/gl/pointLightP.glsl index e70f68a43..2c8e43736 100644 --- a/Templates/Full/game/shaders/common/lighting/advanced/gl/pointLightP.glsl +++ b/Templates/Full/game/shaders/common/lighting/advanced/gl/pointLightP.glsl @@ -187,13 +187,14 @@ void main() #endif // !NO_SHADOW + vec3 lightcol = lightColor.rgb; #ifdef USE_COOKIE_TEX // Lookup the cookie sample. vec4 cookie = texture( cookieMap, tMul( viewToLightProj, -lightVec ) ); // Multiply the light with the cookie tex. - lightColor.rgb *= cookie.rgb; + lightcol *= cookie.rgb; // Use a maximum channel luminance to attenuate // the lighting else we get specular in the dark @@ -211,7 +212,7 @@ void main() normalize( -eyeRay ) ) * lightBrightness * atten * shadowed; float Sat_NL_Att = saturate( nDotL * atten * shadowed ) * lightBrightness; - vec3 lightColorOut = lightMapParams.rgb * lightColor.rgb; + vec3 lightColorOut = lightMapParams.rgb * lightcol; vec4 addToResult = vec4(0.0); // TODO: This needs to be removed when lightmapping is disabled diff --git a/Templates/Full/game/shaders/common/lighting/advanced/gl/spotLightP.glsl b/Templates/Full/game/shaders/common/lighting/advanced/gl/spotLightP.glsl index b3920ec9a..91bc5915a 100644 --- a/Templates/Full/game/shaders/common/lighting/advanced/gl/spotLightP.glsl +++ b/Templates/Full/game/shaders/common/lighting/advanced/gl/spotLightP.glsl @@ -121,13 +121,14 @@ void main() #endif // !NO_SHADOW + vec3 lightcol = lightColor.rgb; #ifdef USE_COOKIE_TEX // Lookup the cookie sample. vec4 cookie = texture( cookieMap, shadowCoord ); // Multiply the light with the cookie tex. - lightColor.rgb *= cookie.rgb; + lightcol *= cookie.rgb; // Use a maximum channel luminance to attenuate // the lighting else we get specular in the dark @@ -145,7 +146,7 @@ void main() normalize( -eyeRay ) ) * lightBrightness * atten * shadowed; float Sat_NL_Att = saturate( nDotL * atten * shadowed ) * lightBrightness; - vec3 lightColorOut = lightMapParams.rgb * lightColor.rgb; + vec3 lightColorOut = lightMapParams.rgb * lightcol; vec4 addToResult = vec4(0.0); // TODO: This needs to be removed when lightmapping is disabled diff --git a/Templates/Full/game/shaders/common/lighting/advanced/pointLightP.hlsl b/Templates/Full/game/shaders/common/lighting/advanced/pointLightP.hlsl index fbfced097..ff1f3d437 100644 --- a/Templates/Full/game/shaders/common/lighting/advanced/pointLightP.hlsl +++ b/Templates/Full/game/shaders/common/lighting/advanced/pointLightP.hlsl @@ -192,13 +192,14 @@ float4 main( ConvexConnectP IN, #endif // !NO_SHADOW + float3 lightcol = lightColor.rgb; #ifdef USE_COOKIE_TEX // Lookup the cookie sample. float4 cookie = texCUBE( cookieMap, mul( viewToLightProj, -lightVec ) ); // Multiply the light with the cookie tex. - lightColor.rgb *= cookie.rgb; + lightcol *= cookie.rgb; // Use a maximum channel luminance to attenuate // the lighting else we get specular in the dark @@ -216,7 +217,7 @@ float4 main( ConvexConnectP IN, normalize( -eyeRay ) ) * lightBrightness * atten * shadowed; float Sat_NL_Att = saturate( nDotL * atten * shadowed ) * lightBrightness; - float3 lightColorOut = lightMapParams.rgb * lightColor.rgb; + float3 lightColorOut = lightMapParams.rgb * lightcol; float4 addToResult = 0.0; // TODO: This needs to be removed when lightmapping is disabled diff --git a/Templates/Full/game/shaders/common/lighting/advanced/spotLightP.hlsl b/Templates/Full/game/shaders/common/lighting/advanced/spotLightP.hlsl index 88e35ad3a..1f1c8e140 100644 --- a/Templates/Full/game/shaders/common/lighting/advanced/spotLightP.hlsl +++ b/Templates/Full/game/shaders/common/lighting/advanced/spotLightP.hlsl @@ -120,13 +120,14 @@ float4 main( ConvexConnectP IN, #endif // !NO_SHADOW + float3 lightcol = lightColor.rgb; #ifdef USE_COOKIE_TEX // Lookup the cookie sample. float4 cookie = tex2D( cookieMap, shadowCoord ); // Multiply the light with the cookie tex. - lightColor.rgb *= cookie.rgb; + lightcol *= cookie.rgb; // Use a maximum channel luminance to attenuate // the lighting else we get specular in the dark @@ -144,7 +145,7 @@ float4 main( ConvexConnectP IN, normalize( -eyeRay ) ) * lightBrightness * atten * shadowed; float Sat_NL_Att = saturate( nDotL * atten * shadowed ) * lightBrightness; - float3 lightColorOut = lightMapParams.rgb * lightColor.rgb; + float3 lightColorOut = lightMapParams.rgb * lightcol; float4 addToResult = 0.0; // TODO: This needs to be removed when lightmapping is disabled