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 8771c46
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions res/org/lwjgl/demo/opengl/shader/raymarching.fs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
#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;
uniform vec3 camPosition;

in vec3 o;
in vec3 d;
Expand All @@ -31,8 +34,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 8771c46

Please sign in to comment.