summaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-30 15:02:48 +0200
committerSven Gothel <[email protected]>2011-09-30 15:02:48 +0200
commitdc0cf65dd75079d8f57eb2431c0fe1235fff27ad (patch)
treee5d576c54c2d6ffdeb31a4dccfde044281bd8954 /src/jogl
parentcdc99f97fde9211b7f73d8592d3d64c6ec78898a (diff)
Graph GLSL: Use global precicision settings enhancing readability
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl10
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/consts.glsl4
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.fp30
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02-xxx.fp36
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/precision.glsl12
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl18
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl4
7 files changed, 54 insertions, 60 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 8240fc661..c8c076ba1 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 GRAPHP vec3 gca_Vertices;
-attribute GRAPHP vec4 gca_Vertices;
-attribute GRAPHP vec2 gca_TexCoords;
-//attribute GRAPHP vec4 gca_Colors;
-//attribute GRAPHP vec3 gca_Normals;
+// attribute vec3 gca_Vertices;
+attribute vec4 gca_Vertices;
+attribute vec2 gca_TexCoords;
+//attribute vec4 gca_Colors;
+//attribute vec3 gca_Normals;
#endif // attributes_glsl
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/consts.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/consts.glsl
index 4cb41c903..c399f0f57 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/consts.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/consts.glsl
@@ -4,7 +4,7 @@
#include precision.glsl
-const LOWP int MAX_TEXTURE_UNITS = 8; // <= gl_MaxTextureImageUnits
-// const LOWP int MAX_LIGHTS = 8;
+const int MAX_TEXTURE_UNITS = 8; // <= gl_MaxTextureImageUnits
+// const int MAX_LIGHTS = 8;
#endif // consts_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 52cff807c..af980da10 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,31 +3,31 @@
#include uniforms.glsl
#include varyings.glsl
-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);
+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)
{
- GRAPHP vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
- GRAPHP vec3 c = gcu_ColorStatic.rgb;
+ vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
+ vec3 c = gcu_ColorStatic.rgb;
- GRAPHP float alpha = 0.0;
+ 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)) {
- GRAPHP vec2 dfx = dFdx(gcv_TexCoord);
- GRAPHP vec2 dfy = dFdy(gcv_TexCoord);
+ vec2 dfx = dFdx(gcv_TexCoord);
+ vec2 dfy = dFdy(gcv_TexCoord);
- GRAPHP vec2 size;
+ vec2 size;
//#if __VERSION__ < 130
size = 1.0/gcu_TextureSize;
//#else
// size = 1.0/textureSize(gcu_TextureUnit,0);
//#endif
rtex -= 5.0;
- GRAPHP vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18;
+ 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;
@@ -58,8 +58,8 @@ void main (void)
}
///////////////////////////////////////////////////////////
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);
+ vec2 dtx = dFdx(rtex);
+ vec2 dty = dFdy(rtex);
rtex.y -= 0.1;
@@ -71,11 +71,11 @@ void main (void)
}
}
- 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));
+ 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 float a = (0.5 - d * sign(gcv_TexCoord.y));
+ float a = (0.5 - d * sign(gcv_TexCoord.y));
if (a >= 1.0) {
alpha = gcu_Alpha;
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 3ba4c8d40..4f66cb41e 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 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);
+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)
{
- GRAPHP vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
- GRAPHP vec3 c = gcu_ColorStatic.rgb;
+ vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
+ vec3 c = gcu_ColorStatic.rgb;
- GRAPHP float alpha = 0.0;
+ 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)) {
- GRAPHP vec2 dfx = dFdx(gcv_TexCoord);
- GRAPHP vec2 dfy = dFdy(gcv_TexCoord);
+ vec2 dfx = dFdx(gcv_TexCoord);
+ vec2 dfy = dFdy(gcv_TexCoord);
// vec2 size;
//#if __VERSION__ < 130
@@ -27,7 +27,7 @@ void main (void)
// size = 1.0/textureSize(gcu_TextureUnit,0);
//#endif
rtex -= 5.0;
- GRAPHP vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18;
+ 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;
@@ -67,20 +67,20 @@ void main (void)
rtex.y = 0.0;
}
}
- GRAPHP vec2 dtx = dFdx(rtex);
- GRAPHP vec2 dty = dFdy(rtex);
+ vec2 dtx = dFdx(rtex);
+ vec2 dty = dFdy(rtex);
- 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 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 aph = 2.0 - 2.0*w;
+ float aph = 2.0 - 2.0*w;
- 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 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 d = position/(length(f));
- GRAPHP float a = (0.5 - d * sign(gcv_TexCoord.y));
+ 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) {
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 f9ed48cb9..9924bd790 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/precision.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/precision.glsl
@@ -2,15 +2,9 @@
#define precision_glsl
#ifdef GL_ES
- #define MEDIUMP mediump
- #define HIGHP highp
- #define LOWP lowp
- #define GRAPHP mediump
-#else
- #define MEDIUMP
- #define HIGHP
- #define LOWP
- #define GRAPHP
+ precision mediump float;
+ precision mediump int;
+ precision mediump sampler2D;
#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 0f0cb4007..5d1177310 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl
@@ -6,19 +6,19 @@
// #include consts.glsl
-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 mat4 gcu_PMVMatrix[3]; // P, Mv, and Mvi
+uniform vec3 gcu_ColorStatic;
+uniform float gcu_Alpha;
+uniform float gcu_Weight;
uniform sampler2D gcu_TextureUnit;
// #if __VERSION__ < 130
-uniform GRAPHP vec2 gcu_TextureSize;
+uniform vec2 gcu_TextureSize;
// #endif
-// 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;
+// uniform mat3 gcu_NormalMatrix; // transpose(inverse(ModelView)).3x3
+// uniform int gcu_ColorEnabled;
+// uniform int gcu_TexCoordEnabled[MAX_TEXTURE_UNITS];
+// uniform int gcu_CullFace;
#endif // uniforms_glsl
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 19d6640e6..adb40ad11 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 GRAPHP vec4 gcv_FrontColor;
-varying GRAPHP vec2 gcv_TexCoord;
+//varying vec4 gcv_FrontColor;
+varying vec2 gcv_TexCoord;
#endif // varyings_glsl