From b2802021acf8aa9b363ebef383c8dc8c8079ffa4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 17 May 2013 07:55:59 +0200 Subject: Fix Bug 711: Align Graphs's Curve Shader programmatically to used GL/GLSL version, following all other internal GLSL usage utilizing ShaderCode. --- .../com/jogamp/graph/curve/opengl/Renderer.java | 35 +++++--- .../com/jogamp/opengl/util/glsl/ShaderCode.java | 28 ++++++- .../graph/curve/opengl/RegionRendererImpl01.java | 29 ++++--- .../graph/curve/opengl/TextRendererImpl01.java | 20 +++-- .../graph/curve/opengl/shader/attributes.glsl | 4 + .../opengl/shader/curverenderer01-1pass-weight.fp | 54 ++++++++++++ .../curve/opengl/shader/curverenderer01-1pass.fp | 48 +++++++++++ .../opengl/shader/curverenderer01-2pass-weight.fp | 95 ++++++++++++++++++++++ .../curve/opengl/shader/curverenderer01-2pass.fp | 89 ++++++++++++++++++++ .../opengl/shader/curverenderer01-es2-merged.vp | 19 ----- .../curve/opengl/shader/curverenderer01-es2.vp | 9 -- .../curve/opengl/shader/curverenderer01-gl2.vp | 6 -- .../curve/opengl/shader/curverenderer01-xxx.vp | 12 --- .../graph/curve/opengl/shader/curverenderer01.vp | 12 +++ .../opengl/shader/curverenderer01a-es2-merged.fp | 52 ------------ .../curve/opengl/shader/curverenderer01a-es2.fp | 13 --- .../curve/opengl/shader/curverenderer01a-gl2.fp | 6 -- .../curve/opengl/shader/curverenderer01a-xxx.fp | 42 ---------- .../curve/opengl/shader/curverenderer01b-es2.fp | 14 ---- .../curve/opengl/shader/curverenderer01b-gl2.fp | 6 -- .../curve/opengl/shader/curverenderer01b-xxx.fp | 82 ------------------- .../curve/opengl/shader/curverenderer02a-es2.fp | 14 ---- .../curve/opengl/shader/curverenderer02a-gl2.fp | 6 -- .../curve/opengl/shader/curverenderer02a-xxx.fp | 48 ----------- .../curve/opengl/shader/curverenderer02b-es2.fp | 14 ---- .../curve/opengl/shader/curverenderer02b-gl2.fp | 6 -- .../curve/opengl/shader/curverenderer02b-xxx.fp | 88 -------------------- .../jogamp/graph/curve/opengl/shader/varyings.glsl | 4 + 28 files changed, 384 insertions(+), 471 deletions(-) create mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp create mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp create mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp create mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2-merged.vp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2.vp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-gl2.vp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.vp create mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2-merged.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-gl2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-es2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-gl2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-xxx.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-es2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-gl2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-xxx.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-es2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-gl2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-xxx.fp (limited to 'src/jogl') diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java index fcccf592e..998129551 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java @@ -33,6 +33,7 @@ import javax.media.opengl.GL2ES2; import javax.media.opengl.GLException; import javax.media.opengl.fixedfunc.GLMatrixFunc; +import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderState; import com.jogamp.opengl.util.PMVMatrix; @@ -263,21 +264,31 @@ public abstract class Renderer { return true; } - protected String getVertexShaderName(GL2ES2 gl) { - return "curverenderer01" + getShaderGLVersionSuffix(gl); + protected String getVertexShaderName() { + return "curverenderer" + getImplVersion(); } - protected String getFragmentShaderName(GL2ES2 gl) { - final String type = "01" ; // Region.isNonUniformWeight(renderModes) ? "02" : "01" ; - final String pass = Region.isVBAA(renderModes) ? "b" : "a" ; - return "curverenderer" + type + pass + getShaderGLVersionSuffix(gl); + protected String getFragmentShaderName() { + final String version = getImplVersion(); + final String pass = Region.isVBAA(renderModes) ? "-2pass" : "-1pass" ; + final String weight = Region.isNonUniformWeight(renderModes) ? "-weight" : "" ; + return "curverenderer" + version + pass + weight; } - - protected String getShaderGLVersionSuffix(GL2ES2 gl) { - if(gl.isGLES2()) { - return "-es2"; + + // FIXME: Really required to have sampler2D def. precision ? If not, we can drop getFragmentShaderPrecision(..) and use default ShaderCode .. + public static final String es2_precision_fp = "\nprecision mediump float;\nprecision mediump int;\nprecision mediump sampler2D;\n"; + + protected String getFragmentShaderPrecision(GL2ES2 gl) { + if( gl.isGLES2() ) { + return es2_precision_fp; } - return "-gl2"; - } + if( ShaderCode.requiresGL3DefaultPrecision(gl) ) { + return ShaderCode.gl3_default_precision_fp; + } + return null; + } + protected String getImplVersion() { + return "01"; + } } \ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index 80a7efaec..edc3d2677 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -684,7 +684,7 @@ public class ShaderCode { * * @param shaderIdx the shader index to be used. * @param position in shader source segments of shader shaderIdx - * @param data the text to be inserted. Shall end with an EOL '\n' character. + * @param data the text to be inserted. Shall end with an EOL '\n' character * @return index after the inserted data * * @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type StringBuilder @@ -833,8 +833,11 @@ public class ShaderCode { /** Default precision of GLSL ≥ 1.30 as required until < 1.50 for {@link GL2ES2#GL_VERTEX_SHADER vertex-shader} or {@link GL3#GL_GEOMETRY_SHADER geometry-shader}: {@value #gl3_default_precision_vp_gp}. See GLSL Spec 1.30-1.50 Section 4.5.3. */ public static final String gl3_default_precision_vp_gp = "\nprecision highp float;\nprecision highp int;\n"; /** Default precision of GLSL ≥ 1.30 as required until < 1.50 for {@link GL2ES2#GL_FRAGMENT_SHADER fragment-shader}: {@value #gl3_default_precision_fp}. See GLSL Spec 1.30-1.50 Section 4.5.3. */ - public static final String gl3_default_precision_fp = "\nprecision highp float;\nprecision mediump int;\n"; + public static final String gl3_default_precision_fp = "\nprecision highp float;\nprecision mediump int;\n/*precision mediump sampler2D;*/\n"; + /** Prefer enable over require, since it won't force a failure. */ + public static final String extOESDerivativesEnable = "#extension GL_OES_standard_derivatives : enable\n"; + /** * Add GLSL version at the head of this shader source code. *

@@ -860,7 +863,6 @@ public class ShaderCode { * @return the index after the inserted data, maybe 0 if nothing has be inserted. */ public final int addDefaultShaderPrecision(GL2ES2 gl, int pos) { - final VersionNumber glslVersion = gl.getContext().getGLSLVersionNumber(); final String defaultPrecision; if( gl.isGLES2() ) { switch ( shaderType ) { @@ -872,7 +874,7 @@ public class ShaderCode { defaultPrecision = null; break; } - } else if( glslVersion.compareTo(GLContext.Version130) >= 0 && glslVersion.compareTo(GLContext.Version150) < 0 ) { + } else if( requiresGL3DefaultPrecision(gl) ) { // GLSL [ 1.30 .. 1.50 [ needs at least fragement float default precision! switch ( shaderType ) { case GL2ES2.GL_VERTEX_SHADER: @@ -893,6 +895,24 @@ public class ShaderCode { return pos; } + /** Returns true, if GLSL version requires default precision, i.e. ES2 or GLSL [1.30 .. 1.50[. */ + public static final boolean requiresDefaultPrecision(GL2ES2 gl) { + if( gl.isGLES2() ) { + return true; + } + return requiresGL3DefaultPrecision(gl); + } + + /** Returns true, if GL3 GLSL version requires default precision, i.e. GLSL [1.30 .. 1.50[. */ + public static final boolean requiresGL3DefaultPrecision(GL2ES2 gl) { + if( gl.isGL3() ) { + final VersionNumber glslVersion = gl.getContext().getGLSLVersionNumber(); + return glslVersion.compareTo(GLContext.Version130) >= 0 && glslVersion.compareTo(GLContext.Version150) < 0 ; + } else { + return false; + } + } + /** * Default customization of this shader source code. *

diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index 2884aca2f..7f5afcd02 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -46,22 +46,25 @@ public class RegionRendererImpl01 extends RegionRenderer { } - @Override - protected String getFragmentShaderName(GL2ES2 gl) { - final String type = Region.isNonUniformWeight(renderModes) ? "02" : "01" ; - final String pass = Region.isVBAA(renderModes) ? "b" : "a" ; - return "curverenderer" + type + pass + getShaderGLVersionSuffix(gl); - } - protected boolean initShaderProgram(GL2ES2 gl) { final ShaderState st = rs.getShaderState(); - ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RegionRendererImpl01.class, "shader", - "shader/bin", getVertexShaderName(gl), false); - ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RegionRendererImpl01.class, "shader", - "shader/bin", getFragmentShaderName(gl), false); - - ShaderProgram sp = new ShaderProgram(); + final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RegionRendererImpl01.class, "shader", + "shader/bin", getVertexShaderName(), true); + final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RegionRendererImpl01.class, "shader", + "shader/bin", getFragmentShaderName(), true); + rsVp.defaultShaderCustomization(gl, true, true); + // rsFp.defaultShaderCustomization(gl, true, true); + int pos = rsFp.addGLSLVersion(gl); + if( gl.isGLES2() ) { + pos = rsFp.insertShaderSource(0, pos, ShaderCode.extOESDerivativesEnable); + } + final String rsFpDefPrecision = getFragmentShaderPrecision(gl); + if( null != rsFpDefPrecision ) { + rsFp.insertShaderSource(0, pos, rsFpDefPrecision); + } + + final ShaderProgram sp = new ShaderProgram(); sp.add(rsVp); sp.add(rsFp); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java index 0cf424cd2..81c421371 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java @@ -49,12 +49,22 @@ public class TextRendererImpl01 extends TextRenderer { protected boolean initShaderProgram(GL2ES2 gl){ final ShaderState st = rs.getShaderState(); - ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TextRendererImpl01.class, "shader", - "shader/bin", getVertexShaderName(gl), false); - ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TextRendererImpl01.class, "shader", - "shader/bin", getFragmentShaderName(gl), false); + final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TextRendererImpl01.class, "shader", + "shader/bin", getVertexShaderName(), true); + final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TextRendererImpl01.class, "shader", + "shader/bin", getFragmentShaderName(), true); + rsVp.defaultShaderCustomization(gl, true, true); + // rsFp.defaultShaderCustomization(gl, true, true); + int pos = rsFp.addGLSLVersion(gl); + if( gl.isGLES2() ) { + pos = rsFp.insertShaderSource(0, pos, ShaderCode.extOESDerivativesEnable); + } + final String rsFpDefPrecision = getFragmentShaderPrecision(gl); + if( null != rsFpDefPrecision ) { + rsFp.insertShaderSource(0, pos, rsFpDefPrecision); + } - ShaderProgram sp = new ShaderProgram(); + final ShaderProgram sp = new ShaderProgram(); sp.add(rsVp); sp.add(rsFp); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl index 108247c9c..ced118c1c 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl @@ -2,6 +2,10 @@ #ifndef attributes_glsl #define attributes_glsl +#if __VERSION__ >= 130 + #define attribute in +#endif + // attribute vec3 gca_Vertices; attribute vec4 gca_Vertices; attribute vec2 gca_TexCoords; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp new file mode 100644 index 000000000..ca03e605c --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp @@ -0,0 +1,54 @@ +//Copyright 2010 JogAmp Community. All rights reserved. + +// +// 1-pass shader w/ weight +// + +#if __VERSION__ >= 130 + out vec4 mgl_FragColor; +#else + #define mgl_FragColor gl_FragColor +#endif + +#include uniforms.glsl +#include varyings.glsl + +void main (void) +{ + 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)) { + alpha = gcu_Alpha; + } + 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); + + 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)); + + // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! + float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); + alpha = gcu_Alpha * a; + } + } + + mgl_FragColor = vec4(c, alpha); +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp new file mode 100644 index 000000000..b978b62d1 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp @@ -0,0 +1,48 @@ +//Copyright 2010 JogAmp Community. All rights reserved. + +// +// 1-pass shader w/o weight +// + +#if __VERSION__ >= 130 + out vec4 mgl_FragColor; +#else + #define mgl_FragColor gl_FragColor +#endif + +#include uniforms.glsl +#include varyings.glsl + +void main (void) +{ + 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)) { + alpha = gcu_Alpha; + } + 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); + + 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)); + + // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! + float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); + alpha = gcu_Alpha * a; + } + } + + mgl_FragColor = vec4(c, alpha); +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp new file mode 100644 index 000000000..9440f314c --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp @@ -0,0 +1,95 @@ +//Copyright 2010 JogAmp Community. All rights reserved. + +// +// 2-pass shader w/ weight +// + +#if __VERSION__ >= 130 + out vec4 mgl_FragColor; +#else + #define mgl_FragColor gl_FragColor +#endif + +#include uniforms.glsl +#include varyings.glsl + +const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025); + +void main (void) +{ + 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)) { + alpha = gcu_Alpha; + } + else if((gcv_TexCoord.x >= 5.0)) { + vec2 dfx = dFdx(gcv_TexCoord); + vec2 dfy = dFdy(gcv_TexCoord); + + vec2 size = 1.0/gcu_TextureSize; + + rtex -= 5.0; + vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18; + + 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; + + #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); + + 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)); + + // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! + float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); + alpha = gcu_Alpha * a; + } + } + + mgl_FragColor = vec4(c, alpha); +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp new file mode 100644 index 000000000..0d878f2e4 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp @@ -0,0 +1,89 @@ +//Copyright 2010 JogAmp Community. All rights reserved. + +// +// 2-pass shader w/o weight +// + +#if __VERSION__ >= 130 + out vec4 mgl_FragColor; +#else + #define mgl_FragColor gl_FragColor +#endif + +#include uniforms.glsl +#include varyings.glsl + +const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025); + +void main (void) +{ + vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); + vec3 c = gcu_ColorStatic.rgb; + + float alpha = 0.0; + float enable = 1.0; + + if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { + alpha = gcu_Alpha; + } + else if((gcv_TexCoord.x >= 5.0)) { + vec2 dfx = dFdx(gcv_TexCoord); + vec2 dfy = dFdy(gcv_TexCoord); + + vec2 size = 1.0/gcu_TextureSize; + + rtex -= 5.0; + vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18; + + 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; + + #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); + + 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)); + + // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! + float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); + alpha = gcu_Alpha * a; + } + } + + mgl_FragColor = vec4(c, alpha); +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2-merged.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2-merged.vp deleted file mode 100644 index 8fb985d69..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2-merged.vp +++ /dev/null @@ -1,19 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#ifdef GL_ES - precision highp float; - precision highp int; -#endif - -uniform mat4 gcu_PMVMatrix[3]; // P, Mv, and Mvi -varying vec2 gcv_TexCoord; - -attribute vec4 gca_Vertices; -attribute vec2 gca_TexCoords; - - -void main(void) -{ - gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * gca_Vertices; - gcv_TexCoord = gca_TexCoords; -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2.vp deleted file mode 100644 index a5dc158ad..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2.vp +++ /dev/null @@ -1,9 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -precision highp float; -precision highp int; - -#include curverenderer01-xxx.vp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-gl2.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-gl2.vp deleted file mode 100644 index 1ac33e8b3..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-gl2.vp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer01-xxx.vp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.vp deleted file mode 100644 index 64a6835ec..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.vp +++ /dev/null @@ -1,12 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#include uniforms.glsl -#include attributes.glsl -#include varyings.glsl - -void main(void) -{ - // gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * vec4(gca_Vertices, 1); - gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * gca_Vertices; - gcv_TexCoord = gca_TexCoords; -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp new file mode 100644 index 000000000..64a6835ec --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp @@ -0,0 +1,12 @@ +//Copyright 2010 JogAmp Community. All rights reserved. + +#include uniforms.glsl +#include attributes.glsl +#include varyings.glsl + +void main(void) +{ + // gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * vec4(gca_Vertices, 1); + gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * gca_Vertices; + gcv_TexCoord = gca_TexCoords; +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2-merged.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2-merged.fp deleted file mode 100644 index a57d8fc62..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2-merged.fp +++ /dev/null @@ -1,52 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#ifdef GL_ES - precision mediump float; - precision mediump int; -#endif - -uniform mat4 gcu_PMVMatrix[3]; // P, Mv, and Mvi -uniform vec3 gcu_ColorStatic; -uniform float gcu_Alpha; - -varying vec2 gcv_TexCoord; - -const vec3 b_color = vec3(1.0, 1.0, 1.0); - -void main (void) -{ - vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); - vec3 c = gcu_ColorStatic; - - float alpha = 0.0; - - if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { - alpha = gcu_Alpha; - } - else if ((gcv_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) { - 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(gcv_TexCoord.y)); - - if (a >= 1.0) { - alpha = gcu_Alpha; - } else if (a <= 0.0) { - alpha=0.0; - } else { - alpha = gcu_Alpha * a; - } - } - - gl_FragColor = vec4(c, alpha); -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2.fp deleted file mode 100644 index e693891a6..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2.fp +++ /dev/null @@ -1,13 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -// we require dFdx/dFdy -// #extension OES_standard_derivatives : require -#extension GL_OES_standard_derivatives : enable - -precision mediump float; -precision mediump int; - -#include curverenderer01a-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-gl2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-gl2.fp deleted file mode 100644 index d187fea24..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-gl2.fp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer01a-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp deleted file mode 100644 index f3a88adef..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp +++ /dev/null @@ -1,42 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 1-pass shader w/o weight -// - -#include uniforms.glsl -#include varyings.glsl - -void main (void) -{ - 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)) { - alpha = gcu_Alpha; - } - 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); - - 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)); - - // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! - float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); - alpha = gcu_Alpha * a; - } - } - - gl_FragColor = vec4(c, alpha); -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-es2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-es2.fp deleted file mode 100644 index d4748722d..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-es2.fp +++ /dev/null @@ -1,14 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -// we require dFdx/dFdy -// #extension OES_standard_derivatives : require -#extension GL_OES_standard_derivatives : enable - -precision mediump float; -precision mediump int; -precision mediump sampler2D; // default is lowp - -#include curverenderer01b-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-gl2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-gl2.fp deleted file mode 100644 index 01e08ff30..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-gl2.fp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer01b-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-xxx.fp deleted file mode 100644 index 879e41e4c..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-xxx.fp +++ /dev/null @@ -1,82 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 2-pass shader w/o weight -// - -#include uniforms.glsl -#include varyings.glsl - -const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025); - -void main (void) -{ - vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); - vec3 c = gcu_ColorStatic.rgb; - - float alpha = 0.0; - float enable = 1.0; - - if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { - alpha = gcu_Alpha; - } - else if((gcv_TexCoord.x >= 5.0)) { - vec2 dfx = dFdx(gcv_TexCoord); - vec2 dfy = dFdy(gcv_TexCoord); - - vec2 size = 1.0/gcu_TextureSize; - - rtex -= 5.0; - vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18; - - 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; - - /** discard freezes NV tegra2 compiler - if(t.w == 0.0){ - discard; - } */ - - 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); - - 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)); - - // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! - float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); - alpha = gcu_Alpha * a; - } - } - - gl_FragColor = vec4(c, alpha); -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-es2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-es2.fp deleted file mode 100644 index 240a6c30f..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-es2.fp +++ /dev/null @@ -1,14 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -// we require dFdx/dFdy -// #extension OES_standard_derivatives : require -#extension GL_OES_standard_derivatives : enable - -precision mediump float; -precision mediump int; -precision mediump sampler2D; // default is lowp - -#include curverenderer02a-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-gl2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-gl2.fp deleted file mode 100644 index 01715daa5..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-gl2.fp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer02a-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-xxx.fp deleted file mode 100644 index d31bafb5a..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-xxx.fp +++ /dev/null @@ -1,48 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 1-pass shader w/ weight -// - -#include uniforms.glsl -#include varyings.glsl - -void main (void) -{ - 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)) { - alpha = gcu_Alpha; - } - 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); - - 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)); - - // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! - float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); - alpha = gcu_Alpha * a; - } - } - - gl_FragColor = vec4(c, alpha); -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-es2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-es2.fp deleted file mode 100644 index 884e75674..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-es2.fp +++ /dev/null @@ -1,14 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -// we require dFdx/dFdy -// #extension OES_standard_derivatives : require -#extension GL_OES_standard_derivatives : enable - -precision mediump float; -precision mediump int; -precision mediump sampler2D; // default is lowp - -#include curverenderer02b-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-gl2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-gl2.fp deleted file mode 100644 index b1cc72188..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-gl2.fp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer02b-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-xxx.fp deleted file mode 100644 index be738498c..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-xxx.fp +++ /dev/null @@ -1,88 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 2-pass shader w/ weight -// - -#include uniforms.glsl -#include varyings.glsl - -const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025); - -void main (void) -{ - 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)) { - alpha = gcu_Alpha; - } - else if((gcv_TexCoord.x >= 5.0)) { - vec2 dfx = dFdx(gcv_TexCoord); - vec2 dfy = dFdy(gcv_TexCoord); - - vec2 size = 1.0/gcu_TextureSize; - - rtex -= 5.0; - vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18; - - 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; - - /** discard freezes NV tegra2 compiler - if(t.w == 0.0) { - discard; - } */ - - 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); - - 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)); - - // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! - float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); - alpha = gcu_Alpha * a; - } - } - - gl_FragColor = vec4(c, alpha); -} 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 7a9bc5a07..3b9a3b727 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl @@ -2,6 +2,10 @@ #ifndef varyings_glsl #define varyings_glsl +#if __VERSION__ >= 130 + #define varying out +#endif + //varying vec4 gcv_FrontColor; varying vec2 gcv_TexCoord; -- cgit v1.2.3