-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a variant of the experiment on-stream, but somewhat less aggressive: we trace half of the rays in a checkerboard pattern, and reconstruct missing pixels from 4 neighbors using bilateral weights. This also results in increased aliasing but it's less severe vs half-res, and of course the performance gains are less substantial.
- Loading branch information
Showing
3 changed files
with
92 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#version 460 | ||
|
||
#extension GL_GOOGLE_include_directive: require | ||
|
||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; | ||
|
||
layout(push_constant) uniform block | ||
{ | ||
vec2 imageSize; | ||
}; | ||
|
||
layout(binding = 0, r8) uniform image2D shadowImage; | ||
layout(binding = 1) uniform sampler2D depthImage; | ||
|
||
void main() | ||
{ | ||
ivec2 pos = ivec2(gl_GlobalInvocationID.xy); | ||
|
||
// checkerboard odd | ||
pos.x *= 2; | ||
pos.x += 1 - (pos.y & 1); | ||
|
||
float depth = texelFetch(depthImage, pos, 0).r; | ||
|
||
vec4 depths = vec4( | ||
texelFetch(depthImage, pos + ivec2(-1, 0), 0).r, | ||
texelFetch(depthImage, pos + ivec2(+1, 0), 0).r, | ||
texelFetch(depthImage, pos + ivec2(0, -1), 0).r, | ||
texelFetch(depthImage, pos + ivec2(0, +1), 0).r | ||
); | ||
|
||
vec4 shadows = vec4( | ||
imageLoad(shadowImage, pos + ivec2(-1, 0)).r, | ||
imageLoad(shadowImage, pos + ivec2(+1, 0)).r, | ||
imageLoad(shadowImage, pos + ivec2(0, -1)).r, | ||
imageLoad(shadowImage, pos + ivec2(0, +1)).r | ||
); | ||
|
||
vec4 weights = exp2(-abs(depths / depth - 1) * 20); | ||
|
||
float shadow = dot(weights, shadows) / (dot(weights, vec4(1)) + 1e-2); | ||
|
||
imageStore(shadowImage, pos, vec4(shadow, 0, 0, 0)); | ||
} |