From b99cf589e741cdc364be4741808b43c2dcea17ad Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 4 Mar 2024 21:40:11 +0100 Subject: [PATCH] Fix midtextures being opaque --- wadsrc/static/shaders/lightmap/trace_light.glsl | 4 ++-- wadsrc/static/shaders/lightmap/trace_sunlight.glsl | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/wadsrc/static/shaders/lightmap/trace_light.glsl b/wadsrc/static/shaders/lightmap/trace_light.glsl index aa8980eb4..bc758c054 100644 --- a/wadsrc/static/shaders/lightmap/trace_light.glsl +++ b/wadsrc/static/shaders/lightmap/trace_light.glsl @@ -70,8 +70,8 @@ vec4 TracePointLightRay(vec3 origin, vec3 lightpos, float tmin, vec4 rayColor) // Blend with surface texture rayColor = BlendTexture(surface, GetSurfaceUV(result.primitiveIndex, result.primitiveWeights), rayColor); - // Stop if it isn't a portal, or there is no light left - if (surface.PortalIndex == 0 || rayColor.r + rayColor.g + rayColor.b <= 0.0) + // Stop if there is no light left + if (rayColor.r + rayColor.g + rayColor.b <= 0.0) return vec4(0.0); // Move to surface hit point diff --git a/wadsrc/static/shaders/lightmap/trace_sunlight.glsl b/wadsrc/static/shaders/lightmap/trace_sunlight.glsl index 727196807..8397e3cca 100644 --- a/wadsrc/static/shaders/lightmap/trace_sunlight.glsl +++ b/wadsrc/static/shaders/lightmap/trace_sunlight.glsl @@ -53,12 +53,16 @@ vec4 TraceSunRay(vec3 origin, float tmin, vec3 dir, float tmax, vec4 rayColor) SurfaceInfo surface = GetSurface(result.primitiveIndex); + // Stop if we hit the sky. + if (surface.Sky > 0.0) + return rayColor; + // Blend with surface texture rayColor = BlendTexture(surface, GetSurfaceUV(result.primitiveIndex, result.primitiveWeights), rayColor); - // Stop if it isn't a portal, or there is no light left - if (surface.PortalIndex == 0 || rayColor.r + rayColor.g + rayColor.b <= 0.0) - return rayColor * surface.Sky; + // Stop if there is no light left + if (rayColor.r + rayColor.g + rayColor.b <= 0.0) + return vec4(0.0); // Move to surface hit point origin += dir * result.t;