From 85f1687769fbd1e144e84e681a69551e9a3aa24d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 4 Mar 2024 21:41:56 +0100 Subject: [PATCH] Sync shader code from vkdoom --- src/lightmapper/glsl/trace_light.glsl.h | 4 ++-- src/lightmapper/glsl/trace_sunlight.glsl.h | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lightmapper/glsl/trace_light.glsl.h b/src/lightmapper/glsl/trace_light.glsl.h index 20800d6..b36b94a 100644 --- a/src/lightmapper/glsl/trace_light.glsl.h +++ b/src/lightmapper/glsl/trace_light.glsl.h @@ -71,8 +71,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/src/lightmapper/glsl/trace_sunlight.glsl.h b/src/lightmapper/glsl/trace_sunlight.glsl.h index 4febd86..e7cc26c 100644 --- a/src/lightmapper/glsl/trace_sunlight.glsl.h +++ b/src/lightmapper/glsl/trace_sunlight.glsl.h @@ -54,12 +54,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;