summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/curve/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-07-31 20:43:41 +0200
committerSven Gothel <[email protected]>2011-07-31 20:43:41 +0200
commit355d1da079f9635bba3441482766f100b8c8e7ce (patch)
tree3649fa39e1bdeabf04e296a17e195a0f59a8a5e9 /src/jogl/classes/jogamp/graph/curve/opengl
parent9f59125e322b80f62b791ae9af3ee6405307cbde (diff)
Graph Shader: def. GRAPHP to easily change precision, set to mediump; Add precision for all vars.
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve/opengl')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl10
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.fp46
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02-xxx.fp54
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/precision.glsl2
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl14
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl4
6 files changed, 64 insertions, 66 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 c9a242573..8240fc661 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl
@@ -4,10 +4,10 @@
#include precision.glsl
-// attribute HIGHP vec3 gca_Vertices;
-attribute HIGHP vec4 gca_Vertices;
-attribute HIGHP vec2 gca_TexCoords;
-//attribute HIGHP vec4 gca_Colors;
-//attribute HIGHP vec3 gca_Normals;
+// attribute GRAPHP vec3 gca_Vertices;
+attribute GRAPHP vec4 gca_Vertices;
+attribute GRAPHP vec2 gca_TexCoords;
+//attribute GRAPHP vec4 gca_Colors;
+//attribute GRAPHP vec3 gca_Normals;
#endif // attributes_glsl
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.fp
index e50aea04d..300164466 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.fp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.fp
@@ -3,24 +3,24 @@
#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);
+const GRAPHP vec3 b_color = vec3(1.0, 1.0, 1.0);
+const GRAPHP 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;
+ GRAPHP vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
+ GRAPHP vec3 c = gcu_ColorStatic.rgb;
- float alpha = 0.0;
+ GRAPHP float alpha = 0.0;
- if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 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);
+ else if((gcv_TexCoord.x >= 5.0)) {
+ GRAPHP vec2 dfx = dFdx(gcv_TexCoord);
+ GRAPHP vec2 dfy = dFdy(gcv_TexCoord);
- vec2 size;
+ GRAPHP vec2 size;
//#if __VERSION__ < 130
size = 1.0/gcu_TextureSize;
//#else
@@ -57,35 +57,33 @@ void main (void)
alpha = gcu_Alpha * t.w;
}
///////////////////////////////////////////////////////////
- else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)){
- vec2 dtx = dFdx(rtex);
- vec2 dty = dFdy(rtex);
+ else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) {
+ GRAPHP vec2 dtx = dFdx(rtex);
+ GRAPHP vec2 dty = dFdy(rtex);
rtex.y -= 0.1;
if(rtex.y < 0.0) {
- if(gcv_TexCoord.y < 0.0)
+ if(gcv_TexCoord.y < 0.0) {
discard;
- else{
+ } 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));
+ GRAPHP vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x));
+ GRAPHP float position = rtex.y - (rtex.x * (1.0 - rtex.x));
+ GRAPHP float d = position/(length(f));
- float a = (0.5 - d * sign(gcv_TexCoord.y));
+ GRAPHP float a = (0.5 - d * sign(gcv_TexCoord.y));
if (a >= 1.0) {
alpha = gcu_Alpha;
- }
- else if (a <= 0.0) {
+ } else if (a <= 0.0) {
discard;
- }
- else {
+ } else {
alpha = gcu_Alpha * a;
- mix(b_color,gcu_ColorStatic.rgb, a);
+ // ?? mix(b_color,gcu_ColorStatic.rgb, a);
}
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02-xxx.fp
index c6a3c56c8..22936c3fb 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02-xxx.fp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02-xxx.fp
@@ -3,22 +3,22 @@
#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);
+const GRAPHP vec3 b_color = vec3(0.0, 0.0, 0.0);
+const GRAPHP 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;
+ GRAPHP vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
+ GRAPHP vec3 c = gcu_ColorStatic.rgb;
- float alpha = 0.0;
+ GRAPHP float alpha = 0.0;
- if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 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);
+ else if((gcv_TexCoord.x >= 5.0)) {
+ GRAPHP vec2 dfx = dFdx(gcv_TexCoord);
+ GRAPHP vec2 dfy = dFdy(gcv_TexCoord);
// vec2 size;
//#if __VERSION__ < 130
@@ -49,7 +49,7 @@ void main (void)
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){
+ if(t.w == 0.0) {
discard;
}
@@ -57,37 +57,35 @@ void main (void)
alpha = gcu_Alpha * t.w;
}
///////////////////////////////////////////////////////////
- else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)){
+ 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)
+ if(gcv_TexCoord.y < 0.0) {
discard;
- else{
+ } else {
rtex.y = 0.0;
}
}
- vec2 dtx = dFdx(rtex);
- vec2 dty = dFdy(rtex);
+ GRAPHP vec2 dtx = dFdx(rtex);
+ GRAPHP 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);
+ GRAPHP float w = gcu_Weight;
+ GRAPHP float pd = ((2.0 - (2.0*w))*rtex.x*rtex.x) + 2.0*(w-1.0)*rtex.x + 1.0;
+ GRAPHP float position = rtex.y - ((w*rtex.x*(1.0 - rtex.x))/pd);
- float aph = 2.0 - 2.0*w;
+ GRAPHP 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));
+ GRAPHP float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0);
+ GRAPHP 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));
- float d = position/(length(f));
- float a = (0.5 - d * sign(gcv_TexCoord.y));
- if (a >= 1.0){
+ GRAPHP float d = position/(length(f));
+ GRAPHP float a = (0.5 - d * sign(gcv_TexCoord.y));
+ if (a >= 1.0) {
alpha = gcu_Alpha;
- }
- else if (a <= 0.0) {
+ } else if (a <= 0.0) {
discard;
- }
- else {
+ } else {
alpha = gcu_Alpha*a;
}
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/precision.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/precision.glsl
index 1ac4ed8e9..f9ed48cb9 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/precision.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/precision.glsl
@@ -5,10 +5,12 @@
#define MEDIUMP mediump
#define HIGHP highp
#define LOWP lowp
+ #define GRAPHP mediump
#else
#define MEDIUMP
#define HIGHP
#define LOWP
+ #define GRAPHP
#endif
#endif // precision_glsl
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 6b3d846a3..0f0cb4007 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl
@@ -6,17 +6,17 @@
// #include consts.glsl
-uniform HIGHP mat4 gcu_PMVMatrix[3]; // P, Mv, and Mvi
-uniform HIGHP vec3 gcu_ColorStatic;
-uniform HIGHP float gcu_Alpha;
-uniform HIGHP float gcu_Weight;
-uniform sampler2D gcu_TextureUnit;
+uniform GRAPHP mat4 gcu_PMVMatrix[3]; // P, Mv, and Mvi
+uniform GRAPHP vec3 gcu_ColorStatic;
+uniform GRAPHP float gcu_Alpha;
+uniform GRAPHP float gcu_Weight;
+uniform sampler2D gcu_TextureUnit;
// #if __VERSION__ < 130
- uniform HIGHP vec2 gcu_TextureSize;
+uniform GRAPHP vec2 gcu_TextureSize;
// #endif
-// uniform HIGHP mat3 gcu_NormalMatrix; // transpose(inverse(ModelView)).3x3
+// uniform GRAPHP mat3 gcu_NormalMatrix; // transpose(inverse(ModelView)).3x3
// uniform LOWP int gcu_ColorEnabled;
// uniform LOWP int gcu_TexCoordEnabled[MAX_TEXTURE_UNITS];
// uniform LOWP int gcu_CullFace;
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 0b821524c..19d6640e6 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl
@@ -6,8 +6,8 @@
#include consts.glsl
-//varying vec4 gcv_FrontColor;
-varying vec2 gcv_TexCoord;
+//varying GRAPHP vec4 gcv_FrontColor;
+varying GRAPHP vec2 gcv_TexCoord;
#endif // varyings_glsl