Fixing all the shaders for entities to work correctly with the now supported color attribute field

This commit is contained in:
Sam Gateau 2015-04-07 14:26:45 -07:00
parent f0efade06d
commit ad9129b552
15 changed files with 48 additions and 18 deletions

View file

@ -19,9 +19,11 @@
uniform sampler2D diffuseMap;
// the interpolated normal
varying vec3 vertexColor;
varying vec4 normal;
varying vec3 color;
void main(void) {
// Fetch diffuse map
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
@ -31,7 +33,7 @@ void main(void) {
packDeferredFragment(
normalize(normal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * vertexColor,
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialSpecular(mat),
getMaterialShininess(mat));
}

View file

@ -19,15 +19,15 @@ const int MAX_TEXCOORDS = 2;
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
// the interpolated normal
varying vec3 vertexColor;
varying vec4 normal;
varying vec3 color;
void main(void) {
// pass along the diffuse color
vertexColor = gl_Color.xyz;
color = gl_Color.xyz;
// and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);

View file

@ -26,6 +26,8 @@ uniform vec2 emissiveParams;
// the interpolated normal
varying vec4 normal;
varying vec3 color;
// the interpolated texcoord1
varying vec2 interpolatedTexcoord1;
@ -39,7 +41,7 @@ void main(void) {
packDeferredFragmentLightmap(
normalize(normal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb,
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialSpecular(mat),
getMaterialShininess(mat),
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));

View file

@ -28,9 +28,12 @@ varying vec4 normal;
// the interpolated texcoord1
varying vec2 interpolatedTexcoord1;
varying vec3 color;
void main(void) {
// pass along the diffuse color
gl_FrontColor = gl_Color;
color = gl_Color.xyz;
// and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);

View file

@ -34,6 +34,8 @@ varying vec4 interpolatedTangent;
varying vec2 interpolatedTexcoord1;
varying vec3 color;
void main(void) {
// compute the view normal from the various bits
vec3 normalizedNormal = normalize(vec3(interpolatedNormal));
@ -52,7 +54,7 @@ void main(void) {
packDeferredFragmentLightmap(
normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb,
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialSpecular(mat),
getMaterialShininess(mat),
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));

View file

@ -34,13 +34,15 @@ varying vec4 interpolatedTangent;
// the interpolated texcoord1
varying vec2 interpolatedTexcoord1;
varying vec3 color;
void main(void) {
// transform and store the normal and tangent for interpolation
//interpolatedNormal = gl_ModelViewMatrix * vec4(gl_Normal, 0.0);
//interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0);
// pass along the diffuse color
gl_FrontColor = gl_Color;
color = gl_Color.xyz;
// and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);

View file

@ -37,6 +37,9 @@ varying vec4 interpolatedTangent;
varying vec2 interpolatedTexcoord1;
varying vec3 color;
void main(void) {
// compute the view normal from the various bits
vec3 normalizedNormal = normalize(vec3(interpolatedNormal));
@ -56,7 +59,7 @@ void main(void) {
packDeferredFragmentLightmap(
normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb,
getMaterialDiffuse(mat) * diffuse.rgb * color,
specular, // no use of getMaterialSpecular(mat)
getMaterialShininess(mat),
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));

View file

@ -31,6 +31,8 @@ varying vec4 normal;
varying vec2 interpolatedTexcoord1;
varying vec3 color;
void main(void) {
// set the diffuse, normal, specular data
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
@ -42,7 +44,7 @@ void main(void) {
packDeferredFragmentLightmap(
normalize(normal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb,
getMaterialDiffuse(mat) * diffuse.rgb * color,
specular, // no use of getMaterialSpecular(mat)
getMaterialShininess(mat),
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));

View file

@ -28,6 +28,8 @@ varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent;
varying vec3 color;
void main(void) {
// compute the view normal from the various bits
vec3 normalizedNormal = normalize(vec3(interpolatedNormal));
@ -44,7 +46,7 @@ void main(void) {
packDeferredFragment(
normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb,
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialSpecular(mat),
getMaterialShininess(mat));
}

View file

@ -29,13 +29,15 @@ varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent;
varying vec3 color;
void main(void) {
// transform and store the normal and tangent for interpolation
//interpolatedNormal = gl_ModelViewMatrix * vec4(gl_Normal, 0.0);
//interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0);
// pass along the diffuse color
gl_FrontColor = gl_Color;
color = gl_Color.xyz;
// and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);

View file

@ -31,6 +31,8 @@ varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent;
varying vec3 color;
void main(void) {
// compute the view normal from the various bits
vec3 normalizedNormal = normalize(vec3(interpolatedNormal));
@ -49,7 +51,7 @@ void main(void) {
packDeferredFragment(
normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb,
getMaterialDiffuse(mat) * diffuse.rgb * color,
specular, //getMaterialSpecular(mat),
getMaterialShininess(mat));
}

View file

@ -25,6 +25,8 @@ uniform sampler2D specularMap;
// the interpolated normal
varying vec4 normal;
varying vec3 color;
void main(void) {
// set the diffuse, normal, specular data
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
@ -35,7 +37,7 @@ void main(void) {
packDeferredFragment(
normalize(normal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb,
getMaterialDiffuse(mat) * diffuse.rgb * color,
specular, //getMaterialSpecular(mat),
getMaterialShininess(mat));
}

View file

@ -21,6 +21,8 @@ uniform sampler2D diffuseMap;
varying vec4 normal;
varying vec3 color;
void main(void) {
// Fetch diffuse map
@ -31,7 +33,7 @@ void main(void) {
packDeferredFragmentTranslucent(
normalize(normal.xyz),
getMaterialOpacity(mat) * diffuse.a,
getMaterialDiffuse(mat) * diffuse.rgb,
getMaterialDiffuse(mat) * diffuse.rgb * color,
getMaterialSpecular(mat),
getMaterialShininess(mat));

View file

@ -28,6 +28,8 @@ attribute vec4 clusterWeights;
// the interpolated normal
varying vec4 normal;
varying vec3 color;
void main(void) {
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
normal = vec4(0.0, 0.0, 0.0, 0.0);
@ -39,7 +41,7 @@ void main(void) {
}
// pass along the diffuse color
gl_FrontColor = gl_Color;
color = gl_Color.xyz;
// and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);

View file

@ -34,6 +34,8 @@ varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent;
varying vec3 color;
void main(void) {
vec4 interpolatedPosition = vec4(0.0, 0.0, 0.0, 0.0);
interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
@ -47,7 +49,7 @@ void main(void) {
}
// pass along the diffuse color
gl_FrontColor = gl_Color;
color = gl_Color.xyz;
// and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);