commit 9af288b997c3dc835d8fed6ca7f6580324063b9d
parent d1e663b360fae7094a973081b2e1a14d0e5dd0a9
Author: Brian Swetland <swetland@frotz.net>
Date: Wed, 4 Sep 2013 05:47:14 -0700
fix for mesa 9.2
GLSL 1.40 does not support uniform block instance names...
Diffstat:
3 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/common/shared.h b/common/shared.h
@@ -52,21 +52,21 @@ static const char *shader_globals =
"#define A_NORMAL 1\n"
"#define A_TEXCOORD 2\n"
"layout(std140) uniform block0 {\n"
-" mat4 Ortho;\n"
-" vec4 OrthoSize;\n"
-" vec4 LightColor;\n"
-" vec4 LightPosition;\n"
-"} SCN;\n"
+" mat4 uOrtho;\n"
+" vec4 uOrthoSize;\n"
+" vec4 uLightColor;\n"
+" vec4 uLightPosition;\n"
+"};\n"
"layout(std140) uniform block1 {\n"
-" mat4 MVP;\n"
-" mat4 MV;\n"
-"} OBJ;\n"
+" mat4 uMVP;\n"
+" mat4 uMV;\n"
+"};\n"
"layout(std140) uniform block2 {\n"
-" vec4 Ambient;\n"
-" vec4 Diffuse;\n"
-" vec4 Specular;\n"
-" float Shininess;\n"
-"} MAT;\n"
+" vec4 uAmbient;\n"
+" vec4 uDiffuse;\n"
+" vec4 uSpecular;\n"
+" float uShininess;\n"
+"};\n"
;
#endif
diff --git a/test/assets/flat.glsl b/test/assets/flat.glsl
@@ -6,7 +6,7 @@
layout (location = A_POSITION) in vec4 aPosition;
void main() {
- gl_Position = OBJ.MVP * aPosition;
+ gl_Position = uMVP * aPosition;
}
-- fragment
diff --git a/test/assets/simple.glsl b/test/assets/simple.glsl
@@ -15,10 +15,10 @@ out vec3 vPosition; // eye space
out vec3 vNormal; // eye space
void main() {
- vPosition = (OBJ.MV * aPosition).xyz;
- vNormal = (OBJ.MV * vec4(aNormal, 0.0)).xyz;
+ vPosition = (uMV * aPosition).xyz;
+ vNormal = (uMV * vec4(aNormal, 0.0)).xyz;
vTexCoord = aTexCoord;
- gl_Position = OBJ.MVP * aPosition;
+ gl_Position = uMVP * aPosition;
}
-- fragment
@@ -37,20 +37,20 @@ void main() {
#endif
vec3 n = normalize(vNormal);
vec3 s;
- if (SCN.LightPosition.w > 0) {
+ if (uLightPosition.w > 0) {
/* positional light, compute direction */
- s = normalize(SCN.LightPosition.xyz - vPosition);
+ s = normalize(uLightPosition.xyz - vPosition);
} else {
/* directional light - light position is actually a vector */
- s = SCN.LightPosition.xyz;
+ s = uLightPosition.xyz;
}
vec3 v = normalize(-vPosition);
vec3 h = normalize(v + s);
- gl_FragColor = MAT.Ambient * c
- + MAT.Diffuse * c * max( dot(s, n), 0.0)
+ gl_FragColor = uAmbient * c
+ + uDiffuse * c * max( dot(s, n), 0.0)
#ifdef SPECULAR
- + MAT.Specular * SCN.LightColor * pow( max( dot(h,n), 0.0), MAT.Shininess)
+ + uSpecular * uLightColor * pow( max( dot(h,n), 0.0), uShininess)
#endif
;
}