diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/pointLightP.glsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/pointLightP.glsl index 01a547011..b0b02d226 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/pointLightP.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/pointLightP.glsl @@ -108,6 +108,7 @@ uniform sampler2D deferredBuffer; #include "softShadow.glsl" uniform sampler2D colorBuffer; uniform sampler2D matInfoBuffer; + #ifdef SHADOW_CUBE /// The texture for cookie rendering. uniform samplerCube cookieMap; @@ -115,7 +116,9 @@ uniform samplerCube cookieMap; uniform sampler2D cookieMap; #endif -uniform sampler2D iesProfile; +#ifdef UES_PHOTOMETRIC_MASK +uniform sampler1D iesProfile; +#endif uniform vec4 rtParams0; @@ -231,17 +234,18 @@ void main() OUT_col = vec4(final, 0); return #endif - - //get punctual light contribution - lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow); + #ifdef UES_PHOTOMETRIC_MASK // Lookup the cookie sample.d float cosTheta = dot(-surfaceToLight.L, lightDirection); float angle = acos(cosTheta) * ( M_1OVER_PI_F); - float iesMask = texture(iesProfile, vec2(angle, 0.0)).r; + float iesMask = texture(iesProfile,angle).r; // Multiply the light with the iesMask tex. - lighting *= iesMask; + shadow *= iesMask; #endif + + //get punctual light contribution + lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow); } diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/spotLightP.glsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/spotLightP.glsl index f5983eb0d..f96212c8d 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/spotLightP.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/spotLightP.glsl @@ -38,8 +38,15 @@ uniform sampler2D shadowMap; #include "softShadow.glsl" uniform sampler2D colorBuffer; uniform sampler2D matInfoBuffer; + +#ifdef USE_COOKIE_TEX uniform sampler2D cookieMap; -uniform sampler2D iesProfile; +#endif + +#ifdef UES_PHOTOMETRIC_MASK +uniform sampler1D iesProfile; +#endif + uniform vec4 rtParams0; uniform float lightBrightness; @@ -154,16 +161,17 @@ void main() return; #endif - //get spot light contribution - lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow); #ifdef UES_PHOTOMETRIC_MASK // Lookup the cookie sample.d float cosTheta = dot(-surfaceToLight.L, lightDirection); float angle = acos(cosTheta) * ( M_1OVER_PI_F); - float iesMask = texture(iesProfile, vec2(angle, 0.0)).r; + float iesMask = texture(iesProfile, angle).r; // Multiply the light with the iesMask tex. - lighting *= iesMask; + shadow *= iesMask; #endif + + //get spot light contribution + lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow); } OUT_col = vec4(lighting, 0); diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/pointLightP.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/pointLightP.hlsl index de3d3433f..747f168a6 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/pointLightP.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/pointLightP.hlsl @@ -107,13 +107,17 @@ TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1); #include "softShadow.hlsl" TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3); TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4); + /// The texture for cookie rendering. #ifdef SHADOW_CUBE TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 5); #else TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5); #endif -TORQUE_UNIFORM_SAMPLER2D(iesProfile, 6); + +#ifdef UES_PHOTOMETRIC_MASK +TORQUE_UNIFORM_SAMPLER1D(iesProfile, 6); +#endif uniform float4 rtParams0; uniform float4 lightColor; @@ -223,17 +227,18 @@ float4 main( ConvexConnectP IN ) : SV_TARGET return final; #endif - //get punctual light contribution - lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow); - #ifdef UES_PHOTOMETRIC_MASK // Lookup the cookie sample.d float cosTheta = dot(-surfaceToLight.L, lightDirection); float angle = acos(cosTheta) * ( M_1OVER_PI_F); - float iesMask = TORQUE_TEX2D(iesProfile, float2(angle, 0.0)).r; + float iesMask = TORQUE_TEX2D(iesProfile, angle).r; // Multiply the light with the iesMask tex. - lighting *= iesMask; + shadow *= iesMask; #endif + + //get punctual light contribution + lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow); + } diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/spotLightP.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/spotLightP.hlsl index efd07fa30..dc47ea23d 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/spotLightP.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/spotLightP.hlsl @@ -43,8 +43,14 @@ TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1); TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3); TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4); /// The texture for cookie rendering. + +#ifdef USE_COOKIE_TEX TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5); -TORQUE_UNIFORM_SAMPLER2D(iesProfile, 6); +#endif + +#ifdef UES_PHOTOMETRIC_MASK +TORQUE_UNIFORM_SAMPLER1D(iesProfile, 6); +#endif uniform float4 rtParams0; @@ -153,16 +159,17 @@ float4 main( ConvexConnectP IN ) : SV_TARGET return final; #endif - //get spot light contribution - lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow); #ifdef UES_PHOTOMETRIC_MASK // Lookup the cookie sample.d float cosTheta = dot(-surfaceToLight.L, lightDirection); float angle = acos(cosTheta) * ( M_1OVER_PI_F); - float iesMask = TORQUE_TEX2D(iesProfile, float2(angle, 0.0)).r; + float iesMask = TORQUE_TEX1D(iesProfile, angle).r; // Multiply the light with the iesMask tex. - lighting *= iesMask; + shadow *= iesMask; #endif + + //get spot light contribution + lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow); } return float4(lighting, 0);