From 8771c460ced26e5be11d88bf211b09d818a7edfd Mon Sep 17 00:00:00 2001 From: httpdigest Date: Thu, 4 Jan 2024 14:22:49 +0100 Subject: [PATCH] Use ARB_conservative_depth when available and discard fragment when ray does not intersect voxels. --- res/org/lwjgl/demo/opengl/shader/raymarching.fs.glsl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/res/org/lwjgl/demo/opengl/shader/raymarching.fs.glsl b/res/org/lwjgl/demo/opengl/shader/raymarching.fs.glsl index 922288e3..7064dc6e 100644 --- a/res/org/lwjgl/demo/opengl/shader/raymarching.fs.glsl +++ b/res/org/lwjgl/demo/opengl/shader/raymarching.fs.glsl @@ -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; @@ -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) {