diff options
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve/opengl')
8 files changed, 145 insertions, 46 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index 0b47606e4..6f79e1407 100755 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -41,20 +41,29 @@ import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState;
public class RegionRendererImpl01 extends RegionRenderer {
- public RegionRendererImpl01(RenderState rs, int type) {
- super(rs, type);
- // rs.getSharpness().setData(0.5f);
- // rs.getAlpha().setData(1.0f);
- // rs.getStrength().setData(3.0f);
+ public RegionRendererImpl01(RenderState rs, int type, boolean uniform) {
+ super(rs, type, uniform);
+
+ }
+
+ private String getVertexShaderName(){
+ return "curverenderer01";
+ }
+
+ private String getFragmentShaderName(){
+ if(!isUniform()){
+ return "curverenderer02";
+ }
+ return "curverenderer01";
}
protected boolean initShaderProgram(GL2ES2 gl) {
final ShaderState st = rs.getShaderState();
ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RegionRendererImpl01.class,
- "shader", "shader/bin", "curverenderer01");
+ "shader", "shader/bin", getVertexShaderName());
ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RegionRendererImpl01.class,
- "shader", "shader/bin", "curverenderer01");
+ "shader", "shader/bin", getFragmentShaderName());
ShaderProgram sp = new ShaderProgram();
sp.add(rsVp);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java b/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java index eef64dab5..350c77d98 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java @@ -49,14 +49,13 @@ public class RenderStateImpl implements RenderState { private final GLUniformData gcu_PMVMatrix; /** - * Sharpness is equivalent to the texture-coord component <i>t</i> - * on the off-curve vertex. Higher values of sharpness will - * result in higher curvature. + * weight is equivalent to the + * global off-curve vertex weight. + * TODO: change to per vertex */ - private final GLUniformData gcu_Sharpness; + private final GLUniformData gcu_Weight; private final GLUniformData gcu_Alpha; private final GLUniformData gcu_ColorStatic; - private final GLUniformData gcu_Strength; public static final RenderState getRenderState(GL2ES2 gl) { return (RenderState) gl.getContext().getAttachedObject(RenderState.class.getName()); @@ -69,14 +68,14 @@ public class RenderStateImpl implements RenderState { this.gcu_PMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, pmvMatrix.glGetPMvMatrixf()); st.ownUniform(gcu_PMVMatrix); - gcu_Sharpness = new GLUniformData(UniformNames.gcu_P1Y, 0.5f); + gcu_Weight = new GLUniformData(UniformNames.gcu_Weight, 1.0f); st.ownUniform(gcu_PMVMatrix); gcu_Alpha = new GLUniformData(UniformNames.gcu_Alpha, 1.0f); st.ownUniform(gcu_Alpha); gcu_ColorStatic = new GLUniformData(UniformNames.gcu_ColorStatic, 3, FloatBuffer.allocate(3)); st.ownUniform(gcu_ColorStatic); - gcu_Strength = new GLUniformData(UniformNames.gcu_Strength, 3.0f); - st.ownUniform(gcu_Strength); +// gcu_Strength = new GLUniformData(UniformNames.gcu_Strength, 3.0f); +// st.ownUniform(gcu_Strength); } public RenderStateImpl(ShaderState st, Vertex.Factory<? extends Vertex> pointFactory) { @@ -94,10 +93,10 @@ public class RenderStateImpl implements RenderState { public final Vertex.Factory<? extends Vertex> getPointFactory () { return pointFactory; } public final PMVMatrix pmvMatrix() { return pmvMatrix; } public final GLUniformData getPMVMatrix() { return gcu_PMVMatrix; } - public final GLUniformData getSharpness() { return gcu_Sharpness; } + public final GLUniformData getWeight() { return gcu_Weight; } public final GLUniformData getAlpha() { return gcu_Alpha; } public final GLUniformData getColorStatic() { return gcu_ColorStatic; } - public final GLUniformData getStrength() { return gcu_Strength; } + //public final GLUniformData getStrength() { return gcu_Strength; } public void destroy(GL2ES2 gl) { st.destroy(gl); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java index 2255251a7..257d05fca 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java @@ -42,11 +42,7 @@ import com.jogamp.opengl.util.glsl.ShaderState; public class TextRendererImpl01 extends TextRenderer { public TextRendererImpl01(RenderState rs, int type) { - super(rs, type); - // rs.getSharpness().setData(0.5f); - // rs.getAlpha().setData(1.0f); - // rs.getStrength().setData(3.0f); - rs.getStrength().setData(1.9f); + super(rs, type); } @Override diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java b/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java index 2e04278ca..bb6ff987d 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java @@ -4,7 +4,6 @@ public class UniformNames { public static final String gcu_PMVMatrix = "gcu_PMVMatrix"; // gcu_PMVMatrix[3]; // P, Mv, and Mvi public static final String gcu_ColorStatic = "gcu_ColorStatic"; public static final String gcu_Alpha = "gcu_Alpha"; - public static final String gcu_P1Y = "gcu_P1Y"; - public static final String gcu_Strength = "gcu_Strength"; + public static final String gcu_Weight = "gcu_Weight"; public static final String gcu_TextureUnit = "gcu_TextureUnit"; } 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 975c2dc5b..b3693ec88 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp @@ -12,8 +12,8 @@ #include uniforms.glsl #include varyings.glsl -const vec3 b_color = vec3(0.0, 0.0, 0.0); -const vec4 weights = vec4(0.075, 0.06, 0.045, 0.025); +const vec3 b_color = vec3(1.0, 1.0, 1.0); +const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025); void main (void) { @@ -33,25 +33,25 @@ void main (void) rtex -= 5.0; vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18; - t += texture2D(gcu_TextureUnit, rtex + size*(vec2(1, 0)))*weights.x; - t += texture2D(gcu_TextureUnit, rtex - size*(vec2(1, 0)))*weights.x; - t += texture2D(gcu_TextureUnit, rtex + size*(vec2(0, 1)))*weights.x; - t += texture2D(gcu_TextureUnit, rtex - size*(vec2(0, 1)))*weights.x; + 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)))*weights.y; - t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(1, 0)))*weights.y; - t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(0, 1)))*weights.y; - t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(0, 1)))*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(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)))*weights.z; - t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(1, 0)))*weights.z; - t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(0, 1)))*weights.z; - t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(0, 1)))*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(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)))*weights.w; - t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(1, 0)))*weights.w; - t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(0, 1)))*weights.w; - t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(0, 1)))*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(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(t.w == 0.0){ discard; @@ -85,7 +85,7 @@ void main (void) alpha = gcu_Alpha; } else if (a <= 0.0) { - alpha = 0.0;//discard; + discard; } else { alpha = gcu_Alpha * a; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02.fp new file mode 100755 index 000000000..e3d5bc074 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02.fp @@ -0,0 +1,97 @@ +//Copyright 2010 JogAmp Community. All rights reserved.
+/**
+#ifdef GL_ES
+ #version 100
+#else
+ #version 110
+#endif
+ */
+
+#include uniforms.glsl
+#include varyings.glsl
+
+const vec3 b_color = vec3(0.0, 0.0, 0.0);
+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/textureSize(gcu_TextureUnit,0); //version 130 - FIXME: replace with uniform value
+ 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(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) {
+ if(gcv_TexCoord.y < 0.0)
+ discard;
+ else{
+ 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*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2*rtex.x))/gd));
+
+ 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) {
+ discard;
+ }
+ else {
+ alpha = gcu_Alpha*a;
+ }
+ }
+ gl_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 677c7324f..332edd02b 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl @@ -9,8 +9,7 @@ uniform HIGHP mat4 gcu_PMVMatrix[3]; // P, Mv, and Mvi uniform HIGHP vec3 gcu_ColorStatic; uniform HIGHP float gcu_Alpha; -uniform HIGHP float gcu_P1Y; -uniform HIGHP float gcu_Strength; +uniform HIGHP float gcu_Weight; uniform sampler2D gcu_TextureUnit; // uniform HIGHP mat3 gcu_NormalMatrix; // transpose(inverse(ModelView)).3x3 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 e70c25266..0b821524c 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl @@ -6,7 +6,7 @@ #include consts.glsl -varying vec4 gcv_FrontColor; +//varying vec4 gcv_FrontColor; varying vec2 gcv_TexCoord; #endif // varyings_glsl |