diff options
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve/opengl/shader')
12 files changed, 43 insertions, 24 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java b/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java index 4a66295f2..7a20fc2da 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java @@ -6,7 +6,7 @@ public class UniformNames { public static final String gcu_Weight = "gcu_Weight"; public static final String gcu_ColorTexUnit = "gcu_ColorTexUnit"; public static final String gcu_ColorTexBBox = "gcu_ColorTexBBox"; - public static final String gcu_ClipBBox = "gcu_ClipBBox"; + public static final String gcu_ClipFrustum = "gcu_ClipFrustum"; public static final String gcu_PMVMatrix02 = "gcu_PMVMatrix02"; // gcu_PMVMatrix[3]; // P, Mv, and Mvi public static final String gcu_FboTexUnit = "gcu_FboTexUnit"; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl index c5850f5fa..edb3b553b 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl @@ -1,7 +1,7 @@ // Copyright 2010-2024 JogAmp Community. All rights reserved. -#ifdef USE_AABBOX_CLIPPING - if( is_inside(gcv_ClipBBoxCoord, gcu_ClipBBox[0], gcu_ClipBBox[1]) < 0.5 ) { +#ifdef USE_FRUSTUM_CLIPPING + if( isOutsideMvFrustum(gcv_ClipCoord) ) { #if USE_DISCARD discard; // discard freezes NV tegra2 compiler #else diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_weight.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_weight.glsl index e7172d834..9c8b6a4a5 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_weight.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_weight.glsl @@ -1,7 +1,7 @@ // Copyright 2010-2024 JogAmp Community. All rights reserved. -#ifdef USE_AABBOX_CLIPPING - if( is_inside(gcv_ClipBBoxCoord, gcu_ClipBBox[0], gcu_ClipBBox[1]) < 0.5 ) { +#ifdef USE_FRUSTUM_CLIPPING + if( isOutsideMvFrustum(gcv_ClipCoord) ) { #if USE_DISCARD discard; // discard freezes NV tegra2 compiler #else diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl index 3d4cdc887..3b7291446 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl @@ -1,6 +1,7 @@ // Pass-2: Dump Texture -#ifdef USE_AABBOX_CLIPPING - if( is_inside(gcv_ClipBBoxCoord, gcu_ClipBBox[0], gcu_ClipBBox[1]) < 0.5 ) { + +#ifdef USE_FRUSTUM_CLIPPING + if( isOutsideMvFrustum(gcv_ClipCoord) ) { #if USE_DISCARD discard; // discard freezes NV tegra2 compiler #else diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_even.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_even.glsl index 5e14a1a23..c71267be4 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_even.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_even.glsl @@ -1,10 +1,10 @@ // Pass-2: AA on Texture // Note: gcv_FboTexCoord is in center of sample pixels. -#ifdef USE_AABBOX_CLIPPING - if( is_inside(gcv_ClipBBoxCoord, gcu_ClipBBox[0], gcu_ClipBBox[1]) < 0.5 ) { +#ifdef USE_FRUSTUM_CLIPPING + if( isOutsideMvFrustum(gcv_ClipCoord) ) { #if USE_DISCARD - discard; // discard freezes NV tegra2 compiler + discard; // discard freezes NV tegra2 compiler #else mgl_FragColor = vec4(0); #endif diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_odd.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_odd.glsl index b7d2e0e4e..4fa3c601e 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_odd.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_odd.glsl @@ -1,8 +1,8 @@ // Pass-2: AA on Texture // Note: gcv_FboTexCoord is in center of sample pixels. -#ifdef USE_AABBOX_CLIPPING - if( is_inside(gcv_ClipBBoxCoord, gcu_ClipBBox[0], gcu_ClipBBox[1]) < 0.5 ) { +#ifdef USE_FRUSTUM_CLIPPING + if( isOutsideMvFrustum(gcv_ClipCoord) ) { #if USE_DISCARD discard; // discard freezes NV tegra2 compiler #else diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_flipquad3.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_flipquad3.glsl index da0306425..76b064420 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_flipquad3.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_flipquad3.glsl @@ -4,8 +4,8 @@ // // Same as flipquad - but w/ rgss coordinates -#ifdef USE_AABBOX_CLIPPING - if( is_inside(gcv_ClipBBoxCoord, gcu_ClipBBox[0], gcu_ClipBBox[1]) < 0.5 ) { +#ifdef USE_FRUSTUM_CLIPPING + if( isOutsideMvFrustum(gcv_ClipCoord) ) { #if USE_DISCARD discard; // discard freezes NV tegra2 compiler #else diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2.vp index dce78b9c8..5ee5fcb46 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2.vp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2.vp @@ -14,8 +14,8 @@ void main(void) // gl_Position = gcu_PMVMatrix01[0] * gcu_PMVMatrix01[1] * vec4(gca_FboVertices, 1); gl_Position = gcu_PMVMatrix01[0] * gcu_PMVMatrix01[1] * gca_FboVertices; -#ifdef USE_AABBOX_CLIPPING - gcv_ClipBBoxCoord = (gcu_PMVMatrix01[1] * gca_FboVertices).xyz; // Mv +#ifdef USE_FRUSTUM_CLIPPING + gcv_ClipCoord = (gcu_PMVMatrix01[1] * gca_FboVertices).xyz; // Mv #endif gcv_FboTexCoord = gca_FboTexCoords; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-single.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-single.vp index 2f07ad7d0..bda10c432 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-single.vp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-single.vp @@ -24,8 +24,8 @@ void main(void) } #endif -#ifdef USE_AABBOX_CLIPPING - gcv_ClipBBoxCoord = (gcu_PMVMatrix01[1] * gca_Vertices).xyz; // Mv +#ifdef USE_FRUSTUM_CLIPPING + gcv_ClipCoord = (gcu_PMVMatrix01[1] * gca_Vertices).xyz; // Mv #endif #ifdef USE_COLOR_TEXTURE diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/functions.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/functions.glsl index 41e65178e..3b36b021a 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/functions.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/functions.glsl @@ -75,12 +75,30 @@ vec4 clip_coord(vec4 col_in, vec4 col_ex, vec3 coord, vec3 low, vec3 high) { * </p> */ float is_inside(vec2 coord, vec2 low, vec2 high) { - return v_mul( step(low, coord) ) * ( 1 - v_or( step(high+EPSILON, coord) ) ); + return v_mul( step(low-EPSILON, coord) ) * ( 1 - v_or( step(high+EPSILON, coord) ) ); } /** Branch-less clipping test using vec3 coordinates and low/high clipping. */ float is_inside(vec3 coord, vec3 low, vec3 high) { - return v_mul( step(low, coord) ) * ( 1 - v_or( step(high+EPSILON, coord) ) ); + return v_mul( step(low-EPSILON, coord) ) * ( 1 - v_or( step(high+EPSILON, coord) ) ); } +/** Return distance of plane {n, d} to given point p. */ +float planeDistance(vec3 n, float d, vec3 p) { + return dot(n, p) + d; +} + +#ifdef USE_FRUSTUM_CLIPPING + +bool isOutsideMvFrustum(vec3 p) { + return planeDistance(gcu_ClipFrustum[0].xyz, gcu_ClipFrustum[0].w, p) < 0 || + planeDistance(gcu_ClipFrustum[1].xyz, gcu_ClipFrustum[1].w, p) < 0 || + planeDistance(gcu_ClipFrustum[2].xyz, gcu_ClipFrustum[2].w, p) < 0 || + planeDistance(gcu_ClipFrustum[3].xyz, gcu_ClipFrustum[3].w, p) < 0 || + planeDistance(gcu_ClipFrustum[4].xyz, gcu_ClipFrustum[4].w, p) < 0 || + planeDistance(gcu_ClipFrustum[5].xyz, gcu_ClipFrustum[5].w, p) < 0; +} + +#endif // USE_FRUSTUM_CLIPPING + #endif // functions_glsl diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl index a9554528c..18c563fbb 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl @@ -10,8 +10,8 @@ uniform float gcu_Weight; #ifdef USE_COLOR_TEXTURE uniform vec2 gcu_ColorTexBBox[3]; // box-min[2], box-max[2] and tex-size[2] #endif -#ifdef USE_AABBOX_CLIPPING - uniform vec3 gcu_ClipBBox[2]; // box-min[3], box-max[3] +#ifdef USE_FRUSTUM_CLIPPING + uniform vec4 gcu_ClipFrustum[6]; // L, R, B, T, N, F each {n.x, n.y, n.z, d} #endif uniform mat4 gcu_PMVMatrix02[3]; // P, Mv, and Mvi diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl index 0e8d5b843..6139c9d8f 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl @@ -10,8 +10,8 @@ varying vec2 gcv_FboTexCoord; #ifdef USE_COLOR_TEXTURE varying vec2 gcv_ColorTexCoord; #endif -#ifdef USE_AABBOX_CLIPPING - varying vec3 gcv_ClipBBoxCoord; +#ifdef USE_FRUSTUM_CLIPPING + varying vec3 gcv_ClipCoord; #endif #ifdef USE_COLOR_CHANNEL |