summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java87
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java101
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp26
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp42
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp83
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp90
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp130
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp119
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl7
9 files changed, 419 insertions, 266 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index cac55f6db..9b15ba319 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -27,6 +27,8 @@
*/
package jogamp.graph.curve.opengl;
+import java.nio.FloatBuffer;
+
import javax.media.opengl.GL2ES2;
// FIXME: Subsume GL2GL3.GL_DRAW_FRAMEBUFFER -> GL2ES2.GL_DRAW_FRAMEBUFFER !
import javax.media.opengl.GL;
@@ -36,6 +38,7 @@ import javax.media.opengl.fixedfunc.GLMatrixFunc;
import jogamp.graph.curve.opengl.shader.AttributeNames;
import jogamp.graph.curve.opengl.shader.UniformNames;
+import com.jogamp.common.nio.Buffers;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
@@ -63,7 +66,7 @@ public class VBORegion2PMSAAES2 extends GLRegion {
private int fboWidth = 0;
private int fboHeight = 0;
GLUniformData mgl_ActiveTexture;
- GLUniformData mgl_TextureSize; // if GLSL < 1.30
+ GLUniformData mgl_TextureSize;
final int[] maxTexSize = new int[] { -1 } ;
@@ -119,10 +122,10 @@ public class VBORegion2PMSAAES2 extends GLRegion {
texCoordFboAttr = GLArrayDataServer.createGLSL(AttributeNames.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT,
false, 4, GL.GL_STATIC_DRAW);
st.ownAttribute(texCoordFboAttr, true);
- texCoordFboAttr.putf(5); texCoordFboAttr.putf(5);
- texCoordFboAttr.putf(5); texCoordFboAttr.putf(6);
- texCoordFboAttr.putf(6); texCoordFboAttr.putf(6);
- texCoordFboAttr.putf(6); texCoordFboAttr.putf(5);
+ texCoordFboAttr.putf(0); texCoordFboAttr.putf(0);
+ texCoordFboAttr.putf(0); texCoordFboAttr.putf(1);
+ texCoordFboAttr.putf(1); texCoordFboAttr.putf(1);
+ texCoordFboAttr.putf(1); texCoordFboAttr.putf(0);
texCoordFboAttr.seal(true);
verticeFboAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT,
@@ -147,16 +150,16 @@ public class VBORegion2PMSAAES2 extends GLRegion {
// update all bbox related data
verticeFboAttr.seal(gl, false);
verticeFboAttr.rewind();
- verticeFboAttr.putf(box.getLow()[0]); verticeFboAttr.putf(box.getLow()[1]); verticeFboAttr.putf(box.getLow()[2]);
- verticeFboAttr.putf(box.getLow()[0]); verticeFboAttr.putf(box.getHigh()[1]); verticeFboAttr.putf(box.getLow()[2]);
- verticeFboAttr.putf(box.getHigh()[0]); verticeFboAttr.putf(box.getHigh()[1]); verticeFboAttr.putf(box.getLow()[2]);
- verticeFboAttr.putf(box.getHigh()[0]); verticeFboAttr.putf(box.getLow()[1]); verticeFboAttr.putf(box.getLow()[2]);
+ verticeFboAttr.putf(box.getMinX()); verticeFboAttr.putf(box.getMinY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMinX()); verticeFboAttr.putf(box.getMaxY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMaxX()); verticeFboAttr.putf(box.getMaxY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMaxX()); verticeFboAttr.putf(box.getMinY()); verticeFboAttr.putf(box.getMinZ());
verticeFboAttr.seal(gl, true);
verticeFboAttr.enableBuffer(gl, false);
fboPMVMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
fboPMVMatrix.glLoadIdentity();
- fboPMVMatrix.glOrthof(box.getLow()[0], box.getHigh()[0], box.getLow()[1], box.getHigh()[1], -1, 1);
+ fboPMVMatrix.glOrthof(box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY(), -1, 1);
// push data 2 GPU ..
indicesFbo.seal(gl, true);
@@ -179,7 +182,9 @@ public class VBORegion2PMSAAES2 extends GLRegion {
gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, maxTexSize, 0);
}
final RenderState rs = renderer.getRenderState();
+ float renderFboWidth, renderFboHeight;
int targetFboWidth, targetFboHeight;
+ float diffWidth, diffHeight;
{
// Calculate perspective pixel width/height for FBO,
// considering the sampleCount.
@@ -191,14 +196,20 @@ public class VBORegion2PMSAAES2 extends GLRegion {
final PMVMatrix pmv = renderer.getMatrix();
pmv.gluProject(box.getMinX(), box.getMinY(), objZ, view, 0, winPosSzMin, 0);
pmv.gluProject(box.getMaxX(), box.getMaxY(), objZ, view, 0, winPosSzMax, 0);
- targetFboWidth = Math.round(Math.abs(winPosSzMax[0] - winPosSzMin[0]));
- targetFboHeight = Math.round(Math.abs(winPosSzMax[1] - winPosSzMin[1]));
+ renderFboWidth = Math.abs(winPosSzMax[0] - winPosSzMin[0]);
+ renderFboHeight = Math.abs(winPosSzMax[1] - winPosSzMin[1]);
+ targetFboWidth = (int)Math.ceil(renderFboWidth);
+ targetFboHeight = (int)Math.ceil(renderFboHeight);
+ diffWidth = targetFboWidth-renderFboWidth;
+ diffHeight = targetFboHeight-renderFboHeight;
if( DEBUG_FBO_2 ) {
System.err.printf("XXX.MinMax1 min [%.1f, %.1f -> %.3f, %.3f, %.3f]"+
- ", max [%.1f, %.1f -> %.3f, %.3f, %.3f], view[%d, %d] -> [%d x %d], msaa %d%n",
+ ", max [%.1f, %.1f -> %.3f, %.3f, %.3f], view[%d, %d]: FBO f[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], msaa %d%n",
box.getMinX(), box.getMinY(), winPosSzMin[0], winPosSzMin[1], winPosSzMin[2],
box.getMaxX(), box.getMaxY(), winPosSzMax[0], winPosSzMax[1], winPosSzMax[2],
- view[2], view[3], targetFboWidth, targetFboHeight, sampleCount[0]);
+ view[2], view[3],
+ renderFboWidth, renderFboHeight, targetFboWidth, targetFboHeight,
+ diffWidth, diffHeight, sampleCount[0]);
}
}
final int deltaFboWidth = Math.abs(targetFboWidth-fboWidth);
@@ -222,29 +233,66 @@ public class VBORegion2PMSAAES2 extends GLRegion {
sampleCount[0], targetFboWidth, targetFboHeight);
}
// FIXME: maxTexSize test not correct
+ boolean rescale = false;
if( targetFboWidth > maxTexSize[0] ) {
targetFboWidth = maxTexSize[0];
+ renderFboWidth = targetFboWidth;
+ rescale = true;
}
if( targetFboHeight > maxTexSize[0] ) {
targetFboHeight = maxTexSize[0];
+ renderFboHeight = targetFboHeight;
+ rescale = true;
}
- if( DEBUG_FBO_1 ) {
- System.err.printf("XXX.Rescale (MAX): %d %d x %d%n",
- sampleCount[0], targetFboWidth, targetFboHeight);
+ if(rescale) {
+ diffWidth = targetFboWidth-renderFboWidth;
+ diffHeight = targetFboHeight-renderFboHeight;
+ if( DEBUG_FBO_1 ) {
+ System.err.printf("XXX.Rescale (MAX): FBO f[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], msaa %d%n",
+ renderFboWidth, renderFboHeight, targetFboWidth, targetFboHeight,
+ diffWidth, diffHeight, sampleCount[0]);
+ }
}
+ verticeFboAttr.seal(false);
+ verticeFboAttr.rewind();
+ verticeFboAttr.putf(box.getMinX()); verticeFboAttr.putf(box.getMinY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMinX()); verticeFboAttr.putf(box.getMaxY()+diffHeight); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMaxX()+diffWidth); verticeFboAttr.putf(box.getMaxY()+diffHeight); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMaxX()+diffWidth); verticeFboAttr.putf(box.getMinY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.seal(true);
+ fboPMVMatrix.glLoadIdentity();
+ fboPMVMatrix.glOrthof(box.getMinX(), box.getMaxX()+diffWidth,
+ box.getMinY(), box.getMaxY()+diffHeight, -1, 1);
renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, sampleCount);
+ } else {
+ texCoordFboAttr.setVBOWritten(false);
}
// System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3));
renderFBO(gl, rs, width, height);
}
}
+ private void setTexSize(final GL2ES2 gl, final ShaderState st, boolean firstPass) {
+ if(null == mgl_TextureSize) {
+ mgl_TextureSize = new GLUniformData(UniformNames.gcu_TextureSize, 3, Buffers.newDirectFloatBuffer(3));
+ }
+ final FloatBuffer texSize = (FloatBuffer) mgl_TextureSize.getBuffer();
+ if( firstPass ) {
+ texSize.put(2, 0f);
+ } else {
+ texSize.put(0, fboWidth);
+ texSize.put(1, fboHeight);
+ texSize.put(2, 1f);
+ }
+ st.uniform(gl, mgl_TextureSize);
+ }
- private void renderFBO(final GL2ES2 gl, final RenderState rs, final int width, final int hight) {
+ private void renderFBO(final GL2ES2 gl, final RenderState rs, final int width, final int height) {
final ShaderState st = rs.getShaderState();
- gl.glViewport(0, 0, width, hight);
+ gl.glViewport(0, 0, width, height);
st.uniform(gl, mgl_ActiveTexture);
gl.glActiveTexture(GL.GL_TEXTURE0 + mgl_ActiveTexture.intValue());
+ setTexSize(gl, st, false);
fbo.use(gl, fbo.getSamplingSink());
verticeFboAttr.enableBuffer(gl, true);
@@ -299,6 +347,7 @@ public class VBORegion2PMSAAES2 extends GLRegion {
fboHeight = targetFboHeight;
}
fbo.bind(gl);
+ setTexSize(gl, st, true);
//render texture
gl.glViewport(0, 0, fboWidth, fboHeight);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
index aeb8501ec..cac39fb21 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -30,7 +30,6 @@ package jogamp.graph.curve.opengl;
import java.nio.FloatBuffer;
import javax.media.opengl.GL2ES2;
-// FIXME: Subsume GL2GL3.GL_DRAW_FRAMEBUFFER -> GL2ES2.GL_DRAW_FRAMEBUFFER !
import javax.media.opengl.GL;
import javax.media.opengl.GLUniformData;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
@@ -68,7 +67,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
private int fboWidth = 0;
private int fboHeight = 0;
GLUniformData mgl_ActiveTexture;
- GLUniformData mgl_TextureSize; // if GLSL < 1.30
+ GLUniformData mgl_TextureSize;
final int[] maxTexSize = new int[] { -1 } ;
@@ -124,10 +123,10 @@ public class VBORegion2PVBAAES2 extends GLRegion {
texCoordFboAttr = GLArrayDataServer.createGLSL(AttributeNames.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT,
false, 4, GL.GL_STATIC_DRAW);
st.ownAttribute(texCoordFboAttr, true);
- texCoordFboAttr.putf(5); texCoordFboAttr.putf(5);
- texCoordFboAttr.putf(5); texCoordFboAttr.putf(6);
- texCoordFboAttr.putf(6); texCoordFboAttr.putf(6);
- texCoordFboAttr.putf(6); texCoordFboAttr.putf(5);
+ texCoordFboAttr.putf(0); texCoordFboAttr.putf(0);
+ texCoordFboAttr.putf(0); texCoordFboAttr.putf(1);
+ texCoordFboAttr.putf(1); texCoordFboAttr.putf(1);
+ texCoordFboAttr.putf(1); texCoordFboAttr.putf(0);
texCoordFboAttr.seal(true);
verticeFboAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT,
@@ -152,16 +151,16 @@ public class VBORegion2PVBAAES2 extends GLRegion {
// update all bbox related data
verticeFboAttr.seal(gl, false);
verticeFboAttr.rewind();
- verticeFboAttr.putf(box.getLow()[0]); verticeFboAttr.putf(box.getLow()[1]); verticeFboAttr.putf(box.getLow()[2]);
- verticeFboAttr.putf(box.getLow()[0]); verticeFboAttr.putf(box.getHigh()[1]); verticeFboAttr.putf(box.getLow()[2]);
- verticeFboAttr.putf(box.getHigh()[0]); verticeFboAttr.putf(box.getHigh()[1]); verticeFboAttr.putf(box.getLow()[2]);
- verticeFboAttr.putf(box.getHigh()[0]); verticeFboAttr.putf(box.getLow()[1]); verticeFboAttr.putf(box.getLow()[2]);
+ verticeFboAttr.putf(box.getMinX()); verticeFboAttr.putf(box.getMinY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMinX()); verticeFboAttr.putf(box.getMaxY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMaxX()); verticeFboAttr.putf(box.getMaxY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMaxX()); verticeFboAttr.putf(box.getMinY()); verticeFboAttr.putf(box.getMinZ());
verticeFboAttr.seal(gl, true);
verticeFboAttr.enableBuffer(gl, false);
fboPMVMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
fboPMVMatrix.glLoadIdentity();
- fboPMVMatrix.glOrthof(box.getLow()[0], box.getHigh()[0], box.getLow()[1], box.getHigh()[1], -1, 1);
+ fboPMVMatrix.glOrthof(box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY(), -1, 1);
// push data 2 GPU ..
indicesFbo.seal(gl, true);
@@ -186,6 +185,8 @@ public class VBORegion2PVBAAES2 extends GLRegion {
final RenderState rs = renderer.getRenderState();
final float winWidth, winHeight;
int targetFboWidth, targetFboHeight;
+ float renderFboWidth, renderFboHeight;
+ float diffWidth, diffHeight;
{
// Calculate perspective pixel width/height for FBO,
// considering the sampleCount.
@@ -199,15 +200,21 @@ public class VBORegion2PVBAAES2 extends GLRegion {
pmv.gluProject(box.getMaxX(), box.getMaxY(), objZ, view, 0, winPosSzMax, 0);
winWidth = Math.abs(winPosSzMax[0] - winPosSzMin[0]);
winHeight = Math.abs(winPosSzMax[1] - winPosSzMin[1]);
- targetFboWidth = Math.round(winWidth*sampleCount[0]);
- targetFboHeight= Math.round(winHeight*sampleCount[0]);
+ diffWidth = (float)Math.ceil(winWidth)-winWidth;
+ diffHeight = (float)Math.ceil(winHeight)-winHeight;
+ renderFboWidth = winWidth*sampleCount[0];
+ renderFboHeight = winHeight*sampleCount[0];
+ targetFboWidth = (int)Math.ceil(renderFboWidth);
+ targetFboHeight = (int)Math.ceil(renderFboHeight);
if( DEBUG_FBO_2 ) {
System.err.printf("XXX.MinMax1 min [%.1f, %.1f -> %.3f, %.3f, %.3f]"+
- ", max [%.1f, %.1f -> %.3f, %.3f, %.3f], view[%d, %d] -> [%f x %f]%n",
+ ", max [%.1f, %.1f -> %.3f, %.3f, %.3f], view[%d, %d] -> win[%.3f, %.3f]: FBO f[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], msaa %d%n",
box.getMinX(), box.getMinY(), winPosSzMin[0], winPosSzMin[1], winPosSzMin[2],
box.getMaxX(), box.getMaxY(), winPosSzMax[0], winPosSzMax[1], winPosSzMax[2],
- view[2], view[3], winWidth, winHeight);
- System.err.printf("XXX.MinMax1 [%f x %f] * %d = %d x %d%n", winWidth, winHeight, sampleCount[0], targetFboWidth, targetFboHeight);
+ view[2], view[3],
+ winWidth, winHeight,
+ renderFboWidth, renderFboHeight, targetFboWidth, targetFboHeight,
+ diffWidth, diffHeight, sampleCount[0]);
}
}
final int deltaFboWidth = Math.abs(targetFboWidth-fboWidth);
@@ -237,11 +244,14 @@ public class VBORegion2PVBAAES2 extends GLRegion {
} else {
sampleCount[0] = (int)Math.floor(maxTexSize[0] / winHeight);
}
- targetFboWidth = Math.round(winWidth*sampleCount[0]);
- targetFboHeight= Math.round(winHeight*sampleCount[0]);
+ renderFboWidth = winWidth*sampleCount[0];
+ renderFboHeight = winHeight*sampleCount[0];
+ targetFboWidth = (int)Math.ceil(renderFboWidth);
+ targetFboHeight = (int)Math.ceil(renderFboHeight);
if( DEBUG_FBO_1 ) {
- System.err.printf("XXX.Rescale (MAX): %d * [%f x %f]: %d x %d%n",
- sampleCount[0], winWidth, winHeight, targetFboWidth, targetFboHeight);
+ System.err.printf("XXX.Rescale (MAX): win[%.3f, %.3f]: FBO f[%.3f, %.3f], i[%d x %d], msaa %d%n",
+ winWidth, winHeight,
+ renderFboWidth, renderFboHeight, targetFboWidth, targetFboHeight, sampleCount[0]);
}
if( sampleCount[0] <= 0 ) {
// Last way out!
@@ -249,20 +259,44 @@ public class VBORegion2PVBAAES2 extends GLRegion {
return;
}
}
- renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight);
+ verticeFboAttr.seal(false);
+ verticeFboAttr.rewind();
+ verticeFboAttr.putf(box.getMinX()); verticeFboAttr.putf(box.getMinY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMinX()); verticeFboAttr.putf(box.getMaxY()+diffHeight); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMaxX()+diffWidth); verticeFboAttr.putf(box.getMaxY()+diffHeight); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMaxX()+diffWidth); verticeFboAttr.putf(box.getMinY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.seal(true);
+ fboPMVMatrix.glLoadIdentity();
+ fboPMVMatrix.glOrthof(box.getMinX(), box.getMaxX()+diffWidth,
+ box.getMinY(), box.getMaxY()+diffHeight, -1, 1);
+ renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, sampleCount[0]);
}
// System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3));
- renderFBO(gl, rs, width, height);
+ renderFBO(gl, rs, width, height, sampleCount[0]);
}
}
+ private void setTexSize(final GL2ES2 gl, final ShaderState st, boolean firstPass, int sampleCount) {
+ if(null == mgl_TextureSize) {
+ mgl_TextureSize = new GLUniformData(UniformNames.gcu_TextureSize, 3, Buffers.newDirectFloatBuffer(3));
+ }
+ final FloatBuffer texSize = (FloatBuffer) mgl_TextureSize.getBuffer();
+ if( firstPass ) {
+ texSize.put(2, 0f);
+ } else {
+ texSize.put(0, fboWidth);
+ texSize.put(1, fboHeight);
+ texSize.put(2, sampleCount);
+ }
+ st.uniform(gl, mgl_TextureSize);
+ }
- private void renderFBO(final GL2ES2 gl, final RenderState rs, final int width, final int hight) {
+ private void renderFBO(final GL2ES2 gl, final RenderState rs, final int width, final int height, int sampleCount) {
final ShaderState st = rs.getShaderState();
- gl.glViewport(0, 0, width, hight);
+ gl.glViewport(0, 0, width, height);
st.uniform(gl, mgl_ActiveTexture);
gl.glActiveTexture(GL.GL_TEXTURE0 + mgl_ActiveTexture.intValue());
- setTexSize(gl, st);
+ setTexSize(gl, st, false, sampleCount);
fbo.use(gl, texA);
verticeFboAttr.enableBuffer(gl, true);
@@ -279,7 +313,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
// setback: gl.glActiveTexture(currentActiveTextureEngine[0]);
}
- private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int targetFboWidth, final int targetFboHeight) {
+ private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int targetFboWidth, final int targetFboHeight, int sampleCount) {
final ShaderState st = rs.getShaderState();
if( 0 >= targetFboWidth || 0 >= targetFboHeight ) {
@@ -291,7 +325,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
fboHeight = targetFboHeight;
fbo = new FBObject();
fbo.reset(gl, fboWidth, fboHeight);
- // FIXME: shall not use bilinear (GL_LINEAR), due to own VBAA. Seems result is smooth w/o it now!
+ // Shall not use bilinear (GL_LINEAR), due to own VBAA. Result is smooth w/o it now!
// texA = fbo.attachTexture2D(gl, 0, true, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
texA = fbo.attachTexture2D(gl, 0, true, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
@@ -309,6 +343,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
} else {
fbo.bind(gl);
}
+ setTexSize(gl, st, true, sampleCount);
//render texture
gl.glViewport(0, 0, fboWidth, fboHeight);
@@ -321,18 +356,6 @@ public class VBORegion2PVBAAES2 extends GLRegion {
st.uniform(gl, rs.getPMVMatrix()); // switch back to real PMV matrix
}
- private void setTexSize(final GL2ES2 gl, final ShaderState st) {
- // if( !gl.isGL3() ) {
- // GLSL < 1.30
- if(null == mgl_TextureSize) {
- mgl_TextureSize = new GLUniformData(UniformNames.gcu_TextureSize, 2, Buffers.newDirectFloatBuffer(2));
- }
- final FloatBuffer texSize = (FloatBuffer) mgl_TextureSize.getBuffer();
- texSize.put(0, fboWidth);
- texSize.put(1, fboHeight);
- st.uniform(gl, mgl_TextureSize);
- //}
- }
private void renderRegion(final GL2ES2 gl) {
verticeTxtAttr.enableBuffer(gl, true);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp
index 2248792cb..940e95071 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp
@@ -14,21 +14,26 @@
#include uniforms.glsl
#include varyings.glsl
+const vec3 zero3 = vec3(0);
+
void main (void)
{
+ vec3 c;
+ float alpha;
+
vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
- vec3 c = gcu_ColorStatic.rgb;
-
- float alpha = 0.0;
-
- if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) {
+
+ if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) {
+ // pass-1: Lines
+ c = gcu_ColorStatic.rgb;
alpha = gcu_Alpha;
- }
- else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) {
+ } else if ( gcv_TexCoord.x > 0.0 && ( rtex.y > 0.0 || rtex.x == 1.0 ) ) {
+ // pass-1: curves
rtex.y -= 0.1;
if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
// discard; // freezes NV tegra2 compiler
+ c = zero3;
alpha = 0.0;
} else {
rtex.y = max(rtex.y, 0.0);
@@ -45,9 +50,12 @@ void main (void)
float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0);
vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2.0*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2.0*rtex.x))/gd));
- float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
- alpha = gcu_Alpha * a;
+ c = gcu_ColorStatic.rgb;
+ alpha = gcu_Alpha * clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
}
+ } else {
+ c = zero3;
+ alpha = 0.0;
}
mgl_FragColor = vec4(c, alpha);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp
index 94e551832..2175c1a31 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp
@@ -14,29 +14,35 @@
#include uniforms.glsl
#include varyings.glsl
+const vec3 zero3 = vec3(0);
+
void main (void)
{
- // CDTriangulator2D.extractBoundaryTriangles(..):
- // 0 > gcv_TexCoord.y : hole or holeLike
- // 0 < gcv_TexCoord.y : !hole (outer)
- //
- // 0 == gcv_TexCoord.x : vertex-0 of triangle
- // 0.5 == gcv_TexCoord.x : vertex-1 of triangle
- // 1 == gcv_TexCoord.x : vertex-2 of triangle
- //
+ vec3 c;
+ float alpha;
+
+ /**
+ * CDTriangulator2D.extractBoundaryTriangles(..):
+ * 0 > gcv_TexCoord.y : hole or holeLike
+ * 0 < gcv_TexCoord.y : !hole (outer)
+ *
+ * 0 == gcv_TexCoord.x : vertex-0 of triangle
+ * 0.5 == gcv_TexCoord.x : vertex-1 of triangle
+ * 1 == gcv_TexCoord.x : vertex-2 of triangle
+ */
vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
- vec3 c = gcu_ColorStatic.rgb;
-
- float alpha = 0.0;
- if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) {
+ if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) {
+ // pass-1: Lines
+ c = gcu_ColorStatic.rgb;
alpha = gcu_Alpha;
- }
- else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) {
+ } else if ( gcv_TexCoord.x > 0.0 && ( rtex.y > 0.0 || rtex.x == 1.0 ) ) {
+ // pass-1: curves
rtex.y -= 0.1;
if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
// discard; // freezes NV tegra2 compiler
+ c = zero3;
alpha = 0.0;
} else {
rtex.y = max(rtex.y, 0.0);
@@ -47,10 +53,12 @@ void main (void)
vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x));
float position = rtex.y - (rtex.x * (1.0 - rtex.x));
- float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
- alpha = gcu_Alpha * a;
+ c = gcu_ColorStatic.rgb;
+ alpha = gcu_Alpha * clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
}
+ } else {
+ c = zero3;
+ alpha = 0.0;
}
-
mgl_FragColor = vec4(c, alpha);
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp
index a4c547939..733669e64 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp
@@ -15,55 +15,62 @@
#include uniforms.glsl
#include varyings.glsl
+const vec3 zero3 = vec3(0);
+
void main (void)
{
- vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
- vec3 c = gcu_ColorStatic.rgb;
-
- float alpha = 0.0;
+ vec3 c;
+ float alpha;
- if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) {
- alpha = gcu_Alpha;
- }
- else if((gcv_TexCoord.x >= 5.0)) {
- rtex -= 5.0;
- vec4 t = texture2D(gcu_TextureUnit, rtex);
-
+ if( 0 < gcu_TextureSize.z ) {
+ // Pass-2: Dump Texture
+ vec4 t = texture2D(gcu_TextureUnit, gcv_TexCoord);
#if 0
- if(t.w == 0.0) {
- discard; // discard freezes NV tegra2 compiler
+ if( 0.0 == t.a ) {
+ discard; // discard freezes NV tegra2 compiler
}
#endif
-
- c = t.xyz;
- alpha = gcu_Alpha * t.w;
- }
- ///////////////////////////////////////////////////////////
- else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) {
- rtex.y -= 0.1;
-
- if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
- // discard; // freezes NV tegra2 compiler
- alpha = 0.0;
- } else {
- rtex.y = max(rtex.y, 0.0);
- vec2 dtx = dFdx(rtex);
- vec2 dty = dFdy(rtex);
+ c = t.rgb;
+ alpha = gcu_Alpha * t.a;
+ } else {
+ // Pass-1
+ vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
+
+ if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) {
+ // pass-1: Lines
+ c = gcu_ColorStatic.rgb;
+ alpha = 1.0;
+ } else if ( gcv_TexCoord.x > 0.0 && (rtex.y > 0.0 || rtex.x == 1.0) ) {
+ // pass-1: curves
+ rtex.y -= 0.1;
- float w = gcu_Weight;
- float pd = ((2.0 - (2.0*w))*rtex.x*rtex.x) + 2.0*(w-1.0)*rtex.x + 1.0;
- float position = rtex.y - ((w*rtex.x*(1.0 - rtex.x))/pd);
+ if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
+ // discard; // freezes NV tegra2 compiler
+ c = zero3;
+ alpha = 0.0;
+ } else {
+ rtex.y = max(rtex.y, 0.0);
+
+ vec2 dtx = dFdx(rtex);
+ vec2 dty = dFdy(rtex);
+
+ float w = gcu_Weight;
+ float pd = ((2.0 - (2.0*w))*rtex.x*rtex.x) + 2.0*(w-1.0)*rtex.x + 1.0;
+ float position = rtex.y - ((w*rtex.x*(1.0 - rtex.x))/pd);
- float aph = 2.0 - 2.0*w;
-
- float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0);
- vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2.0*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2.0*rtex.x))/gd));
+ float aph = 2.0 - 2.0*w;
+
+ float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0);
+ vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2.0*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2.0*rtex.x))/gd));
- float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
- alpha = gcu_Alpha * a;
+ c = gcu_ColorStatic.rgb;
+ alpha = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
+ }
+ } else {
+ c = zero3;
+ alpha = 0.0;
}
}
-
mgl_FragColor = vec4(c, alpha);
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp
index 21cd9de71..2536e251b 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp
@@ -15,48 +15,74 @@
#include uniforms.glsl
#include varyings.glsl
+// #define PREALPHA 1
+
+const vec3 zero3 = vec3(0);
+
void main (void)
{
- vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
- vec3 c = gcu_ColorStatic.rgb;
-
- float alpha = 0.0;
+ vec3 c;
+ float alpha;
- if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) {
- alpha = gcu_Alpha;
- }
- else if((gcv_TexCoord.x >= 5.0)) {
- rtex -= 5.0;
- vec4 t = texture2D(gcu_TextureUnit, rtex);
-
+ if( 0 < gcu_TextureSize.z ) {
+ // Pass-2: Dump Texture
+ vec4 t = texture2D(gcu_TextureUnit, gcv_TexCoord);
#if 0
- if(t.w == 0.0) {
- discard; // discard freezes NV tegra2 compiler
+ if( 0.0 == t.a ) {
+ discard; // discard freezes NV tegra2 compiler
}
#endif
-
- c = t.xyz;
- alpha = gcu_Alpha * t.w;
- }
- else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) {
- rtex.y -= 0.1;
-
- if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
- // discard; // freezes NV tegra2 compiler
- alpha = 0.0;
- } else {
- rtex.y = max(rtex.y, 0.0);
- vec2 dtx = dFdx(rtex);
- vec2 dty = dFdy(rtex);
+ c = t.rgb;
+ #ifdef PREALPHA
+ // alpha = mix(0.0, gcu_Alpha, t.a); // t.a one of [ 0.0, 1.0 ]
+ // ^^ for = 0.0 == t.a ? 0.0 : gcu_Alpha;
+ // mix(x, y, a) := x * ( 1 - a ) + y * a
+ alpha = gcu_Alpha;
+ #else
+ alpha = gcu_Alpha * t.a;
+ #endif
+ } else {
+ // Pass-1
+ vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
+
+ if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) {
+ // pass-1: Lines
+ c = gcu_ColorStatic.rgb;
+ alpha = 1.0;
+ } else if ( gcv_TexCoord.x > 0.0 && (rtex.y > 0.0 || rtex.x == 1.0) ) {
+ // pass-1: curves
+ rtex.y -= 0.1;
- vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x));
- float position = rtex.y - (rtex.x * (1.0 - rtex.x));
+ if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
+ // discard; // freezes NV tegra2 compiler
+ c = zero3;
+ alpha = 0.0;
+ } else {
+ rtex.y = max(rtex.y, 0.0);
+
+ vec2 dtx = dFdx(rtex);
+ vec2 dty = dFdy(rtex);
+
+ vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x));
+ float position = rtex.y - (rtex.x * (1.0 - rtex.x));
- float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
- alpha = gcu_Alpha * a;
+ #ifdef PREALPHA
+ float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
+ c = gcu_ColorStatic.rgb * a;
+ alpha = mix(1.0, 0.0, step(a, 0.0));
+ // ^^ = 0.0 < a ? 1.0 : 0.0;
+ // step(e, x) := e > x ? 0.0 : 1.0
+ // mix(x, y, a) := x * ( 1 - a ) + y * a
+ #else
+ c = gcu_ColorStatic.rgb;
+ alpha = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
+ #endif
+ }
+ } else {
+ c = zero3;
+ alpha = 0.0;
}
}
-
mgl_FragColor = vec4(c, alpha);
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp
index c048254df..3b1b55c87 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp
@@ -15,79 +15,95 @@
#include uniforms.glsl
#include varyings.glsl
-const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025);
+const vec3 zero3 = vec3(0);
void main (void)
{
- vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
- vec3 c = gcu_ColorStatic.rgb;
+ vec3 c;
+ float alpha;
- float alpha = 0.0;
-
- if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) {
- alpha = gcu_Alpha;
- }
- else if((gcv_TexCoord.x >= 5.0)) {
- vec2 size = 1.0/gcu_TextureSize;
+ if( 0 < gcu_TextureSize.z ) {
+ // Pass-2: AA on Texture
+ // Note: gcv_TexCoord is in center of sample pixels.
- rtex -= 5.0;
- vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18;
+ float sampleCount = gcu_TextureSize.z;
+ vec2 psize = 1.0 / gcu_TextureSize.xy; // pixel size
- t += texture2D(gcu_TextureUnit, rtex + size*(vec2(1, 0)))*tex_weights.x;
- t += texture2D(gcu_TextureUnit, rtex - size*(vec2(1, 0)))*tex_weights.x;
- t += texture2D(gcu_TextureUnit, rtex + size*(vec2(0, 1)))*tex_weights.x;
- t += texture2D(gcu_TextureUnit, rtex - size*(vec2(0, 1)))*tex_weights.x;
-
- t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(1, 0)))*tex_weights.y;
- t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(1, 0)))*tex_weights.y;
- t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(0, 1)))*tex_weights.y;
- t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(0, 1)))*tex_weights.y;
-
- t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(1, 0)))*tex_weights.z;
- t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(1, 0)))*tex_weights.z;
- t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(0, 1)))*tex_weights.z;
- t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(0, 1)))*tex_weights.z;
-
- t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(1, 0)))*tex_weights.w;
- t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(1, 0)))*tex_weights.w;
- t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(0, 1)))*tex_weights.w;
- t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(0, 1)))*tex_weights.w;
-
+ float sample_weight = 1 / ( 2 * sampleCount );
+ // float sample_weight = 1 / ( 2 * sampleCount + 1 );
+
+ vec4 t = vec4(0);
+ // vec4 t = texture2D(gcu_TextureUnit, gcv_TexCoord)* sample_weight; // center: +1
+
+ // SampleCount 2
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-0.5, -0.5)))*sample_weight; // NW
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-0.5, 0.5)))*sample_weight; // SW
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 0.5, 0.5)))*sample_weight; // SE
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 0.5, -0.5)))*sample_weight; // NE
+ if( sampleCount > 2 ) {
+ // SampleCount 4
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-1.5, -1.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-1.5, 1.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 1.5, 1.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 1.5, -1.5)))*sample_weight;
+ if( sampleCount > 4 ) {
+ // SampleCount 8
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-2.5, -2.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-2.5, 2.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 2.5, 2.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 2.5, -2.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-3.5, -3.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-3.5, 3.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 3.5, 3.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 3.5, -3.5)))*sample_weight;
+ }
+ }
#if 0
- if(t.w == 0.0) {
+ if(t.w == 0.0){
discard; // discard freezes NV tegra2 compiler
}
#endif
- c = t.xyz;
- alpha = gcu_Alpha * t.w;
- }
- ///////////////////////////////////////////////////////////
- else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) {
- rtex.y -= 0.1;
+ c = t.rgb;
+ alpha = gcu_Alpha * t.a;
+ } else {
+ // pass-1
+ vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
+
+ if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) {
+ // pass-1: Lines
+ c = gcu_ColorStatic.rgb;
+ alpha = 1.0;
+ } else if ( gcv_TexCoord.x > 0.0 && (rtex.y > 0.0 || rtex.x == 1.0) ) {
+ // pass-1: curves
+ rtex.y -= 0.1;
- if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
- // discard; // freezes NV tegra2 compiler
- alpha = 0.0;
- } else {
- rtex.y = max(rtex.y, 0.0);
+ if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
+ // discard; // freezes NV tegra2 compiler
+ c = zero3;
+ alpha = 0.0;
+ } else {
+ rtex.y = max(rtex.y, 0.0);
- vec2 dtx = dFdx(rtex);
- vec2 dty = dFdy(rtex);
-
- float w = gcu_Weight;
- float pd = ((2.0 - (2.0*w))*rtex.x*rtex.x) + 2.0*(w-1.0)*rtex.x + 1.0;
- float position = rtex.y - ((w*rtex.x*(1.0 - rtex.x))/pd);
+ vec2 dtx = dFdx(rtex);
+ vec2 dty = dFdy(rtex);
+
+ float w = gcu_Weight;
+ float pd = ((2.0 - (2.0*w))*rtex.x*rtex.x) + 2.0*(w-1.0)*rtex.x + 1.0;
+ float position = rtex.y - ((w*rtex.x*(1.0 - rtex.x))/pd);
- float aph = 2.0 - 2.0*w;
-
- float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0);
- vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2.0*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2.0*rtex.x))/gd));
+ float aph = 2.0 - 2.0*w;
+
+ float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0);
+ vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2.0*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2.0*rtex.x))/gd));
- float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
- alpha = gcu_Alpha * a;
+ c = gcu_ColorStatic.rgb;
+ alpha = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
+ }
+ } else {
+ c = zero3;
+ alpha = 0.0;
}
}
-
mgl_FragColor = vec4(c, alpha);
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp
index 0e590a102..8237fa55b 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp
@@ -15,72 +15,89 @@
#include uniforms.glsl
#include varyings.glsl
-const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025);
+const vec3 zero3 = vec3(0);
void main (void)
{
- vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
- vec3 c = gcu_ColorStatic.rgb;
+ vec3 c;
+ float alpha;
- float alpha = 0.0;
-
- if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) {
- alpha = gcu_Alpha;
- }
- else if((gcv_TexCoord.x >= 5.0)) {
- vec2 size = 1.0/gcu_TextureSize;
+ if( 0 < gcu_TextureSize.z ) {
+ // Pass-2: AA on Texture
+ // Note: gcv_TexCoord is in center of sample pixels.
- rtex -= 5.0;
- vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18;
+ float sampleCount = gcu_TextureSize.z;
+ vec2 psize = 1.0 / gcu_TextureSize.xy; // pixel size
- t += texture2D(gcu_TextureUnit, rtex + size*(vec2(1, 0)))*tex_weights.x;
- t += texture2D(gcu_TextureUnit, rtex - size*(vec2(1, 0)))*tex_weights.x;
- t += texture2D(gcu_TextureUnit, rtex + size*(vec2(0, 1)))*tex_weights.x;
- t += texture2D(gcu_TextureUnit, rtex - size*(vec2(0, 1)))*tex_weights.x;
-
- t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(1, 0)))*tex_weights.y;
- t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(1, 0)))*tex_weights.y;
- t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(0, 1)))*tex_weights.y;
- t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(0, 1)))*tex_weights.y;
-
- t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(1, 0)))*tex_weights.z;
- t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(1, 0)))*tex_weights.z;
- t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(0, 1)))*tex_weights.z;
- t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(0, 1)))*tex_weights.z;
-
- t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(1, 0)))*tex_weights.w;
- t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(1, 0)))*tex_weights.w;
- t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(0, 1)))*tex_weights.w;
- t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(0, 1)))*tex_weights.w;
-
+ float sample_weight = 1 / ( 2 * sampleCount );
+ // float sample_weight = 1 / ( 2 * sampleCount + 1 );
+
+ vec4 t = vec4(0);
+ // vec4 t = texture2D(gcu_TextureUnit, gcv_TexCoord)* sample_weight; // center: +1
+
+ // SampleCount 2
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-0.5, -0.5)))*sample_weight; // NW
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-0.5, 0.5)))*sample_weight; // SW
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 0.5, 0.5)))*sample_weight; // SE
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 0.5, -0.5)))*sample_weight; // NE
+ if( sampleCount > 2 ) {
+ // SampleCount 4
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-1.5, -1.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-1.5, 1.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 1.5, 1.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 1.5, -1.5)))*sample_weight;
+ if( sampleCount > 4 ) {
+ // SampleCount 8
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-2.5, -2.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-2.5, 2.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 2.5, 2.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 2.5, -2.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-3.5, -3.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-3.5, 3.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 3.5, 3.5)))*sample_weight;
+ t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 3.5, -3.5)))*sample_weight;
+ }
+ }
#if 0
if(t.w == 0.0){
discard; // discard freezes NV tegra2 compiler
}
#endif
- c = t.xyz;
- alpha = gcu_Alpha * t.w;
- }
- else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) {
- rtex.y -= 0.1;
-
- if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
- // discard; // freezes NV tegra2 compiler
- alpha = 0.0;
- } else {
- rtex.y = max(rtex.y, 0.0);
-
- vec2 dtx = dFdx(rtex);
- vec2 dty = dFdy(rtex);
+ c = t.rgb;
+ alpha = gcu_Alpha * t.a;
+ } else {
+ // pass-1
+ vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
+
+ if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) {
+ // pass-1: Lines
+ c = gcu_ColorStatic.rgb;
+ alpha = 1.0;
+ } else if ( gcv_TexCoord.x > 0.0 && (rtex.y > 0.0 || rtex.x == 1.0) ) {
+ // pass-1: curves
+ rtex.y -= 0.1;
- vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x));
- float position = rtex.y - (rtex.x * (1.0 - rtex.x));
+ if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
+ // discard; // freezes NV tegra2 compiler
+ c = zero3;
+ alpha = 0.0;
+ } else {
+ rtex.y = max(rtex.y, 0.0);
- float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
- alpha = gcu_Alpha * a;
+ vec2 dtx = dFdx(rtex);
+ vec2 dty = dFdy(rtex);
+
+ vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x));
+ float position = rtex.y - (rtex.x * (1.0 - rtex.x));
+
+ c = gcu_ColorStatic.rgb;
+ alpha = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
+ }
+ } else {
+ c = zero3;
+ alpha = 0.0;
}
}
-
mgl_FragColor = vec4(c, alpha);
}
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 5bbd5de14..92e78d5de 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl
@@ -6,11 +6,10 @@ uniform mat4 gcu_PMVMatrix[3]; // P, Mv, and Mvi
uniform vec3 gcu_ColorStatic;
uniform float gcu_Alpha;
uniform float gcu_Weight;
-uniform sampler2D gcu_TextureUnit;
+uniform sampler2D gcu_TextureUnit;
-// #if __VERSION__ < 130
-uniform vec2 gcu_TextureSize;
-// #endif
+/** 3rd component: 0: pass-1, >0: pass-2, sampleCount */
+uniform vec3 gcu_TextureSize;
// const int MAX_TEXTURE_UNITS = 8; // <= gl_MaxTextureImageUnits
// const int MAX_LIGHTS = 8;