From 4d1395dd57832ad87e230d6e9a92934ed7b732e4 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Fri, 23 Feb 2024 11:23:07 -0600 Subject: [PATCH] from mar: fix the opengl cookie uv lookup --- .../shaders/lighting/advanced/gl/spotLightP.glsl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 0c423630e..3585bfde2 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 @@ -19,7 +19,6 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. //----------------------------------------------------------------------------- - #include "../../../gl/hlslCompat.glsl" #include "farFrustumQuad.glsl" #include "../../shadowMap/shadowMapIO_GLSL.h" @@ -116,7 +115,10 @@ void main() vec3 lightCol = lightColor.rgb; #ifdef USE_COOKIE_TEX // Lookup the cookie sample. - vec4 cookie = texture(cookieMap, shadowCoord); + vec4 pxlPosLightProj = tMul( worldToLightProj, vec4( surface.P, 1 ) ); + vec2 cookieCoord = ( ( pxlPosLightProj.xy / pxlPosLightProj.w ) * 0.5 ) + vec2( 0.5, 0.5 ); + cookieCoord.y = 1.0f - cookieCoord.y; + vec4 cookie = texture(cookieMap, cookieCoord); // Multiply the light with the cookie tex. lightCol *= cookie.rgb; // Use a maximum channel luminance to attenuate @@ -169,7 +171,7 @@ void main() // Multiply the light with the iesMask tex. shadow *= iesMask; #endif - + //get spot light contribution lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow); }