aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/curve
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-01-20 05:01:38 +0100
committerSven Göthel <[email protected]>2024-01-20 05:01:38 +0100
commitc1531c3d99b19032040018b9414263b0d3000147 (patch)
tree93ad05df0398d430884350166a88371f82143947 /src/jogl/classes/jogamp/graph/curve
parent5cca51e32999a882e2a5f00cb45ecafc824ffd86 (diff)
Graph Clipping: Use Frustum Clipping using AABBox -> Mv transformed Cube -> Frustum mapping + GraphUI Support
AABBox clipping naturally couldn't be transformed into 3D Model-View (Mv) Space, as it is axis aligned and only provided 2 points (min/max). Therefor we map the Group's AABBox to a 8-point Cube, perform the Mv-transformation and then produce the 6-plane Frustum. As before, we cull fully outside shapes within the Group's draw method and perform fragment clipping with same Frustum planes in the shader. With clipping enabled, the 3D z-axis getBounds() depth will be slightly increased for functional Frustum operation. This is also done for setFixedSize(Vec2f). The Frustum planes are copied to the Graph shader via float[4*6] -> uniform vec4 gcu_ClipFrustum[6]; // L, R, B, T, N, F each {n.x, n.y, n.z, d} +++ Concludes related work of below commits - 1040bed4ecc6f4598ea459f1073a9240583fc3c3 - 5cca51e32999a882e2a5f00cb45ecafc824ffd86
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java24
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java108
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java25
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java2
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl4
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_weight.glsl4
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl5
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_even.glsl6
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_bforce_odd.glsl4
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_flipquad3.glsl4
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2.vp4
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-single.vp4
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/functions.glsl22
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl4
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl4
15 files changed, 121 insertions, 103 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index ae4a734be..a6ba0e810 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -45,6 +45,7 @@ import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.math.Matrix4f;
import com.jogamp.math.Recti;
import com.jogamp.math.geom.AABBox;
+import com.jogamp.math.geom.Frustum;
import com.jogamp.math.util.SyncMatrices4f16;
import com.jogamp.opengl.FBObject;
import com.jogamp.opengl.FBObject.Attachment;
@@ -66,8 +67,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
private final GLUniformData gcu_ColorTexUnit;
private final float[] colorTexBBox; // minX/minY, maxX/maxY, texW/texH
private final GLUniformData gcu_ColorTexBBox; // vec2 gcu_ColorTexBBox[3] -> boxMin[2], boxMax[2] and texSize[2]
- private final float[] clipBBox; // minX/minY/minZ, maxX/maxY/maxZ
- private final GLUniformData gcu_ClipBBox; // uniform vec3 gcu_ClipBBox[2]; // box-min[3], box-max[3]
+ private final float[/* 4*6 */] clipFrustum; // 6 frustum planes, each [n.x, n.y. n.z, d]
+ private final GLUniformData gcu_ClipFrustum; // uniform vec4 gcu_ClipFrustum[6]; // L, R, B, T, N, F
private ShaderProgram spPass1 = null;
// Pass-2:
@@ -111,8 +112,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
colorTexBBox = null;
gcu_ColorTexBBox = null;
}
- clipBBox = new float[6];
- gcu_ClipBBox = new GLUniformData(UniformNames.gcu_ClipBBox, 3, FloatBuffer.wrap(clipBBox));
+ clipFrustum = new float[4*6];
+ gcu_ClipFrustum = new GLUniformData(UniformNames.gcu_ClipFrustum, 4, FloatBuffer.wrap(clipFrustum));
gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, new SyncMatrices4f16( new Matrix4f[] { matP, matMv } ));
// Pass 2:
@@ -185,7 +186,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ) && null != colorTexSeq;
final RenderState rs = renderer.getRenderState();
- final boolean hasAABBoxClipping = null != rs.getClipBBox() && ( ( !isTwoPass && pass1 ) || ( isTwoPass && !pass1 ) );
+ final boolean hasFrustumClipping = null != rs.getClipFrustum() && ( ( !isTwoPass && pass1 ) || ( isTwoPass && !pass1 ) );
final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, colorTexSeq);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
@@ -230,8 +231,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, false, true);
rs.updateUniformDataLoc(gl, updateLocLocal, false /* updateData */, gcu_FboTexUnit, true); // FIXME always update if changing tex-unit
}
- if( hasAABBoxClipping && updateLocLocal ) {
- rs.updateUniformLoc(gl, true, gcu_ClipBBox, true);
+ if( hasFrustumClipping && updateLocLocal ) {
+ rs.updateUniformLoc(gl, true, gcu_ClipFrustum, true);
}
}
@@ -381,11 +382,10 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
}
{
- final AABBox cb = rs.getClipBBox();
- if( null != cb ) {
- clipBBox[0] = cb.getMinX(); clipBBox[1] = cb.getMinY(); clipBBox[2] = cb.getMinZ();
- clipBBox[3] = cb.getMaxX(); clipBBox[4] = cb.getMaxY(); clipBBox[5] = cb.getMaxZ();
- gl.glUniform(gcu_ClipBBox); // Always update, since program maybe used by multiple regions
+ final Frustum f = rs.getClipFrustum();
+ if( null != f ) {
+ f.getPlanes(clipFrustum, 0);
+ gl.glUniform(gcu_ClipFrustum); // Always update, since program maybe used by multiple regions
}
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
index bf23f33e9..4585c4cab 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -46,6 +46,7 @@ import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.math.Matrix4f;
import com.jogamp.math.Recti;
import com.jogamp.math.geom.AABBox;
+import com.jogamp.math.geom.Frustum;
import com.jogamp.math.util.SyncMatrices4f16;
import com.jogamp.opengl.FBObject;
import com.jogamp.opengl.FBObject.Attachment;
@@ -71,8 +72,8 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
private final GLUniformData gcu_ColorTexUnit;
private final float[] colorTexBBox; // minX/minY, maxX/maxY, texW/texH
private final GLUniformData gcu_ColorTexBBox; // vec2 gcu_ColorTexBBox[3] -> boxMin[2], boxMax[2] and texSize[2]
- private final float[] clipBBox; // minX/minY/minZ, maxX/maxY/maxZ
- private final GLUniformData gcu_ClipBBox; // uniform vec3 gcu_ClipBBox[2]; // box-min[3], box-max[3]
+ private final float[/* 4*6 */] clipFrustum; // 6 frustum planes, each [n.x, n.y. n.z, d]
+ private final GLUniformData gcu_ClipFrustum; // uniform vec4 gcu_ClipFrustum[6]; // L, R, B, T, N, F
private ShaderProgram spPass1 = null;
// Pass-2:
@@ -96,6 +97,50 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
final int[] maxTexSize = new int[] { -1 } ;
+ public VBORegion2PVBAAES2(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit,
+ final int initialVerticesCount, final int initialIndicesCount)
+ {
+ super(glp, renderModes, colorTexSeq);
+
+ rsLocal = new RenderState.ProgramLocal();
+
+ // Pass 1:
+ initBuffer(initialVerticesCount, initialIndicesCount);
+
+ if( hasColorTexture() ) {
+ gcu_ColorTexUnit = new GLUniformData(UniformNames.gcu_ColorTexUnit, colorTexSeq.getTextureUnit());
+ colorTexBBox = new float[6];
+ gcu_ColorTexBBox = new GLUniformData(UniformNames.gcu_ColorTexBBox, 2, FloatBuffer.wrap(colorTexBBox));
+ } else {
+ gcu_ColorTexUnit = null;
+ colorTexBBox = null;
+ gcu_ColorTexBBox = null;
+ }
+ clipFrustum = new float[4*6];
+ gcu_ClipFrustum = new GLUniformData(UniformNames.gcu_ClipFrustum, 4, FloatBuffer.wrap(clipFrustum));
+ gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, new SyncMatrices4f16( new Matrix4f[] { matP, matMv } ));
+
+ // Pass 2:
+ gcu_FboTexUnit = new GLUniformData(UniformNames.gcu_FboTexUnit, pass2TexUnit);
+ gcu_FboTexSize = new GLUniformData(UniformNames.gcu_FboTexSize, 2, FloatBuffer.wrap(new float[2]));
+
+ indicesFbo = GLArrayDataServer.createData(3, GL.GL_UNSIGNED_SHORT, 2, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
+ indicesFbo.puts((short) 0); indicesFbo.puts((short) 1); indicesFbo.puts((short) 3);
+ indicesFbo.puts((short) 1); indicesFbo.puts((short) 2); indicesFbo.puts((short) 3);
+ indicesFbo.seal(true);
+
+ gca_FboTexCoordsAttr = GLArrayDataServer.createGLSL(AttributeNames.FBO_TEXCOORDS_ATTR_NAME, 2, GL.GL_FLOAT,
+ false, 4, GL.GL_STATIC_DRAW);
+ gca_FboTexCoordsAttr.putf(0); gca_FboTexCoordsAttr.putf(0);
+ gca_FboTexCoordsAttr.putf(0); gca_FboTexCoordsAttr.putf(1);
+ gca_FboTexCoordsAttr.putf(1); gca_FboTexCoordsAttr.putf(1);
+ gca_FboTexCoordsAttr.putf(1); gca_FboTexCoordsAttr.putf(0);
+ gca_FboTexCoordsAttr.seal(true);
+
+ gca_FboVerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.FBO_VERTEX_ATTR_NAME, 3, GL.GL_FLOAT,
+ false, 4, GL.GL_STATIC_DRAW);
+ }
+
/**
* <p>
* Since multiple {@link Region}s may share one
@@ -113,7 +158,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ) && null != colorTexSeq;
final RenderState rs = renderer.getRenderState();
- final boolean hasAABBoxClipping = null != rs.getClipBBox() && ( ( !isTwoPass && pass1 ) || ( isTwoPass && !pass1 ) );
+ final boolean hasFrustumClipping = null != rs.getClipFrustum() && ( ( !isTwoPass && pass1 ) || ( isTwoPass && !pass1 ) );
final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, colorTexSeq);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
@@ -159,55 +204,11 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
rs.updateUniformDataLoc(gl, updateLocLocal, false /* updateData */, gcu_FboTexUnit, true); // FIXME always update if changing tex-unit
rs.updateUniformLoc(gl, updateLocLocal, gcu_FboTexSize, rs.getSampleCount() > 1); // maybe optimized away for sampleCount <= 1
}
- if( hasAABBoxClipping && updateLocLocal ) {
- rs.updateUniformLoc(gl, true, gcu_ClipBBox, true);
+ if( hasFrustumClipping && updateLocLocal ) {
+ rs.updateUniformLoc(gl, true, gcu_ClipFrustum, true);
}
}
- public VBORegion2PVBAAES2(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit,
- final int initialVerticesCount, final int initialIndicesCount)
- {
- super(glp, renderModes, colorTexSeq);
-
- rsLocal = new RenderState.ProgramLocal();
-
- // Pass 1:
- initBuffer(initialVerticesCount, initialIndicesCount);
-
- if( hasColorTexture() ) {
- gcu_ColorTexUnit = new GLUniformData(UniformNames.gcu_ColorTexUnit, colorTexSeq.getTextureUnit());
- colorTexBBox = new float[6];
- gcu_ColorTexBBox = new GLUniformData(UniformNames.gcu_ColorTexBBox, 2, FloatBuffer.wrap(colorTexBBox));
- } else {
- gcu_ColorTexUnit = null;
- colorTexBBox = null;
- gcu_ColorTexBBox = null;
- }
- clipBBox = new float[6];
- gcu_ClipBBox = new GLUniformData(UniformNames.gcu_ClipBBox, 3, FloatBuffer.wrap(clipBBox));
- gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, new SyncMatrices4f16( new Matrix4f[] { matP, matMv } ));
-
- // Pass 2:
- gcu_FboTexUnit = new GLUniformData(UniformNames.gcu_FboTexUnit, pass2TexUnit);
- gcu_FboTexSize = new GLUniformData(UniformNames.gcu_FboTexSize, 2, FloatBuffer.wrap(new float[2]));
-
- indicesFbo = GLArrayDataServer.createData(3, GL.GL_UNSIGNED_SHORT, 2, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
- indicesFbo.puts((short) 0); indicesFbo.puts((short) 1); indicesFbo.puts((short) 3);
- indicesFbo.puts((short) 1); indicesFbo.puts((short) 2); indicesFbo.puts((short) 3);
- indicesFbo.seal(true);
-
- gca_FboTexCoordsAttr = GLArrayDataServer.createGLSL(AttributeNames.FBO_TEXCOORDS_ATTR_NAME, 2, GL.GL_FLOAT,
- false, 4, GL.GL_STATIC_DRAW);
- gca_FboTexCoordsAttr.putf(0); gca_FboTexCoordsAttr.putf(0);
- gca_FboTexCoordsAttr.putf(0); gca_FboTexCoordsAttr.putf(1);
- gca_FboTexCoordsAttr.putf(1); gca_FboTexCoordsAttr.putf(1);
- gca_FboTexCoordsAttr.putf(1); gca_FboTexCoordsAttr.putf(0);
- gca_FboTexCoordsAttr.seal(true);
-
- gca_FboVerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.FBO_VERTEX_ATTR_NAME, 3, GL.GL_FLOAT,
- false, 4, GL.GL_STATIC_DRAW);
- }
-
@Override
public void setTextureUnit(final int pass2TexUnit) {
gcu_FboTexUnit.setData(pass2TexUnit);
@@ -420,11 +421,10 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
gl.glUniform(gcu_FboTexSize);
{
- final AABBox cb = rs.getClipBBox();
- if( null != cb ) {
- clipBBox[0] = cb.getMinX(); clipBBox[1] = cb.getMinY(); clipBBox[2] = cb.getMinZ();
- clipBBox[3] = cb.getMaxX(); clipBBox[4] = cb.getMaxY(); clipBBox[5] = cb.getMaxZ();
- gl.glUniform(gcu_ClipBBox); // Always update, since program maybe used by multiple regions
+ final Frustum f = rs.getClipFrustum();
+ if( null != f ) {
+ f.getPlanes(clipFrustum, 0);
+ gl.glUniform(gcu_ClipFrustum); // Always update, since program maybe used by multiple regions
}
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index 3a568758c..c4e842791 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -40,7 +40,7 @@ import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
-import com.jogamp.math.geom.AABBox;
+import com.jogamp.math.geom.Frustum;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureSequence;
@@ -52,8 +52,8 @@ public final class VBORegionSPES2 extends GLRegion {
private final GLUniformData gcu_ColorTexUnit;
private final float[] colorTexBBox; // minX/minY, maxX/maxY, texW/texH
private final GLUniformData gcu_ColorTexBBox; // vec2 gcu_ColorTexBBox[3] -> boxMin[2], boxMax[2] and texSize[2]
- private final float[] clipBBox; // minX/minY/minZ, maxX/maxY/maxZ
- private final GLUniformData gcu_ClipBBox; // uniform vec3 gcu_ClipBBox[2]; // box-min[3], box-max[3]
+ private final float[/* 4*6 */] clipFrustum; // 6 frustum planes, each [n.x, n.y. n.z, d]
+ private final GLUniformData gcu_ClipFrustum; // uniform vec4 gcu_ClipFrustum[6]; // L, R, B, T, N, F
private ShaderProgram spPass1 = null;
public VBORegionSPES2(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq,
@@ -74,8 +74,8 @@ public final class VBORegionSPES2 extends GLRegion {
colorTexBBox = null;
gcu_ColorTexBBox = null;
}
- clipBBox = new float[6];
- gcu_ClipBBox = new GLUniformData(UniformNames.gcu_ClipBBox, 3, FloatBuffer.wrap(clipBBox));
+ clipFrustum = new float[4*6];
+ gcu_ClipFrustum = new GLUniformData(UniformNames.gcu_ClipFrustum, 4, FloatBuffer.wrap(clipFrustum));
}
@Override
@@ -122,7 +122,7 @@ public final class VBORegionSPES2 extends GLRegion {
final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ) && null != colorTexSeq;
final RenderState rs = renderer.getRenderState();
- final boolean hasAABBoxClipping = null != rs.getClipBBox();
+ final boolean hasFrustumClipping = null != rs.getClipFrustum();
final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, true, colorTexSeq);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
@@ -139,8 +139,8 @@ public final class VBORegionSPES2 extends GLRegion {
if( hasColorChannel && null != gca_ColorsAttr ) {
rs.updateAttributeLoc(gl, true, gca_ColorsAttr, throwOnError);
}
- if( hasAABBoxClipping ) {
- rs.updateUniformLoc(gl, true, gcu_ClipBBox, throwOnError);
+ if( hasFrustumClipping ) {
+ rs.updateUniformLoc(gl, true, gcu_ClipFrustum, throwOnError);
}
}
rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, true, throwOnError);
@@ -158,11 +158,10 @@ public final class VBORegionSPES2 extends GLRegion {
useShaderProgram(gl, renderer, curRenderModes);
{
- final AABBox cb = renderer.getClipBBox();
- if( null != cb ) {
- clipBBox[0] = cb.getMinX(); clipBBox[1] = cb.getMinY(); clipBBox[2] = cb.getMinZ();
- clipBBox[3] = cb.getMaxX(); clipBBox[4] = cb.getMaxY(); clipBBox[5] = cb.getMaxZ();
- gl.glUniform(gcu_ClipBBox); // Always update, since program maybe used by multiple regions
+ final Frustum f = renderer.getClipFrustum();
+ if( null != f ) {
+ f.getPlanes(clipFrustum, 0);
+ gl.glUniform(gcu_ClipFrustum); // Always update, since program maybe used by multiple regions
}
}
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