Ray-caster: check layer count
In debug mode, show the layer count instead of the shaded image. This reveals a bug: testing whether the hit depth is NaN doesn't actually detect sphere misses, because `sphere_cast` returns -1 rather than NaN to indicate a miss.
This commit is contained in:
parent
c04e29f586
commit
3d7ee98dd6
@ -40,7 +40,7 @@ uniform vec2 radius;
|
||||
uniform float opacity;
|
||||
uniform float highlight;
|
||||
uniform int layer_threshold;
|
||||
uniform bool test_mode;
|
||||
uniform bool debug_mode;
|
||||
|
||||
// light and camera
|
||||
const float focal_slope = 0.3;
|
||||
@ -151,6 +151,19 @@ void main() {
|
||||
}
|
||||
}
|
||||
|
||||
/* DEBUG */
|
||||
// in debug mode, show the layer count instead of the shaded image
|
||||
if (debug_mode) {
|
||||
// at the bottom of the screen, show the color scale instead of the
|
||||
// layer count
|
||||
if (gl_FragCoord.y < 10.) frag_cnt = int(8. * gl_FragCoord.x / resolution.x);
|
||||
|
||||
// convert number to color
|
||||
ivec3 bits = frag_cnt / ivec3(1, 2, 4);
|
||||
outColor = vec4(mod(vec3(bits), 2.), 1.);
|
||||
return;
|
||||
}
|
||||
|
||||
// sort the fragments by depth, using an insertion sort
|
||||
for (int take = 1; take < frag_cnt; ++take) {
|
||||
taggedFrag pulled = frags[take];
|
||||
|
Loading…
Reference in New Issue
Block a user