aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-05-17 07:55:59 +0200
committerSven Gothel <[email protected]>2013-05-17 07:55:59 +0200
commitb2802021acf8aa9b363ebef383c8dc8c8079ffa4 (patch)
tree7a9ba6c7b951e6eaf5fe7f91c5ef00ad9b357279 /src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp
parent33abeb8097a8f80acd1a4ce94b4866e5dc41f0c0 (diff)
Fix Bug 711: Align Graphs's Curve Shader programmatically to used GL/GLSL version, following all other internal GLSL usage utilizing ShaderCode.
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp54
1 files changed, 54 insertions, 0 deletions
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);
+}