diff options
author | Sven Gothel <[email protected]> | 2011-10-04 02:48:22 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-10-04 02:48:22 +0200 |
commit | a095b7da968533120306ff9ef019685b6698272c (patch) | |
tree | f04c4043eafbfb7df255ea19aeeeeca69bd6e40c /src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp | |
parent | c76e858c7f4481cab2dae6e079e0db35e3b591e6 (diff) |
Graph Shader Simplification, 'a'/'b' redefined; GraphUI 2-pass demo;
Graph Shader Simplification
- remove enable factor and 2nd 'discard' branch
- use build-in 'max'/'clamp' functions, supposed to be faster
Graph Shader 'a'/'b' redefined
- 'a' is 1-pass shader only
- 'b' is 2-pass incl. (1st pass + 2nd pass)
- Works well on ARM Mali-400 MP (Galaxy S2).
- Doesn't work on NV tegra2 (P1202: Texture's gl states do not match with shader's),
however 2-pass on mobile seems to be overkill for now.
We may create a workaround (switch shader ..).
GraphUI 2-pass demo;
- Propagate renderModes and texSize to UIShape's render(..)
- TODO: Remove GL dependency in UIShape, maybe use a callback or visitor model
- Adding GarpUI 2-pass launcher (Android and Standalone)
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp')
-rw-r--r-- | src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp | 47 |
1 files changed, 18 insertions, 29 deletions
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 index b51ec5808..f3a88adef 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp @@ -1,51 +1,40 @@ //Copyright 2010 JogAmp Community. All rights reserved. +// +// 1-pass shader w/o weight +// + #include uniforms.glsl #include varyings.glsl -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) { 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 > 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(gcv_TexCoord.y < 0.0) { - // discard; // freezes NV tegra2 compiler (TODO: dbl check) - enable = 0.0; - } 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(gcv_TexCoord.y)); - - if (a >= 1.0) { - alpha = gcu_Alpha * enable; - } else if (a <= 0.0) { - // discard; // freezes NV tegra2 compiler (TODO: dbl check) + if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { + // discard; // freezes NV tegra2 compiler alpha = 0.0; - } else { - alpha = gcu_Alpha * a * enable; - // ?? mix(b_color,gcu_ColorStatic.rgb, a); + } 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; } } |