Skip to content

Commit

Permalink
Sync shader code from vkdoom
Browse files Browse the repository at this point in the history
  • Loading branch information
dpjudas committed Mar 4, 2024
1 parent f2ecc9c commit 85f1687
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/lightmapper/glsl/trace_light.glsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions src/lightmapper/glsl/trace_sunlight.glsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 85f1687

Please sign in to comment.