diff options
author | Sven Gothel <sgothel@jausoft.com> | 2014-03-22 06:23:50 +0100 |
---|---|---|
committer | Sven Gothel <sgothel@jausoft.com> | 2014-03-22 06:23:50 +0100 |
commit | b4817d053d7af20dae33774e430bf79a3d3c6fcd (patch) | |
tree | 1e7cd3d713e3c1f8442f00be8d161a63de34f601 /src/jogl/classes/jogamp/graph/curve/opengl/shader | |
parent | 523d1dae2431fdd56d39d3ea06220cfed412a0b5 (diff) |
Bug 801: Revise Graph VBAA (Add border dropping MSAA; Test diff. AA modes incl. FXAA2) ; Test exp. LineAA ; Misc Changes
- Revise VBAA
- Add border to FBO dropping MSAA
- This automatically gives AA for edges on FBO boundary
- Correcting ceil-diff, use object-diff instead of win-diff (diff := ceil(a)-a, w/ float a)
- Reorg shader - using includes to test diff. AA modes:
- [poles, wholeedge] * [equalweight, propweight]
- fxaa2
- Exp. LineAA (disabled)
- Test ROESSLER-2012-OGLES for detected rectangles only
- Test boundary line detection
See screenshots: <http://jogamp.org/files/screenshots/graphui/20140322/>
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve/opengl/shader')
19 files changed, 735 insertions, 408 deletions
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..c4d9db535 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl @@ -4,7 +4,20 @@ // attribute vec3 gca_Vertices; attribute vec4 gca_Vertices; -attribute vec2 gca_TexCoords; + +/** + * CDTriangulator2D.extractBoundaryTriangles(..): + * AA line (exp) : z > 0 + * line : x == 0, y == 0 + * hole or holeLike: 0 > y + * !hole : 0 < y + * + * 0 == gcv_TexCoord.x : vertex-0 of triangle + * 0.5 == gcv_TexCoord.x : vertex-1 of triangle + * 1 == gcv_TexCoord.x : vertex-2 of triangle + */ +attribute vec3 gca_TexCoords; + //attribute vec4 gca_Colors; //attribute vec3 gca_Normals; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp index 940e95071..20acfbac6 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp @@ -1,62 +1,28 @@ -//Copyright 2010 JogAmp Community. All rights reserved.
-
-//
-// 1-pass shader w/ weight
-//
-
-#if __VERSION__ >= 130
- #define varying in
- out vec4 mgl_FragColor;
-#else
- #define mgl_FragColor gl_FragColor
-#endif
-
-#include uniforms.glsl
-#include varyings.glsl
-
-const vec3 zero3 = vec3(0);
-
-void main (void)
-{
- vec3 c;
- float alpha;
-
- vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
-
- if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) {
- // pass-1: Lines
- c = gcu_ColorStatic.rgb;
- alpha = gcu_Alpha;
- } else if ( gcv_TexCoord.x > 0.0 && ( rtex.y > 0.0 || rtex.x == 1.0 ) ) {
- // pass-1: curves
- rtex.y -= 0.1;
-
- if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
- // discard; // freezes NV tegra2 compiler
- c = zero3;
- 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));
-
- c = gcu_ColorStatic.rgb;
- alpha = gcu_Alpha * clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
- }
- } else {
- c = zero3;
- alpha = 0.0;
- }
-
- mgl_FragColor = vec4(c, alpha);
-}
+//Copyright 2010 JogAmp Community. All rights reserved. + +// +// 1-pass shader w/o weight +// + +#if __VERSION__ >= 130 + #define varying in + out vec4 mgl_FragColor; +#else + #define mgl_FragColor gl_FragColor +#endif + +#include uniforms.glsl +#include varyings.glsl + +const vec3 zero3 = vec3(0); + +void main (void) +{ + vec3 color; + float alpha; + +// #include curverenderer01-pass1-curve-lineAA.glsl +#include curverenderer01-pass1-curve-weight.glsl + + mgl_FragColor = vec4(color, gcu_Alpha * alpha); +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp index 2175c1a31..03d2f9408 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp @@ -18,47 +18,11 @@ const vec3 zero3 = vec3(0); void main (void) { - vec3 c; + vec3 color; float alpha; - /** - * CDTriangulator2D.extractBoundaryTriangles(..): - * 0 > gcv_TexCoord.y : hole or holeLike - * 0 < gcv_TexCoord.y : !hole (outer) - * - * 0 == gcv_TexCoord.x : vertex-0 of triangle - * 0.5 == gcv_TexCoord.x : vertex-1 of triangle - * 1 == gcv_TexCoord.x : vertex-2 of triangle - */ - vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); - - if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) { - // pass-1: Lines - c = gcu_ColorStatic.rgb; - alpha = gcu_Alpha; - } else if ( gcv_TexCoord.x > 0.0 && ( rtex.y > 0.0 || rtex.x == 1.0 ) ) { - // pass-1: curves - rtex.y -= 0.1; - - if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { - // discard; // freezes NV tegra2 compiler - c = zero3; - alpha = 0.0; - } else { - rtex.y = max(rtex.y, 0.0); +// #include curverenderer01-pass1-curve-lineAA.glsl +#include curverenderer01-pass1-curve-simple.glsl - 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)); - - c = gcu_ColorStatic.rgb; - alpha = gcu_Alpha * clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); - } - } else { - c = zero3; - alpha = 0.0; - } - mgl_FragColor = vec4(c, alpha); + mgl_FragColor = vec4(color, gcu_Alpha * alpha); } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp index 733669e64..1c5688880 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp @@ -1,76 +1,42 @@ -//Copyright 2010 JogAmp Community. All rights reserved.
-
-//
-// 2-pass shader w/ weight
-//
-
-#if __VERSION__ >= 130
- #define varying in
- out vec4 mgl_FragColor;
- #define texture2D texture
-#else
- #define mgl_FragColor gl_FragColor
-#endif
-
-#include uniforms.glsl
-#include varyings.glsl
-
-const vec3 zero3 = vec3(0);
-
-void main (void)
-{
- vec3 c;
- float alpha;
-
- if( 0 < gcu_TextureSize.z ) {
- // Pass-2: Dump Texture
- vec4 t = texture2D(gcu_TextureUnit, gcv_TexCoord);
- #if 0
- if( 0.0 == t.a ) {
- discard; // discard freezes NV tegra2 compiler
- }
- #endif
-
- c = t.rgb;
- alpha = gcu_Alpha * t.a;
- } else {
- // Pass-1
- vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
-
- if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) {
- // pass-1: Lines
- c = gcu_ColorStatic.rgb;
- alpha = 1.0;
- } else if ( gcv_TexCoord.x > 0.0 && (rtex.y > 0.0 || rtex.x == 1.0) ) {
- // pass-1: curves
- rtex.y -= 0.1;
-
- if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
- // discard; // freezes NV tegra2 compiler
- c = zero3;
- 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));
-
- c = gcu_ColorStatic.rgb;
- alpha = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
- }
- } else {
- c = zero3;
- alpha = 0.0;
- }
- }
- mgl_FragColor = vec4(c, alpha);
-}
+//Copyright 2010 JogAmp Community. All rights reserved. + +// +// 2-pass shader w/ weight +// + +#if __VERSION__ >= 130 + #define varying in + out vec4 mgl_FragColor; + #define texture2D texture +#else + #define mgl_FragColor gl_FragColor +#endif + +#include uniforms.glsl +#include varyings.glsl + +const vec3 zero3 = vec3(0); + +void main (void) +{ + vec3 color; + float alpha; + + if( 0 < gcu_TextureSize.z ) { + // Pass-2: Dump Texture + vec4 t = texture2D(gcu_TextureUnit, gcv_TexCoord.st); + #if 0 + if( 0.0 == t.a ) { + discard; // discard freezes NV tegra2 compiler + } + #endif + + c = t.rgb; + alpha = gcu_Alpha * t.a; + } else { + +#include curverenderer01-pass1-curve-weight.glsl + + } + mgl_FragColor = vec4(c, alpha); +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp index 2536e251b..b78e11585 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp @@ -15,25 +15,23 @@ #include uniforms.glsl #include varyings.glsl -// #define PREALPHA 1 - const vec3 zero3 = vec3(0); void main (void) { - vec3 c; + vec3 color; float alpha; - + if( 0 < gcu_TextureSize.z ) { // Pass-2: Dump Texture - vec4 t = texture2D(gcu_TextureUnit, gcv_TexCoord); + vec4 t = texture2D(gcu_TextureUnit, gcv_TexCoord.st); #if 0 if( 0.0 == t.a ) { discard; // discard freezes NV tegra2 compiler } #endif - c = t.rgb; + color = t.rgb; #ifdef PREALPHA // alpha = mix(0.0, gcu_Alpha, t.a); // t.a one of [ 0.0, 1.0 ] // ^^ for = 0.0 == t.a ? 0.0 : gcu_Alpha; @@ -43,46 +41,10 @@ void main (void) alpha = gcu_Alpha * t.a; #endif } else { - // Pass-1 - vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); - - if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) { - // pass-1: Lines - c = gcu_ColorStatic.rgb; - alpha = 1.0; - } else if ( gcv_TexCoord.x > 0.0 && (rtex.y > 0.0 || rtex.x == 1.0) ) { - // pass-1: curves - rtex.y -= 0.1; - - if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { - // discard; // freezes NV tegra2 compiler - c = zero3; - 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)); +#include curverenderer01-pass1-curve-simple.glsl - #ifdef PREALPHA - float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); - c = gcu_ColorStatic.rgb * a; - alpha = mix(1.0, 0.0, step(a, 0.0)); - // ^^ = 0.0 < a ? 1.0 : 0.0; - // step(e, x) := e > x ? 0.0 : 1.0 - // mix(x, y, a) := x * ( 1 - a ) + y * a - #else - c = gcu_ColorStatic.rgb; - alpha = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); - #endif - } - } else { - c = zero3; - alpha = 0.0; - } } - mgl_FragColor = vec4(c, alpha); + mgl_FragColor = vec4(color, alpha); } + diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp index 3b1b55c87..36767b658 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp @@ -1,109 +1,44 @@ -//Copyright 2010 JogAmp Community. All rights reserved.
-
-//
-// 2-pass shader w/ weight
-//
-
-#if __VERSION__ >= 130
- #define varying in
- out vec4 mgl_FragColor;
- #define texture2D texture
-#else
- #define mgl_FragColor gl_FragColor
-#endif
-
-#include uniforms.glsl
-#include varyings.glsl
-
-const vec3 zero3 = vec3(0);
-
-void main (void)
-{
- vec3 c;
- float alpha;
-
- if( 0 < gcu_TextureSize.z ) {
- // Pass-2: AA on Texture
- // Note: gcv_TexCoord is in center of sample pixels.
-
- float sampleCount = gcu_TextureSize.z;
- vec2 psize = 1.0 / gcu_TextureSize.xy; // pixel size
-
- float sample_weight = 1 / ( 2 * sampleCount );
- // float sample_weight = 1 / ( 2 * sampleCount + 1 );
-
- vec4 t = vec4(0);
- // vec4 t = texture2D(gcu_TextureUnit, gcv_TexCoord)* sample_weight; // center: +1
-
- // SampleCount 2
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-0.5, -0.5)))*sample_weight; // NW
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-0.5, 0.5)))*sample_weight; // SW
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 0.5, 0.5)))*sample_weight; // SE
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 0.5, -0.5)))*sample_weight; // NE
- if( sampleCount > 2 ) {
- // SampleCount 4
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-1.5, -1.5)))*sample_weight;
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-1.5, 1.5)))*sample_weight;
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 1.5, 1.5)))*sample_weight;
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 1.5, -1.5)))*sample_weight;
- if( sampleCount > 4 ) {
- // SampleCount 8
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-2.5, -2.5)))*sample_weight;
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-2.5, 2.5)))*sample_weight;
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 2.5, 2.5)))*sample_weight;
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 2.5, -2.5)))*sample_weight;
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-3.5, -3.5)))*sample_weight;
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-3.5, 3.5)))*sample_weight;
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 3.5, 3.5)))*sample_weight;
- t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 3.5, -3.5)))*sample_weight;
- }
- }
- #if 0
- if(t.w == 0.0){
- discard; // discard freezes NV tegra2 compiler
- }
- #endif
-
- c = t.rgb;
- alpha = gcu_Alpha * t.a;
- } else {
- // pass-1
- vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
-
- if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) {
- // pass-1: Lines
- c = gcu_ColorStatic.rgb;
- alpha = 1.0;
- } else if ( gcv_TexCoord.x > 0.0 && (rtex.y > 0.0 || rtex.x == 1.0) ) {
- // pass-1: curves
- rtex.y -= 0.1;
-
- if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) {
- // discard; // freezes NV tegra2 compiler
- c = zero3;
- 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));
-
- c = gcu_ColorStatic.rgb;
- alpha = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
- }
- } else {
- c = zero3;
- alpha = 0.0;
- }
- }
- mgl_FragColor = vec4(c, alpha);
-}
+//Copyright 2010 JogAmp Community. All rights reserved. + +// +// 2-pass shader w/ weight +// + +#if __VERSION__ >= 130 + #define varying in + out vec4 mgl_FragColor; + #define texture2D texture +#else + #define mgl_FragColor gl_FragColor +#endif + +#include uniforms.glsl +#include varyings.glsl + +const vec3 zero3 = vec3(0); + +void main (void) +{ + vec3 color; + float alpha; + + // Note: gcu_Alpha is multiplied in pass2! + + if( 0 < gcu_TextureSize.z ) { + +// 1st Choice VBAA +#include curverenderer01-pass2-vbaa_poles_equalweight.glsl + +// #include curverenderer01-pass2-vbaa_poles_bilin1.glsl +// #include curverenderer01-pass2-vbaa_poles_propweight1.glsl +// #include curverenderer01-pass2-vbaa_wholeedge_propweight1.glsl +// #include curverenderer01-pass2-vbaa_wholeedge_equalweight.glsl +// #include curverenderer01-pass2-vbaa_fxaa3.glsl + + } else { + +#include curverenderer01-pass1-curve-weight.glsl + + } + mgl_FragColor = vec4(color, alpha); +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp index 8237fa55b..89a193501 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp @@ -19,85 +19,26 @@ const vec3 zero3 = vec3(0); void main (void) { - vec3 c; + vec3 color; float alpha; + // Note: gcu_Alpha is multiplied in pass2! + if( 0 < gcu_TextureSize.z ) { - // Pass-2: AA on Texture - // Note: gcv_TexCoord is in center of sample pixels. - float sampleCount = gcu_TextureSize.z; - vec2 psize = 1.0 / gcu_TextureSize.xy; // pixel size +// 1st Choice VBAA +#include curverenderer01-pass2-vbaa_poles_equalweight.glsl - float sample_weight = 1 / ( 2 * sampleCount ); - // float sample_weight = 1 / ( 2 * sampleCount + 1 ); +// #include curverenderer01-pass2-vbaa_poles_bilin1.glsl +// #include curverenderer01-pass2-vbaa_poles_propweight1.glsl +// #include curverenderer01-pass2-vbaa_wholeedge_propweight1.glsl +// #include curverenderer01-pass2-vbaa_wholeedge_equalweight.glsl +// #include curverenderer01-pass2-vbaa_fxaa3.glsl - vec4 t = vec4(0); - // vec4 t = texture2D(gcu_TextureUnit, gcv_TexCoord)* sample_weight; // center: +1 - - // SampleCount 2 - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-0.5, -0.5)))*sample_weight; // NW - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-0.5, 0.5)))*sample_weight; // SW - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 0.5, 0.5)))*sample_weight; // SE - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 0.5, -0.5)))*sample_weight; // NE - if( sampleCount > 2 ) { - // SampleCount 4 - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-1.5, -1.5)))*sample_weight; - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-1.5, 1.5)))*sample_weight; - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 1.5, 1.5)))*sample_weight; - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 1.5, -1.5)))*sample_weight; - if( sampleCount > 4 ) { - // SampleCount 8 - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-2.5, -2.5)))*sample_weight; - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-2.5, 2.5)))*sample_weight; - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 2.5, 2.5)))*sample_weight; - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 2.5, -2.5)))*sample_weight; - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-3.5, -3.5)))*sample_weight; - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2(-3.5, 3.5)))*sample_weight; - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 3.5, 3.5)))*sample_weight; - t += texture2D(gcu_TextureUnit, gcv_TexCoord + psize*(vec2( 3.5, -3.5)))*sample_weight; - } - } - #if 0 - if(t.w == 0.0){ - discard; // discard freezes NV tegra2 compiler - } - #endif - - c = t.rgb; - alpha = gcu_Alpha * t.a; } else { - // pass-1 - vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); - - if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) { - // pass-1: Lines - c = gcu_ColorStatic.rgb; - alpha = 1.0; - } else if ( gcv_TexCoord.x > 0.0 && (rtex.y > 0.0 || rtex.x == 1.0) ) { - // pass-1: curves - rtex.y -= 0.1; - - if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { - // discard; // freezes NV tegra2 compiler - c = zero3; - 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)); +#include curverenderer01-pass1-curve-simple.glsl - c = gcu_ColorStatic.rgb; - alpha = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); - } - } else { - c = zero3; - alpha = 0.0; - } } - mgl_FragColor = vec4(c, alpha); + mgl_FragColor = vec4(color, alpha); } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-lineAA.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-lineAA.glsl new file mode 100644 index 000000000..16dda5947 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-lineAA.glsl @@ -0,0 +1,20 @@ + + // if( gcv_TexCoord.x == 10.0 && gcv_TexCoord.y == 10.0 ) { + if( gcv_TexCoord.z > 0.0 ) { + // pass-1: AA Lines + #if 1 + // const float dist = sqrt( gcv_TexCoord.x*gcv_TexCoord.x + gcv_TexCoord.y*gcv_TexCoord.y ); // magnitude + const float dist = sqrt( gcv_TexCoord.y*gcv_TexCoord.y ); // magnitude + // const float a = 1.0 - smoothstep (gcv_TexCoord.y-gcv_TexCoord.z, gcv_TexCoord.y, dist); + const float r = gcv_TexCoord.x/3.0; + const float wa = gcv_TexCoord.x+r; + const float waHalf = wa/2.0; + const float a = 1.0 - smoothstep (waHalf-2.0*r, waHalf, dist); + color = vec3(0, 0, 1.0); // gcu_ColorStatic.rgb; + alpha = a; + #else + color = vec3(0, 0, 1.0); + alpha = 1.0; + #endif + } else + diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-simple.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-simple.glsl new file mode 100644 index 000000000..df53db686 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-simple.glsl @@ -0,0 +1,21 @@ + + if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) { + // pass-1: Lines + // color = vec3(0, 1.0, 0); + color = gcu_ColorStatic.rgb; + alpha = 1.0; + } else { + // pass-1: curves + const vec2 rtex = vec2( abs(gcv_TexCoord.x), abs(gcv_TexCoord.y) - 0.1 ); + + const vec2 dtx = dFdx(rtex); + const vec2 dty = dFdy(rtex); + + const vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x)); + const float position = rtex.y - (rtex.x * (1.0 - rtex.x)); + + // color = vec3(1.0, 0, 0); + color = gcu_ColorStatic.rgb; + alpha = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); + } + diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-simple.orig.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-simple.orig.glsl new file mode 100644 index 000000000..325ddee01 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-simple.orig.glsl @@ -0,0 +1,32 @@ + + vec2 rtex = vec2( abs(gcv_TexCoord.x), abs(gcv_TexCoord.y) ); + + if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) { + // pass-1: Lines + color = gcu_ColorStatic.rgb; + alpha = 1.0; + } else if ( gcv_TexCoord.x > 0.0 && ( rtex.y > 0.0 || rtex.x == 1.0 ) ) { + // pass-1: curves + rtex.y -= 0.1; + + if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { + // discard; // freezes NV tegra2 compiler + color = zero3; + alpha = 0.0; + } else { + rtex.y = max(rtex.y, 0.0); // always >= 0 + + const vec2 dtx = dFdx(rtex); + const vec2 dty = dFdy(rtex); + + const vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x)); + const float position = rtex.y - (rtex.x * (1.0 - rtex.x)); + + color = gcu_ColorStatic.rgb; + alpha = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); + } + } else { + color = zero3; + alpha = 0.0; + } + diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-weight.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-weight.glsl new file mode 100644 index 000000000..a489949b4 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-weight.glsl @@ -0,0 +1,25 @@ + + if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) { + // pass-1: Lines + color = gcu_ColorStatic.rgb; + alpha = 1.0; + } else { + // pass-1: curves + const vec2 rtex = vec2( abs(gcv_TexCoord.x), abs(gcv_TexCoord.y) - 0.1 ); + + const vec2 dtx = dFdx(rtex); + const vec2 dty = dFdy(rtex); + + const float w = gcu_Weight; + const float pd = ((2.0 - (2.0*w))*rtex.x*rtex.x) + 2.0*(w-1.0)*rtex.x + 1.0; + const float position = rtex.y - ((w*rtex.x*(1.0 - rtex.x))/pd); + + const float aph = 2.0 - 2.0*w; + + const float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0); + const 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)); + + color = gcu_ColorStatic.rgb; + alpha = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); + } + diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_fxaa3.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_fxaa3.glsl new file mode 100644 index 000000000..d27d9df12 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_fxaa3.glsl @@ -0,0 +1,56 @@ + + // Pass-2: AA on Texture + // Note: gcv_TexCoord is in center of sample pixels. + + if( gcu_TextureSize.z < 4 ) { + // FXAA-2 + const float FXAA_REDUCE_MIN = (1.0/128.0); + const float FXAA_REDUCE_MUL = (1.0/8.0); + const float FXAA_SPAN_MAX = 8.0; + + const float sampleCount = gcu_TextureSize.z; + + const vec2 texCoord = gcv_TexCoord.st; + const float poff = 1.0; + const vec2 psize = 1.0 / texCoord; // pixel size + + const vec3 rgbNW = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-poff, -poff))).rgb; + const vec3 rgbSW = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-poff, poff))).rgb; + const vec3 rgbSE = texture2D(gcu_TextureUnit, texCoord + psize*(vec2( poff, poff))).rgb; + const vec3 rgbNE = texture2D(gcu_TextureUnit, texCoord + psize*(vec2( poff, -poff))).rgb; + const vec4 rgbM = texture2D(gcu_TextureUnit, texCoord); + + const vec3 luma = vec3(0.299, 0.587, 0.114); + const float lumaNW = dot(rgbNW, luma); + const float lumaNE = dot(rgbNE, luma); + const float lumaSW = dot(rgbSW, luma); + const float lumaSE = dot(rgbSE, luma); + const float lumaM = dot(rgbM.rgb, luma); + const float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); + const float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); + vec2 dir; + dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); + dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); + const float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL),FXAA_REDUCE_MIN); + const float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce); + dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX), + max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),dir * rcpDirMin) ) * psize; + + + const vec3 rgbA = 0.5 * ( texture2D(gcu_TextureUnit, texCoord + dir * (1.0/3.0 - 0.5)).rgb + + texture2D(gcu_TextureUnit, texCoord + dir * (2.0/3.0 - 0.5)).rgb ); + const vec3 rgbB = rgbA * 0.5 + 0.25 * ( texture2D(gcu_TextureUnit, texCoord + (dir * - 0.5)).rgb + + texture2D(gcu_TextureUnit, texCoord + (dir * 0.5)).rgb ); + const float lumaB = dot(rgbB, luma); + if((lumaB < lumaMin) || (lumaB > lumaMax)) { + color = rgbA; + } else { + color = rgbB; + } + alpha = gcu_Alpha * rgbM.a; // mix(0.0, gcu_Alpha, rgbM.a); // t.a one of [ 0.0, 1.0 ] + } else { + +#include curverenderer01-pass2-vbaa_poles_equalweight.glsl + + } + diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_poles_bilin1.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_poles_bilin1.glsl new file mode 100644 index 000000000..f582ee8a2 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_poles_bilin1.glsl @@ -0,0 +1,92 @@ + // Pass-2: AA on Texture + // Note: gcv_TexCoord is in center of sample pixels. + + const vec2 texCoord = gcv_TexCoord.st; + + const float sampleCount = gcu_TextureSize.z; + const vec2 tsize = gcu_TextureSize.xy; // tex size + const vec2 psize = 1.0 / gcu_TextureSize.xy; // pixel size + + // mix(x,y,a): x*(1-a) + y*a + // + // bilinear filtering includes 2 mix: + // + // pix1 = tex[x0][y0] * ( 1 - u_ratio ) + tex[x1][y0] * u_ratio + // pix2 = tex[x0][y1] * ( 1 - u_ratio ) + tex[x1][y1] * u_ratio + // fin = pix1 * ( 1 - v_ratio ) + pix2 * v_ratio + // + // so we can use the build in mix function for these 2 computations ;-) + // + const vec2 uv_ratio = fract(texCoord*tsize); // texCoord*tsize - floor(texCoord*tsize); + + // Just poles (NW, SW, ..) + const float pixelCount = 2 * sampleCount; + + // sampleCount [0, 1, 3, 5, 7] are undefined! + const float layerCount = ( sampleCount / 2.0 ); + + // sum of all integer [layerCount .. 1] -> Gauss + const float denom = ( layerCount / 2.0 ) * ( layerCount + 1.0 ); + + vec4 t, p1, p2, p3, p4; + + // Layer-1: SampleCount 2 -> 4x + p1 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, -0.5))); // NW + p2 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, 0.5))); // SW + p3 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, 0.5))); // SE + p4 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, -0.5))); // NE + + p1 = mix( p1, p4, uv_ratio.x); + p2 = mix( p2, p3, uv_ratio.x); + t = mix ( p1, p2, uv_ratio.y ); + + t *= (layerCount - 0.0) / ( denom ); // weight layer 1 + + if( sampleCount > 2 ) { + // Layer-2: SampleCount 4 -> +4x = 8p + p1 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, -1.5))); // NW + p2 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, 1.5))); // SW + p3 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, 1.5))); // SE + p4 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, -1.5))); // NE + + p1 = mix( p1, p4, uv_ratio.x); + p2 = mix( p2, p3, uv_ratio.x); + p3 = mix ( p1, p2, uv_ratio.y ); + t += p3 * (layerCount - 1) / ( denom ); // weight layer 2 + + if( sampleCount > 4 ) { + // Layer-3: SampleCount 6 -> +4 = 12p + p1 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, -2.5))); // NW + p2 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, 2.5))); // SW + p3 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, 2.5))); // SE + p4 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, -2.5))); // NE + + p1 = mix( p1, p4, uv_ratio.x); + p2 = mix( p2, p3, uv_ratio.x); + p3 = mix ( p1, p2, uv_ratio.y ); + t += p3 * (layerCount - 2) / ( denom ); // weight layer 3 + + if( sampleCount > 6 ) { + // Layer-4: SampleCount 8 -> +4 = 16p + p1 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, -3.5))); // NW + p2 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, 3.5))); // SW + p3 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, 3.5))); // SE + p4 = texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, -3.5))); // NE + + p1 = mix( p1, p4, uv_ratio.x); + p2 = mix( p2, p3, uv_ratio.x); + p3 = mix ( p1, p2, uv_ratio.y ); + + t += p3 * (layerCount - 3) / ( denom ); // weight layer 4 + } + } + } + + #if 0 + if(t.w == 0.0){ + discard; // discard freezes NV tegra2 compiler + } + #endif + + color = t.rgb; + alpha = gcu_Alpha * t.a; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_poles_equalweight.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_poles_equalweight.glsl new file mode 100644 index 000000000..d1efb1206 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_poles_equalweight.glsl @@ -0,0 +1,50 @@ + + // Pass-2: AA on Texture + // Note: gcv_TexCoord is in center of sample pixels. + + const float sampleCount = gcu_TextureSize.z; + const vec2 psize = 1.0 / gcu_TextureSize.xy; // pixel size + + // Just poles (NW, SW, ..) + const float sample_weight = 1 / ( 2 * sampleCount ); + + const vec2 texCoord = gcv_TexCoord.st; + + vec4 t = vec4(0); + + // SampleCount 2 -> 4x + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, -0.5)))*sample_weight; // NW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, 0.5)))*sample_weight; // SW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, 0.5)))*sample_weight; // SE + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, -0.5)))*sample_weight; // NE + if( sampleCount > 2 ) { + // SampleCount 4 -> +4 = 8p + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, -1.5)))*sample_weight; // NW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, 1.5)))*sample_weight; // SW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, 1.5)))*sample_weight; // SE + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, -1.5)))*sample_weight; // NE + + if( sampleCount > 4 ) { + // SampleCount 6 -> +4 = 12p + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, -2.5)))*sample_weight; // NW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, 2.5)))*sample_weight; // SW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, 2.5)))*sample_weight; // SE + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, -2.5)))*sample_weight; // NE + if( sampleCount > 6 ) { + // SampleCount 8 -> +4 = 16p + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, -3.5)))*sample_weight; // NW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, 3.5)))*sample_weight; // SW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, 3.5)))*sample_weight; // SE + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, -3.5)))*sample_weight; // NE + } + } + } + #if 0 + if(t.w == 0.0){ + discard; // discard freezes NV tegra2 compiler + } + #endif + + color = t.rgb; + alpha = gcu_Alpha * t.a; + diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_poles_propweight1.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_poles_propweight1.glsl new file mode 100644 index 000000000..3459e3da6 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_poles_propweight1.glsl @@ -0,0 +1,66 @@ + // Pass-2: AA on Texture + // Note: gcv_TexCoord is in center of sample pixels. + + const float sampleCount = gcu_TextureSize.z; + const vec2 psize = 1.0 / gcu_TextureSize.xy; // pixel size + + // Just poles (NW, SW, ..) + const float pixelCount = 2 * sampleCount; + + // sampleCount [0, 1, 3, 5, 7] are undefined! + const float layerCount = ( sampleCount / 2.0 ); + + // sum of all integer [layerCount .. 1] -> Gauss + const float denom = ( layerCount / 2.0 ) * ( layerCount + 1.0 ); + + const vec2 texCoord = gcv_TexCoord.st; + + vec4 t = vec4(0); + + // Layer-1: SampleCount 2 -> 4x + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, -0.5))); // NW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, 0.5))); // SW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, 0.5))); // SE + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, -0.5))); // NE + + t *= (layerCount - 0.0) / ( denom * 4.0 ); // weight layer 1 + + if( sampleCount > 2 ) { + // Layer-2: SampleCount 4 -> +4x = 8p + vec4 tn = vec4(0); + tn = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, -1.5))); // NW + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, 1.5))); // SW + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, 1.5))); // SE + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, -1.5))); // NE + + t += tn * (layerCount - 1) / ( denom * 4.0 ); // weight layer 2 + + if( sampleCount > 4 ) { + // Layer-3: SampleCount 6 -> +4 = 12p + tn = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, -2.5))); // NW + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, 2.5))); // SW + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, 2.5))); // SE + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, -2.5))); // NE + + t += tn * (layerCount - 2) / ( denom * 4.0 ); // weight layer 3 + + if( sampleCount > 6 ) { + // Layer-4: SampleCount 8 -> +4 = 16p + tn = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, -3.5))); // NW + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, 3.5))); // SW + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, 3.5))); // SE + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, -3.5))); // NE + + t += tn * (layerCount - 3) / ( denom * 4.0 ); // weight layer 4 + } + } + } + + #if 0 + if(t.w == 0.0){ + discard; // discard freezes NV tegra2 compiler + } + #endif + + color = t.rgb; + alpha = gcu_Alpha * t.a; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_wholeedge_equalweight.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_wholeedge_equalweight.glsl new file mode 100644 index 000000000..3c787b46e --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_wholeedge_equalweight.glsl @@ -0,0 +1,98 @@ + // Pass-2: AA on Texture + // Note: gcv_TexCoord is in center of sample pixels. + + const float sampleCount = gcu_TextureSize.z; + const vec2 psize = 1.0 / gcu_TextureSize.xy; // pixel size + + // Not only the poles (NW, SW, ..) but the whole edge! + const float sample_weight = 1 / ( sampleCount * sampleCount ); + + // const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025); + + const vec2 texCoord = gcv_TexCoord.st; + + vec4 t = vec4(0); + + // SampleCount 2 -> 4x + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, -0.5)))*sample_weight; // NW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, 0.5)))*sample_weight; // SW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, 0.5)))*sample_weight; // SE + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, -0.5)))*sample_weight; // NE + if( sampleCount > 2 ) { + // SampleCount 4 -> +12x = 16p + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, -1.5)))*sample_weight; // NW -> SW Edge + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, -0.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, 0.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, 1.5)))*sample_weight; // SW -> SE Edge + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, 1.5)))*sample_weight; // + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, 1.5)))*sample_weight; // + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, 1.5)))*sample_weight; // SE -> NE Edge + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, 0.5)))*sample_weight; // + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, -0.5)))*sample_weight; // + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, -1.5)))*sample_weight; // NE -> NW Edge + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, -1.5)))*sample_weight; // + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, -1.5)))*sample_weight; // NW - 1 (closed) + + if( sampleCount > 4 ) { + // SampleCount 6 -> +20x = 36p + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, -2.5)))*sample_weight; // NW -> SW Edge + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, -1.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, -0.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, 0.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, 1.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, 2.5)))*sample_weight; // SW -> SE Edge + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, 2.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, 2.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, 2.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, 2.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, 2.5)))*sample_weight; // SE -> NE Edge + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, 1.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, 0.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, -0.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, -1.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, -2.5)))*sample_weight; // NE -> NW Edge + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, -2.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, -2.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, -2.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, -2.5)))*sample_weight; // NW - 1 (closed) + if( sampleCount > 6 ) { + // SampleCount 8 -> +28x = 64p + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, -3.5)))*sample_weight; // NW -> SW Edge + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, -2.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, -1.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, -0.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, 0.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, 1.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, 2.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, 3.5)))*sample_weight; // SW -> SE Edge + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, 3.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, 3.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, 3.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, 3.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, 3.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, 3.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, 3.5)))*sample_weight; // SE -> NE Edge + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, 2.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, 1.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, 0.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, -0.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, -1.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, -2.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, -3.5)))*sample_weight; // NE -> NW Edge + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, -3.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, -3.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, -3.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, -3.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, -3.5)))*sample_weight; + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, -3.5)))*sample_weight; // NW - 1 (closed) + } + } + } + #if 0 + if(t.w == 0.0){ + discard; // discard freezes NV tegra2 compiler + } + #endif + + color = t.rgb; + alpha = gcu_Alpha * t.a; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_wholeedge_propweight1.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_wholeedge_propweight1.glsl new file mode 100644 index 000000000..76227eba3 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-vbaa_wholeedge_propweight1.glsl @@ -0,0 +1,114 @@ + // Pass-2: AA on Texture + // Note: gcv_TexCoord is in center of sample pixels. + + const float sampleCount = gcu_TextureSize.z; + const vec2 psize = 1.0 / gcu_TextureSize.xy; // pixel size + + // Not only the poles (NW, SW, ..) but the whole edge! + const float pixelCount = sampleCount * sampleCount; + + // sampleCount [0, 1, 3, 5, 7] are undefined! + const float layerCount = ( sampleCount / 2.0 ); + + // sum of all integer [layerCount .. 1] -> Gauss + const float denom = ( layerCount / 2.0 ) * ( layerCount + 1.0 ); + + const vec2 texCoord = gcv_TexCoord.st; + + vec4 t = vec4(0); + + // Layer-1: SampleCount 2 -> 4x + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, -0.5))); // NW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, 0.5))); // SW + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, 0.5))); // SE + t += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, -0.5))); // NE + + t *= (layerCount - 0.0) / ( denom * 4.0 ); // weight layer 1 + + if( sampleCount > 2 ) { + // Layer-2: SampleCount 4 -> +12x = 16p + vec4 tn = vec4(0); + tn = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, -1.5))); // NW -> SW Edge + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, -0.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, 0.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, 1.5))); // SW -> SE Edge + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, 1.5))); // + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, 1.5))); // + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, 1.5))); // SE -> NE Edge + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, 0.5))); // + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, -0.5))); // + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, -1.5))); // NE -> NW Edge + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, -1.5))); // + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, -1.5))); // NW - 1 (closed) + + t += tn * (layerCount - 1) / ( denom * 12.0 ); // weight layer 2 + + if( sampleCount > 4 ) { + // Layer-3: SampleCount 6 -> +20x = 36p + tn = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, -2.5))); // NW -> SW Edge + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, -1.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, -0.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, 0.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, 1.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, 2.5))); // SW -> SE Edge + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, 2.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, 2.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, 2.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, 2.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, 2.5))); // SE -> NE Edge + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, 1.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, 0.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, -0.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, -1.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, -2.5))); // NE -> NW Edge + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, -2.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, -2.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, -2.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, -2.5))); // NW - 1 (closed) + + t += tn * (layerCount - 2) / ( denom * 20.0 ); // weight layer 3 + + if( sampleCount > 6 ) { + // Layer-4: SampleCount 8 -> +28x = 64p + tn = texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, -3.5))); // NW -> SW Edge + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, -2.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, -1.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, -0.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, 0.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, 1.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, 2.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-3.5, 3.5))); // SW -> SE Edge + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, 3.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, 3.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, 3.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, 3.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, 3.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, 3.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, 3.5))); // SE -> NE Edge + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, 2.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, 1.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, 0.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, -0.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, -1.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, -2.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 3.5, -3.5))); // NE -> NW Edge + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 2.5, -3.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 1.5, -3.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2( 0.5, -3.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-0.5, -3.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-1.5, -3.5))); + tn += texture2D(gcu_TextureUnit, texCoord + psize*(vec2(-2.5, -3.5))); // NW - 1 (closed) + + t += tn * (layerCount - 3) / ( denom * 28.0 ); // weight layer 4 + } + } + } + + #if 0 + if(t.w == 0.0){ + discard; // discard freezes NV tegra2 compiler + } + #endif + + color = t.rgb; + alpha = gcu_Alpha * t.a; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp index 4b5c8b1e2..b3c9ebd35 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp @@ -11,7 +11,13 @@ 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; + // gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * vec4(gca_Vertices, 1); + gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * gca_Vertices; + if( gcv_TexCoord.x <= -10.0 ) { + // const vec4 tc = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * vec4(gca_TexCoords.xy, gca_Vertices.z, 1); + // gcv_TexCoord = vec3(tc.xy, gca_TexCoords.z); + gcv_TexCoord = gca_TexCoords; + } else { + gcv_TexCoord = gca_TexCoords; + } } 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..17f118bc8 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl @@ -3,7 +3,7 @@ #define varyings_glsl //varying vec4 gcv_FrontColor; -varying vec2 gcv_TexCoord; +varying vec3 gcv_TexCoord; #endif // varyings_glsl |