thinking about shaders

This commit is contained in:
2021-02-24 18:30:45 -08:00
parent 813d2f6f2f
commit 7fb89e7d6e
6 changed files with 185 additions and 17 deletions

View File

@@ -36,16 +36,17 @@ float fetch_shadow(int light_id, vec4 homogeneous_coords) {
if (homogeneous_coords.w <= 0.0) {
return 1.0;
}
// compensate for the Y-flip difference between the NDC and texture coordinates
// compensate for the Y-flip difference between the normalized device
// coordinates (NDC) and texture coordinates
const vec2 flip_correction = vec2(0.5, -0.5);
// compute texture coordinates for shadow lookup
vec4 light_local = vec4(
// I don't know what kind of jank shit is going on on this line
homogeneous_coords.xy * flip_correction/homogeneous_coords.w + 0.5,
light_id,
homogeneous_coords.z / homogeneous_coords.w
light_id, // array layer
homogeneous_coords.z / homogeneous_coords.w // D-Ref
);
// do the lookup, using HW PCF and comparison
// do the lookup, using HW percentage closer filtering(PCF) and comparison
return texture(sampler2DArrayShadow(t_Shadow, s_Shadow), light_local);
}