Skip to content

Commit

Permalink
Use ARB_conservative_depth when available
Browse files Browse the repository at this point in the history
and discard fragment when ray does not intersect voxels.
  • Loading branch information
httpdigest committed Jan 4, 2024
1 parent 42dd5f5 commit e738b4d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions res/org/lwjgl/demo/opengl/shader/raymarching.fs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#version 330 core

layout (location = 0) out vec4 fragColor;
#ifdef GL_ARB_conservative_depth
#extension GL_ARB_conservative_depth : enable
layout (depth_less) out float gl_FragDepth;
#endif

uniform sampler3D tex;
uniform mat4 mvp;
Expand All @@ -31,8 +35,7 @@ vec3 rayMarch(vec3 o, vec3 d, vec3 ts) {
break;
}
}
gl_FragDepth = 1.0-1e-6;
return vec3(i)/vec3(N);
discard;
}

void main(void) {
Expand Down

0 comments on commit e738b4d

Please sign in to comment.