summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/curve/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-04-08 21:35:34 +0200
committerSven Gothel <[email protected]>2011-04-08 21:35:34 +0200
commit324b85b0cc688f85a91e84b0b6d6a0378a79bea3 (patch)
treea5acbe1630d879e80ec66c6c3a72623431c57632 /src/jogl/classes/jogamp/graph/curve/opengl
parente104e42ba9ecda8c4094bf4b183105a6ab719da5 (diff)
Fix TAB: Replace all TAB with 4 spaces
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve/opengl')
-rwxr-xr-xsrc/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java56
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java210
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java368
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java252
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp148
5 files changed, 517 insertions, 517 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java
index 34b46a8b5..683a72d96 100755
--- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java
@@ -43,10 +43,10 @@ import com.jogamp.opengl.util.glsl.ShaderState;
public class RegionRendererImpl01 extends RegionRenderer {
- /**Sharpness is equivalent to the value of t value of texture coord
- * on the off-curve vertex. The high value of sharpness will
- * result in high curvature.
- */
+ /**Sharpness is equivalent to the value of t value of texture coord
+ * on the off-curve vertex. The high value of sharpness will
+ * result in high curvature.
+ */
private GLUniformData mgl_sharpness = new GLUniformData("p1y", 0.5f);
GLUniformData mgl_alpha = new GLUniformData("g_alpha", 1.0f);
private GLUniformData mgl_color = new GLUniformData("g_color", 3, FloatBuffer.allocate(3));
@@ -174,35 +174,35 @@ public class RegionRendererImpl01 extends RegionRenderer {
}
}
-
- @Override
+
+ @Override
public void renderOutlineShape(GL2ES2 gl, OutlineShape outlineShape, float[] position, int texSize) {
- if(!isInitialized()){
- throw new GLException("RegionRendererImpl01: not initialized!");
- }
- int hashCode = getHashCode(outlineShape);
- Region region = regions.get(hashCode);
-
- if(null == region) {
- region = createRegion(gl, outlineShape, mgl_sharpness.floatValue());
- regions.put(hashCode, region);
- }
- region.render(pmvMatrix, vp_width, vp_height, texSize);
- }
-
- @Override
+ if(!isInitialized()){
+ throw new GLException("RegionRendererImpl01: not initialized!");
+ }
+ int hashCode = getHashCode(outlineShape);
+ Region region = regions.get(hashCode);
+
+ if(null == region) {
+ region = createRegion(gl, outlineShape, mgl_sharpness.floatValue());
+ regions.put(hashCode, region);
+ }
+ region.render(pmvMatrix, vp_width, vp_height, texSize);
+ }
+
+ @Override
public void renderOutlineShapes(GL2ES2 gl, OutlineShape[] outlineShapes, float[] position, int texSize) {
if(!isInitialized()){
throw new GLException("RegionRendererImpl01: not initialized!");
}
-
- int hashCode = getHashCode(outlineShapes);
- Region region = regions.get(hashCode);
-
- if(null == region) {
+
+ int hashCode = getHashCode(outlineShapes);
+ Region region = regions.get(hashCode);
+
+ if(null == region) {
region = createRegion(gl, outlineShapes, mgl_sharpness.floatValue());
- regions.put(hashCode, region);
- }
+ regions.put(hashCode, region);
+ }
region.render(pmvMatrix, vp_width, vp_height, texSize);
- }
+ }
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java
index 69a8e470b..bc94ab180 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java
@@ -44,39 +44,39 @@ import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
public class TextRendererImpl01 extends TextRenderer {
- /**Sharpness is equivalent to the value of t value of texture coord
- * on the off-curve vertex. The high value of sharpness will
- * result in high curvature.
- */
+ /**Sharpness is equivalent to the value of t value of texture coord
+ * on the off-curve vertex. The high value of sharpness will
+ * result in high curvature.
+ */
private GLUniformData mgl_sharpness = new GLUniformData("p1y", 0.5f);
GLUniformData mgl_alpha = new GLUniformData("g_alpha", 1.0f);
private GLUniformData mgl_color = new GLUniformData("g_color", 3, FloatBuffer.allocate(3));
private GLUniformData mgl_strength = new GLUniformData("a_strength", 1.8f);
-
- public TextRendererImpl01(Vertex.Factory<? extends Vertex> factory, int type) {
- super(factory, type);
- }
+
+ public TextRendererImpl01(Vertex.Factory<? extends Vertex> factory, int type) {
+ super(factory, type);
+ }
- @Override
+ @Override
protected boolean initImpl(GL2ES2 gl){
- boolean VBOsupported = gl.isFunctionAvailable("glGenBuffers") &&
- gl.isFunctionAvailable("glBindBuffer") &&
- gl.isFunctionAvailable("glBufferData") &&
- gl.isFunctionAvailable("glDrawElements") &&
- gl.isFunctionAvailable("glVertexAttribPointer") &&
- gl.isFunctionAvailable("glDeleteBuffers");
-
- if(DEBUG) {
- System.err.println("TextRendererImpl01: VBO Supported = " + VBOsupported);
- }
-
- if(!VBOsupported){
- return false;
- }
-
- gl.glEnable(GL2ES2.GL_BLEND);
- gl.glBlendFunc(GL2ES2.GL_SRC_ALPHA, GL2ES2.GL_ONE_MINUS_SRC_ALPHA);
-
+ boolean VBOsupported = gl.isFunctionAvailable("glGenBuffers") &&
+ gl.isFunctionAvailable("glBindBuffer") &&
+ gl.isFunctionAvailable("glBufferData") &&
+ gl.isFunctionAvailable("glDrawElements") &&
+ gl.isFunctionAvailable("glVertexAttribPointer") &&
+ gl.isFunctionAvailable("glDeleteBuffers");
+
+ if(DEBUG) {
+ System.err.println("TextRendererImpl01: VBO Supported = " + VBOsupported);
+ }
+
+ if(!VBOsupported){
+ return false;
+ }
+
+ gl.glEnable(GL2ES2.GL_BLEND);
+ gl.glBlendFunc(GL2ES2.GL_SRC_ALPHA, GL2ES2.GL_ONE_MINUS_SRC_ALPHA);
+
ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, TextRendererImpl01.class,
"shader", "shader/bin", "curverenderer01");
ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, TextRendererImpl01.class,
@@ -95,62 +95,62 @@ public class TextRendererImpl01 extends TextRenderer {
}
st.attachShaderProgram(gl, sp);
-
- st.glUseProgram(gl, true);
+
+ st.glUseProgram(gl, true);
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmvMatrix.glLoadIdentity();
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmvMatrix.glLoadIdentity();
-
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmvMatrix.glLoadIdentity();
- resetModelview(null);
-
- mgl_PMVMatrix = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
- if(!st.glUniform(gl, mgl_PMVMatrix)) {
- if(DEBUG){
- System.err.println("Error setting PMVMatrix in shader: "+st);
- }
- return false;
- }
-
- if(!st.glUniform(gl, mgl_sharpness)) {
- if(DEBUG){
- System.err.println("Error setting sharpness in shader: "+st);
- }
- return false;
- }
-
- if(!st.glUniform(gl, mgl_alpha)) {
- if(DEBUG){
- System.err.println("Error setting global alpha in shader: "+st);
- }
- return false;
- }
-
- if(!st.glUniform(gl, mgl_color)) {
- if(DEBUG){
- System.err.println("Error setting global color in shader: "+st);
- }
- return false;
- }
-
- if(!st.glUniform(gl, mgl_strength)) {
- System.err.println("Error setting antialias strength in shader: "+st);
- }
-
- if(DEBUG) {
- System.err.println("TextRendererImpl01 initialized: " + Thread.currentThread()+" "+st);
- }
- return true;
- }
-
- @Override
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ resetModelview(null);
+
+ mgl_PMVMatrix = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ if(!st.glUniform(gl, mgl_PMVMatrix)) {
+ if(DEBUG){
+ System.err.println("Error setting PMVMatrix in shader: "+st);
+ }
+ return false;
+ }
+
+ if(!st.glUniform(gl, mgl_sharpness)) {
+ if(DEBUG){
+ System.err.println("Error setting sharpness in shader: "+st);
+ }
+ return false;
+ }
+
+ if(!st.glUniform(gl, mgl_alpha)) {
+ if(DEBUG){
+ System.err.println("Error setting global alpha in shader: "+st);
+ }
+ return false;
+ }
+
+ if(!st.glUniform(gl, mgl_color)) {
+ if(DEBUG){
+ System.err.println("Error setting global color in shader: "+st);
+ }
+ return false;
+ }
+
+ if(!st.glUniform(gl, mgl_strength)) {
+ System.err.println("Error setting antialias strength in shader: "+st);
+ }
+
+ if(DEBUG) {
+ System.err.println("TextRendererImpl01 initialized: " + Thread.currentThread()+" "+st);
+ }
+ return true;
+ }
+
+ @Override
protected void disposeImpl(GL2ES2 gl) {
- super.disposeImpl(gl);
- }
-
+ super.disposeImpl(gl);
+ }
+
@Override
public float getAlpha() {
return mgl_alpha.floatValue();
@@ -163,30 +163,30 @@ public class TextRendererImpl01 extends TextRenderer {
st.glUniform(gl, mgl_alpha);
}
}
-
- @Override
+
+ @Override
public void setColor(GL2ES2 gl, float r, float g, float b){
- FloatBuffer fb = (FloatBuffer) mgl_color.getBuffer();
- fb.put(0, r);
- fb.put(1, r);
- fb.put(2, r);
- if(null != gl && st.inUse()) {
- st.glUniform(gl, mgl_color);
- }
- }
-
- @Override
+ FloatBuffer fb = (FloatBuffer) mgl_color.getBuffer();
+ fb.put(0, r);
+ fb.put(1, r);
+ fb.put(2, r);
+ if(null != gl && st.inUse()) {
+ st.glUniform(gl, mgl_color);
+ }
+ }
+
+ @Override
public void renderString3D(GL2ES2 gl, Font font, String str, float[] position, int fontSize, int texSize) {
- if(!isInitialized()){
- throw new GLException("TextRendererImpl01: not initialized!");
- }
- GlyphString glyphString = getCachedGlyphString(font, str, fontSize);
- if(null == glyphString) {
- glyphString = createString(gl, font, fontSize, str, mgl_sharpness.floatValue());
- addCachedGlyphString(font, str, fontSize, glyphString);
- }
-
- glyphString.renderString3D(pmvMatrix, vp_width, vp_height, texSize);
- }
-
+ if(!isInitialized()){
+ throw new GLException("TextRendererImpl01: not initialized!");
+ }
+ GlyphString glyphString = getCachedGlyphString(font, str, fontSize);
+ if(null == glyphString) {
+ glyphString = createString(gl, font, fontSize, str, mgl_sharpness.floatValue());
+ addCachedGlyphString(font, str, fontSize, glyphString);
+ }
+
+ glyphString.renderString3D(pmvMatrix, vp_width, vp_height, texSize);
+ }
+
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
index 81d9d1858..05814965e 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
@@ -49,35 +49,35 @@ import com.jogamp.opengl.util.glsl.ShaderState;
public class VBORegion2PES2 implements Region {
private int numVertices = 0;
- private ArrayList<Triangle> triangles = new ArrayList<Triangle>();
- private ArrayList<Vertex> vertices = new ArrayList<Vertex>();
- private GLArrayDataServer verticeTxtAttr = null;
- private GLArrayDataServer texCoordTxtAttr = null;
- private GLArrayDataServer indicesTxt = null;
+ private ArrayList<Triangle> triangles = new ArrayList<Triangle>();
+ private ArrayList<Vertex> vertices = new ArrayList<Vertex>();
+ private GLArrayDataServer verticeTxtAttr = null;
+ private GLArrayDataServer texCoordTxtAttr = null;
+ private GLArrayDataServer indicesTxt = null;
private GLArrayDataServer verticeFboAttr = null;
private GLArrayDataServer texCoordFboAttr = null;
private GLArrayDataServer indicesFbo = null;
-
- private GLContext context;
-
- private boolean flipped = false;
-
- private boolean dirty = false;
-
- private AABBox box = null;
- private FBObject fbo = null;
+
+ private GLContext context;
+
+ private boolean flipped = false;
+
+ private boolean dirty = false;
+
+ private AABBox box = null;
+ private FBObject fbo = null;
- private int tex_width_c = 0;
- private int tex_height_c = 0;
-
- private ShaderState st;
-
- public VBORegion2PES2(GLContext context, ShaderState st){
- this.context =context;
- this.st = st;
-
- GL2ES2 gl = context.getGL().getGL2ES2();
-
+ private int tex_width_c = 0;
+ private int tex_height_c = 0;
+
+ private ShaderState st;
+
+ public VBORegion2PES2(GLContext context, ShaderState st){
+ this.context =context;
+ this.st = st;
+
+ GL2ES2 gl = context.getGL().getGL2ES2();
+
indicesFbo = GLArrayDataServer.createGLSL(gl, null, 3, GL2ES2.GL_SHORT, false,
2, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
indicesFbo.puts((short) 0); indicesFbo.puts((short) 1); indicesFbo.puts((short) 3);
@@ -108,132 +108,132 @@ public class VBORegion2PES2 implements Region {
if(DEBUG) {
System.err.println("VBORegion2PES2 Create: " + this);
}
- }
-
- public void update(){
- GL2ES2 gl = context.getGL().getGL2ES2();
-
+ }
+
+ public void update(){
+ GL2ES2 gl = context.getGL().getGL2ES2();
+
destroyTxtAttr(gl);
box = new AABBox();
indicesTxt = GLArrayDataServer.createGLSL(gl, null, 3, GL2ES2.GL_SHORT, false,
triangles.size(), GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
- for(Triangle t:triangles){
- if(t.getVertices()[0].getId() == Integer.MAX_VALUE){
- t.getVertices()[0].setId(numVertices++);
- t.getVertices()[1].setId(numVertices++);
- t.getVertices()[2].setId(numVertices++);
-
- vertices.add(t.getVertices()[0]);
- vertices.add(t.getVertices()[1]);
- vertices.add(t.getVertices()[2]);
-
- indicesTxt.puts((short) t.getVertices()[0].getId());
- indicesTxt.puts((short) t.getVertices()[1].getId());
- indicesTxt.puts((short) t.getVertices()[2].getId());
- }
- else{
- Vertex v1 = t.getVertices()[0];
- Vertex v2 = t.getVertices()[1];
- Vertex v3 = t.getVertices()[2];
-
- indicesTxt.puts((short) v1.getId());
- indicesTxt.puts((short) v2.getId());
- indicesTxt.puts((short) v3.getId());
- }
- }
+ for(Triangle t:triangles){
+ if(t.getVertices()[0].getId() == Integer.MAX_VALUE){
+ t.getVertices()[0].setId(numVertices++);
+ t.getVertices()[1].setId(numVertices++);
+ t.getVertices()[2].setId(numVertices++);
+
+ vertices.add(t.getVertices()[0]);
+ vertices.add(t.getVertices()[1]);
+ vertices.add(t.getVertices()[2]);
+
+ indicesTxt.puts((short) t.getVertices()[0].getId());
+ indicesTxt.puts((short) t.getVertices()[1].getId());
+ indicesTxt.puts((short) t.getVertices()[2].getId());
+ }
+ else{
+ Vertex v1 = t.getVertices()[0];
+ Vertex v2 = t.getVertices()[1];
+ Vertex v3 = t.getVertices()[2];
+
+ indicesTxt.puts((short) v1.getId());
+ indicesTxt.puts((short) v2.getId());
+ indicesTxt.puts((short) v3.getId());
+ }
+ }
indicesTxt.seal(gl, true);
verticeTxtAttr = GLArrayDataServer.createGLSL(gl, Region.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, false,
vertices.size(), GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
verticeTxtAttr.setLocation(Region.VERTEX_ATTR_IDX);
- for(Vertex v:vertices){
- verticeTxtAttr.putf(v.getX());
- if(flipped){
- verticeTxtAttr.putf(-1*v.getY());
- } else {
- verticeTxtAttr.putf(v.getY());
- }
- verticeTxtAttr.putf(v.getZ());
- if(flipped){
- box.resize(v.getX(), -1*v.getY(), v.getZ());
- } else {
- box.resize(v.getX(), v.getY(), v.getZ());
- }
- }
+ for(Vertex v:vertices){
+ verticeTxtAttr.putf(v.getX());
+ if(flipped){
+ verticeTxtAttr.putf(-1*v.getY());
+ } else {
+ verticeTxtAttr.putf(v.getY());
+ }
+ verticeTxtAttr.putf(v.getZ());
+ if(flipped){
+ box.resize(v.getX(), -1*v.getY(), v.getZ());
+ } else {
+ box.resize(v.getX(), v.getY(), v.getZ());
+ }
+ }
verticeTxtAttr.seal(gl, true);
-
+
texCoordTxtAttr = GLArrayDataServer.createGLSL(gl, Region.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, false,
vertices.size(), GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
texCoordTxtAttr.setLocation(Region.TEXCOORD_ATTR_IDX);
- for(Vertex v:vertices){
- float[] tex = v.getTexCoord();
- texCoordTxtAttr.putf(tex[0]);
- texCoordTxtAttr.putf(tex[1]);
- }
+ for(Vertex v:vertices){
+ float[] tex = v.getTexCoord();
+ texCoordTxtAttr.putf(tex[0]);
+ texCoordTxtAttr.putf(tex[1]);
+ }
texCoordTxtAttr.seal(gl, true);
// leave the buffers enabled for subsequent render call
- dirty = false;
- }
-
- public void render(PMVMatrix matrix, int vp_width, int vp_height, int width){
+ dirty = false;
+ }
+
+ public void render(PMVMatrix matrix, int vp_width, int vp_height, int width){
GL2ES2 gl = context.getGL().getGL2ES2();
- if(null == matrix || vp_width <=0 || vp_height <= 0 || width <= 0){
- renderRegion(gl);
- } else {
- if(width != tex_width_c){
+ if(null == matrix || vp_width <=0 || vp_height <= 0 || width <= 0){
+ renderRegion(gl);
+ } else {
+ if(width != tex_width_c){
renderRegion2FBO(gl, matrix, width);
setupBBox2FboAttr(gl);
- }
-// System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3));
- renderFBO(gl, matrix, vp_width, vp_height);
- }
- }
-
- private void renderFBO(GL2ES2 gl, PMVMatrix matrix, int width, int hight) {
- gl.glViewport(0, 0, width, hight);
- if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, matrix.glGetPMvMatrixf()))){
- System.out.println("Cnt set tex based mat");
- }
- gl.glEnable(GL2ES2.GL_TEXTURE_2D);
- gl.glActiveTexture(GL2ES2.GL_TEXTURE0);
- fbo.use(gl);
-
- st.glUniform(gl, new GLUniformData("texture", fbo.getTextureName()));
- int loc = gl.glGetUniformLocation(st.shaderProgram().program(), "texture");
- gl.glUniform1i(loc, 0);
-
-
+ }
+// System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3));
+ renderFBO(gl, matrix, vp_width, vp_height);
+ }
+ }
+
+ private void renderFBO(GL2ES2 gl, PMVMatrix matrix, int width, int hight) {
+ gl.glViewport(0, 0, width, hight);
+ if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, matrix.glGetPMvMatrixf()))){
+ System.out.println("Cnt set tex based mat");
+ }
+ gl.glEnable(GL2ES2.GL_TEXTURE_2D);
+ gl.glActiveTexture(GL2ES2.GL_TEXTURE0);
+ fbo.use(gl);
+
+ st.glUniform(gl, new GLUniformData("texture", fbo.getTextureName()));
+ int loc = gl.glGetUniformLocation(st.shaderProgram().program(), "texture");
+ gl.glUniform1i(loc, 0);
+
+
verticeFboAttr.enableBuffer(gl, true);
texCoordFboAttr.enableBuffer(gl, true);
indicesFbo.enableBuffer(gl, true);
gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesFbo.getElementNumber() * indicesFbo.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
-
+
verticeFboAttr.enableBuffer(gl, false);
texCoordFboAttr.enableBuffer(gl, false);
indicesFbo.enableBuffer(gl, false);
- }
-
- private void setupBBox2FboAttr(GL2ES2 gl){
+ }
+
+ private void setupBBox2FboAttr(GL2ES2 gl){
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.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.seal(gl, true);
- }
-
- private void renderRegion2FBO(GL2ES2 gl, PMVMatrix m, int tex_width){
- tex_width_c = tex_width;
- tex_height_c = (int)(tex_width_c*box.getHeight()/box.getWidth());
-
+ }
+
+ private void renderRegion2FBO(GL2ES2 gl, PMVMatrix m, int tex_width){
+ tex_width_c = tex_width;
+ tex_height_c = (int)(tex_width_c*box.getHeight()/box.getWidth());
+
// System.out.println("FBO Size: "+tex_width+" -> "+tex_height_c+"x"+tex_width_c);
// System.out.println("FBO Scale: " + m.glGetMatrixf().get(0) +" " + m.glGetMatrixf().get(5));
@@ -245,79 +245,79 @@ public class VBORegion2PES2 implements Region {
if(null == fbo) {
fbo = new FBObject(tex_width_c, tex_height_c);
// FIXME: shall not use bilinear, due to own AA ? However, w/o bilinear result is not smooth
- fbo.init(gl, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
- // fbo.init(gl, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
- fbo.attachDepthBuffer(gl, GL.GL_DEPTH_COMPONENT16); // FIXME: or shall we use 24 or 32 bit depth ?
+ fbo.init(gl, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
+ // fbo.init(gl, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
+ fbo.attachDepthBuffer(gl, GL.GL_DEPTH_COMPONENT16); // FIXME: or shall we use 24 or 32 bit depth ?
} else {
fbo.bind(gl);
}
-
- //render texture
- PMVMatrix tex_matrix = new PMVMatrix();
- gl.glViewport(0, 0, tex_width_c, tex_height_c);
- tex_matrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- tex_matrix.glLoadIdentity();
- tex_matrix.glOrthof(box.getLow()[0], box.getHigh()[0], box.getLow()[1], box.getHigh()[1], -1, 1);
-
- if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, tex_matrix.glGetPMvMatrixf()))){
- System.out.println("Cnt set tex based mat");
- }
-
- gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT);
- renderRegion(gl);
+
+ //render texture
+ PMVMatrix tex_matrix = new PMVMatrix();
+ gl.glViewport(0, 0, tex_width_c, tex_height_c);
+ tex_matrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ tex_matrix.glLoadIdentity();
+ tex_matrix.glOrthof(box.getLow()[0], box.getHigh()[0], box.getLow()[1], box.getHigh()[1], -1, 1);
+
+ if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, tex_matrix.glGetPMvMatrixf()))){
+ System.out.println("Cnt set tex based mat");
+ }
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT);
+ renderRegion(gl);
- fbo.unbind(gl);
- }
-
- private void renderRegion(GL2ES2 gl) {
+ fbo.unbind(gl);
+ }
+
+ private void renderRegion(GL2ES2 gl) {
verticeTxtAttr.enableBuffer(gl, true);
texCoordTxtAttr.enableBuffer(gl, true);
indicesTxt.enableBuffer(gl, true);
-
- gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesTxt.getElementNumber() * indicesTxt.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
-
+
+ gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesTxt.getElementNumber() * indicesTxt.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
+
verticeTxtAttr.enableBuffer(gl, false);
texCoordTxtAttr.enableBuffer(gl, false);
indicesTxt.enableBuffer(gl, false);
- }
-
- public void addTriangles(ArrayList<Triangle> tris) {
- triangles.addAll(tris);
- dirty = true;
- }
-
- public int getNumVertices(){
- return numVertices;
- }
-
- public void addVertices(ArrayList<Vertex> verts){
- vertices.addAll(verts);
- numVertices = vertices.size();
- dirty = true;
- }
-
- public boolean isDirty(){
- return dirty;
- }
-
- public void destroy() {
- if(DEBUG) {
- System.err.println("VBORegion2PES2 Destroy: " + this);
- }
- GL2ES2 gl = context.getGL().getGL2ES2();
- destroyFbo(gl);
+ }
+
+ public void addTriangles(ArrayList<Triangle> tris) {
+ triangles.addAll(tris);
+ dirty = true;
+ }
+
+ public int getNumVertices(){
+ return numVertices;
+ }
+
+ public void addVertices(ArrayList<Vertex> verts){
+ vertices.addAll(verts);
+ numVertices = vertices.size();
+ dirty = true;
+ }
+
+ public boolean isDirty(){
+ return dirty;
+ }
+
+ public void destroy() {
+ if(DEBUG) {
+ System.err.println("VBORegion2PES2 Destroy: " + this);
+ }
+ GL2ES2 gl = context.getGL().getGL2ES2();
+ destroyFbo(gl);
destroyTxtAttr(gl);
destroyFboAttr(gl);
triangles.clear();
vertices.clear();
- }
- final void destroyFbo(GL2ES2 gl) {
+ }
+ final void destroyFbo(GL2ES2 gl) {
if(null != fbo) {
fbo.destroy(gl);
fbo = null;
- }
- }
+ }
+ }
final void destroyTxtAttr(GL2ES2 gl) {
if(null != verticeTxtAttr) {
verticeTxtAttr.destroy(gl);
@@ -331,7 +331,7 @@ public class VBORegion2PES2 implements Region {
indicesTxt.destroy(gl);
indicesTxt = null;
}
- }
+ }
final void destroyFboAttr(GL2ES2 gl) {
if(null != verticeFboAttr) {
verticeFboAttr.destroy(gl);
@@ -347,15 +347,15 @@ public class VBORegion2PES2 implements Region {
}
}
- public boolean isFlipped() {
- return flipped;
- }
+ public boolean isFlipped() {
+ return flipped;
+ }
- public void setFlipped(boolean flipped) {
- this.flipped = flipped;
- }
-
- public AABBox getBounds(){
- return box;
- }
+ public void setFlipped(boolean flipped) {
+ this.flipped = flipped;
+ }
+
+ public AABBox getBounds(){
+ return box;
+ }
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index 0d68be8ce..83cd6b80d 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -41,143 +41,143 @@ import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.PMVMatrix;
public class VBORegionSPES2 implements Region {
- private int numVertices = 0;
-
- private ArrayList<Triangle> triangles = new ArrayList<Triangle>();
- private ArrayList<Vertex> vertices = new ArrayList<Vertex>();
- private GLArrayDataServer verticeAttr = null;
- private GLArrayDataServer texCoordAttr = null;
- private GLArrayDataServer indices = null;
-
- private GLContext context;
-
- private boolean flipped = false;
- private boolean dirty = false;
-
- private AABBox box = null;
-
- public VBORegionSPES2(GLContext context){
- this.context =context;
- }
-
- public void update(){
- box = new AABBox();
- GL2ES2 gl = context.getGL().getGL2ES2();
-
+ private int numVertices = 0;
+
+ private ArrayList<Triangle> triangles = new ArrayList<Triangle>();
+ private ArrayList<Vertex> vertices = new ArrayList<Vertex>();
+ private GLArrayDataServer verticeAttr = null;
+ private GLArrayDataServer texCoordAttr = null;
+ private GLArrayDataServer indices = null;
+
+ private GLContext context;
+
+ private boolean flipped = false;
+ private boolean dirty = false;
+
+ private AABBox box = null;
+
+ public VBORegionSPES2(GLContext context){
+ this.context =context;
+ }
+
+ public void update(){
+ box = new AABBox();
+ GL2ES2 gl = context.getGL().getGL2ES2();
+
destroy(gl);
indices = GLArrayDataServer.createGLSL(gl, null, 3, GL2ES2.GL_SHORT, false,
triangles.size(), GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
- for(Triangle t:triangles){
- final Vertex[] t_vertices = t.getVertices();
-
- if(t_vertices[0].getId() == Integer.MAX_VALUE){
- t_vertices[0].setId(numVertices++);
- t_vertices[1].setId(numVertices++);
- t_vertices[2].setId(numVertices++);
-
- vertices.add(t.getVertices()[0]);
- vertices.add(t.getVertices()[1]);
- vertices.add(t.getVertices()[2]);
+ for(Triangle t:triangles){
+ final Vertex[] t_vertices = t.getVertices();
+
+ if(t_vertices[0].getId() == Integer.MAX_VALUE){
+ t_vertices[0].setId(numVertices++);
+ t_vertices[1].setId(numVertices++);
+ t_vertices[2].setId(numVertices++);
+
+ vertices.add(t.getVertices()[0]);
+ vertices.add(t.getVertices()[1]);
+ vertices.add(t.getVertices()[2]);
- indices.puts((short) t.getVertices()[0].getId());
- indices.puts((short) t.getVertices()[1].getId());
- indices.puts((short) t.getVertices()[2].getId());
- }
- else{
- Vertex v1 = t_vertices[0];
- Vertex v2 = t_vertices[1];
- Vertex v3 = t_vertices[2];
-
- indices.puts((short) v1.getId());
- indices.puts((short) v2.getId());
- indices.puts((short) v3.getId());
- }
- }
+ indices.puts((short) t.getVertices()[0].getId());
+ indices.puts((short) t.getVertices()[1].getId());
+ indices.puts((short) t.getVertices()[2].getId());
+ }
+ else{
+ Vertex v1 = t_vertices[0];
+ Vertex v2 = t_vertices[1];
+ Vertex v3 = t_vertices[2];
+
+ indices.puts((short) v1.getId());
+ indices.puts((short) v2.getId());
+ indices.puts((short) v3.getId());
+ }
+ }
indices.seal(gl, true);
-
- verticeAttr = GLArrayDataServer.createGLSL(gl, Region.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, false,
- vertices.size(), GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
- verticeAttr.setLocation(Region.VERTEX_ATTR_IDX);
- for(Vertex v:vertices){
-
- if(flipped){
- verticeAttr.putf(v.getX());
- verticeAttr.putf(-1*v.getY());
- verticeAttr.putf(v.getZ());
-
- box.resize(v.getX(),-1*v.getY(),v.getZ());
- }
- else{
- verticeAttr.putf(v.getX());
- verticeAttr.putf(v.getY());
- verticeAttr.putf(v.getZ());
-
- box.resize(v.getX(),v.getY(),v.getZ());
- }
- }
- verticeAttr.seal(gl, true);
+
+ verticeAttr = GLArrayDataServer.createGLSL(gl, Region.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, false,
+ vertices.size(), GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
+ verticeAttr.setLocation(Region.VERTEX_ATTR_IDX);
+ for(Vertex v:vertices){
+
+ if(flipped){
+ verticeAttr.putf(v.getX());
+ verticeAttr.putf(-1*v.getY());
+ verticeAttr.putf(v.getZ());
+
+ box.resize(v.getX(),-1*v.getY(),v.getZ());
+ }
+ else{
+ verticeAttr.putf(v.getX());
+ verticeAttr.putf(v.getY());
+ verticeAttr.putf(v.getZ());
+
+ box.resize(v.getX(),v.getY(),v.getZ());
+ }
+ }
+ verticeAttr.seal(gl, true);
texCoordAttr = GLArrayDataServer.createGLSL(gl, Region.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, false,
vertices.size(), GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
texCoordAttr.setLocation(Region.TEXCOORD_ATTR_IDX);
- for(Vertex v:vertices){
- float[] tex = v.getTexCoord();
- texCoordAttr.putf(tex[0]);
- texCoordAttr.putf(tex[1]);
- }
- texCoordAttr.seal(gl, true);
+ for(Vertex v:vertices){
+ float[] tex = v.getTexCoord();
+ texCoordAttr.putf(tex[0]);
+ texCoordAttr.putf(tex[1]);
+ }
+ texCoordAttr.seal(gl, true);
verticeAttr.enableBuffer(gl, false);
texCoordAttr.enableBuffer(gl, false);
indices.enableBuffer(gl, false);
- dirty = false;
- }
-
- private void render() {
- GL2ES2 gl = context.getGL().getGL2ES2();
+ dirty = false;
+ }
+
+ private void render() {
+ GL2ES2 gl = context.getGL().getGL2ES2();
verticeAttr.enableBuffer(gl, true);
texCoordAttr.enableBuffer(gl, true);
indices.enableBuffer(gl, true);
-
- gl.glDrawElements(GL2ES2.GL_TRIANGLES, indices.getElementNumber() * indices.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
-
+
+ gl.glDrawElements(GL2ES2.GL_TRIANGLES, indices.getElementNumber() * indices.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
+
verticeAttr.enableBuffer(gl, false);
texCoordAttr.enableBuffer(gl, false);
indices.enableBuffer(gl, false);
- }
-
- public void render(PMVMatrix matrix, int vp_width, int vp_height, int width){
- render();
- }
-
- public void addTriangles(ArrayList<Triangle> tris) {
- triangles.addAll(tris);
- dirty = true;
- }
-
- public int getNumVertices(){
- return numVertices;
- }
-
- public void addVertices(ArrayList<Vertex> verts){
- vertices.addAll(verts);
- numVertices = vertices.size();
- dirty = true;
- }
-
- public boolean isDirty(){
- return dirty;
- }
-
- public void destroy() {
- GL2ES2 gl = context.getGL().getGL2ES2();
- destroy(gl);
- }
-
- final void destroy(GL2ES2 gl) {
+ }
+
+ public void render(PMVMatrix matrix, int vp_width, int vp_height, int width){
+ render();
+ }
+
+ public void addTriangles(ArrayList<Triangle> tris) {
+ triangles.addAll(tris);
+ dirty = true;
+ }
+
+ public int getNumVertices(){
+ return numVertices;
+ }
+
+ public void addVertices(ArrayList<Vertex> verts){
+ vertices.addAll(verts);
+ numVertices = vertices.size();
+ dirty = true;
+ }
+
+ public boolean isDirty(){
+ return dirty;
+ }
+
+ public void destroy() {
+ GL2ES2 gl = context.getGL().getGL2ES2();
+ destroy(gl);
+ }
+
+ final void destroy(GL2ES2 gl) {
if(null != verticeAttr) {
verticeAttr.destroy(gl);
verticeAttr = null;
@@ -190,16 +190,16 @@ public class VBORegionSPES2 implements Region {
indices.destroy(gl);
indices = null;
}
- }
-
- public boolean isFlipped() {
- return flipped;
- }
+ }
+
+ public boolean isFlipped() {
+ return flipped;
+ }
- public void setFlipped(boolean flipped) {
- this.flipped = flipped;
- }
- public AABBox getBounds(){
- return box;
- }
+ public void setFlipped(boolean flipped) {
+ this.flipped = flipped;
+ }
+ public AABBox getBounds(){
+ return box;
+ }
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp
index 3a1ef5157..166937f7f 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp
@@ -15,81 +15,81 @@ vec4 weights = vec4(0.075, 0.06, 0.045, 0.025);
void main (void)
{
- vec2 rtex = vec2(abs(v_texCoord.x),abs(v_texCoord.y));
- vec3 c = g_color;
-
- float alpha = 0.0;
-
- if((v_texCoord.x == 0.0) && (v_texCoord.y == 0.0)){
- alpha = g_alpha;
- }
- else if((v_texCoord.x >= 5.0)){
- vec2 dfx = dFdx(v_texCoord);
- vec2 dfy = dFdy(v_texCoord);
-
- vec2 size = 1.0/textureSize(texture,0); //version 130
- rtex -= 5.0;
- vec4 t = texture2D(texture, rtex)* 0.18;
+ vec2 rtex = vec2(abs(v_texCoord.x),abs(v_texCoord.y));
+ vec3 c = g_color;
+
+ float alpha = 0.0;
+
+ if((v_texCoord.x == 0.0) && (v_texCoord.y == 0.0)){
+ alpha = g_alpha;
+ }
+ else if((v_texCoord.x >= 5.0)){
+ vec2 dfx = dFdx(v_texCoord);
+ vec2 dfy = dFdy(v_texCoord);
+
+ vec2 size = 1.0/textureSize(texture,0); //version 130
+ rtex -= 5.0;
+ vec4 t = texture2D(texture, rtex)* 0.18;
- t += texture2D(texture, rtex + size*(vec2(1, 0)))*weights.x;
- t += texture2D(texture, rtex - size*(vec2(1, 0)))*weights.x;
- t += texture2D(texture, rtex + size*(vec2(0, 1)))*weights.x;
- t += texture2D(texture, rtex - size*(vec2(0, 1)))*weights.x;
-
- t += texture2D(texture, rtex + 2.0*size*(vec2(1, 0))) *weights.y;
- t += texture2D(texture, rtex - 2.0*size*(vec2(1, 0)))*weights.y;
- t += texture2D(texture, rtex + 2.0*size*(vec2(0, 1)))*weights.y;
- t += texture2D(texture, rtex - 2.0*size*(vec2(0, 1)))*weights.y;
-
- t += texture2D(texture, rtex + 3.0*size*(vec2(1, 0))) *weights.z;
- t += texture2D(texture, rtex - 3.0*size*(vec2(1, 0)))*weights.z;
- t += texture2D(texture, rtex + 3.0*size*(vec2(0, 1)))*weights.z;
- t += texture2D(texture, rtex - 3.0*size*(vec2(0, 1)))*weights.z;
-
- t += texture2D(texture, rtex + 4.0*size*(vec2(1, 0))) *weights.w;
- t += texture2D(texture, rtex - 4.0*size*(vec2(1, 0)))*weights.w;
- t += texture2D(texture, rtex + 4.0*size*(vec2(0, 1)))*weights.w;
- t += texture2D(texture, rtex - 4.0*size*(vec2(0, 1)))*weights.w;
-
- if(t.w == 0.0){
- discard;
- }
-
- c = t.xyz;
- alpha = g_alpha* t.w;
- }
- ///////////////////////////////////////////////////////////
- else if ((v_texCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)){
- vec2 dtx = dFdx(rtex);
- vec2 dty = dFdy(rtex);
-
- rtex.y -= 0.1;
-
- if(rtex.y < 0.0) {
- if(v_texCoord.y < 0.0)
- discard;
- else{
- rtex.y = 0.0;
- }
- }
-
- 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 d = position/(length(f));
+ t += texture2D(texture, rtex + size*(vec2(1, 0)))*weights.x;
+ t += texture2D(texture, rtex - size*(vec2(1, 0)))*weights.x;
+ t += texture2D(texture, rtex + size*(vec2(0, 1)))*weights.x;
+ t += texture2D(texture, rtex - size*(vec2(0, 1)))*weights.x;
+
+ t += texture2D(texture, rtex + 2.0*size*(vec2(1, 0))) *weights.y;
+ t += texture2D(texture, rtex - 2.0*size*(vec2(1, 0)))*weights.y;
+ t += texture2D(texture, rtex + 2.0*size*(vec2(0, 1)))*weights.y;
+ t += texture2D(texture, rtex - 2.0*size*(vec2(0, 1)))*weights.y;
+
+ t += texture2D(texture, rtex + 3.0*size*(vec2(1, 0))) *weights.z;
+ t += texture2D(texture, rtex - 3.0*size*(vec2(1, 0)))*weights.z;
+ t += texture2D(texture, rtex + 3.0*size*(vec2(0, 1)))*weights.z;
+ t += texture2D(texture, rtex - 3.0*size*(vec2(0, 1)))*weights.z;
+
+ t += texture2D(texture, rtex + 4.0*size*(vec2(1, 0))) *weights.w;
+ t += texture2D(texture, rtex - 4.0*size*(vec2(1, 0)))*weights.w;
+ t += texture2D(texture, rtex + 4.0*size*(vec2(0, 1)))*weights.w;
+ t += texture2D(texture, rtex - 4.0*size*(vec2(0, 1)))*weights.w;
+
+ if(t.w == 0.0){
+ discard;
+ }
+
+ c = t.xyz;
+ alpha = g_alpha* t.w;
+ }
+ ///////////////////////////////////////////////////////////
+ else if ((v_texCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)){
+ vec2 dtx = dFdx(rtex);
+ vec2 dty = dFdy(rtex);
+
+ rtex.y -= 0.1;
+
+ if(rtex.y < 0.0) {
+ if(v_texCoord.y < 0.0)
+ discard;
+ else{
+ rtex.y = 0.0;
+ }
+ }
+
+ 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 d = position/(length(f));
- float a = (0.5 - d * sign(v_texCoord.y));
-
- if (a >= 1.0) {
- alpha = g_alpha;
- }
- else if (a <= 0.0) {
- alpha = 0.0;//discard;
- }
- else {
- alpha = g_alpha*a;
- mix(b_color,g_color, a);
- }
- }
-
+ float a = (0.5 - d * sign(v_texCoord.y));
+
+ if (a >= 1.0) {
+ alpha = g_alpha;
+ }
+ else if (a <= 0.0) {
+ alpha = 0.0;//discard;
+ }
+ else {
+ alpha = g_alpha*a;
+ mix(b_color,g_color, a);
+ }
+ }
+
gl_FragColor = vec4(c, alpha);
}