Vertex shaders optimization
This commit is contained in:
parent
bb49102a4b
commit
fb6ef2c2f4
41 changed files with 86 additions and 92 deletions
|
@ -6,8 +6,7 @@ in vec3 vertexNormal;
|
|||
|
||||
out vec2 fragTexCoord;
|
||||
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 modelviewMatrix;
|
||||
uniform mat4 mvpMatrix;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
@ -15,5 +14,5 @@ void main()
|
|||
{
|
||||
fragTexCoord = vertexTexCoord;
|
||||
|
||||
gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0);
|
||||
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
|
||||
}
|
|
@ -5,7 +5,7 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,16 +5,16 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 base = texture2D(texture0, fragTexCoord)*tintColor;
|
||||
vec4 base = texture2D(texture0, fragTexCoord)*fragTintColor;
|
||||
|
||||
// Convert to grayscale using NTSC conversion weights
|
||||
float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
|
||||
|
||||
fragColor = vec4(gray, gray, gray, tintColor.a);
|
||||
fragColor = vec4(gray, gray, gray, fragTintColor.a);
|
||||
}
|
|
@ -6,7 +6,7 @@ in vec3 fragNormal;
|
|||
|
||||
// Diffuse data
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// Light attributes
|
||||
uniform vec3 light_ambientColor = vec3(0.6, 0.3, 0);
|
||||
|
|
|
@ -6,8 +6,7 @@ in vec2 vertexTexCoord;
|
|||
in vec3 vertexNormal;
|
||||
|
||||
// Projection and model data
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 modelviewMatrix;
|
||||
uniform mat4 mvpMatrix;
|
||||
uniform mat4 modelMatrix;
|
||||
|
||||
// Attributes to fragment shader
|
||||
|
@ -21,8 +20,8 @@ void main()
|
|||
|
||||
// Calculate view vector normal from model
|
||||
mat3 normalMatrix = transpose(inverse(mat3(modelMatrix)));
|
||||
fragNormal = normalize(normalMatrix * vertexNormal);
|
||||
fragNormal = normalize(normalMatrix*vertexNormal);
|
||||
|
||||
// Calculate final vertex position
|
||||
gl_Position = projectionMatrix * modelviewMatrix * vec4(vertexPosition, 1.0);
|
||||
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
|
||||
}
|
|
@ -5,7 +5,7 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ in vec2 fragTexCoord;
|
|||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
@ -15,5 +15,5 @@ void main()
|
|||
|
||||
// NOTE: Implement here your fragment shader code
|
||||
|
||||
fragColor = texelColor*tintColor;
|
||||
fragColor = texelColor*fragTintColor;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ attribute vec3 vertexNormal;
|
|||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 modelviewMatrix;
|
||||
uniform mat4 mvpMatrix;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
@ -17,5 +16,5 @@ void main()
|
|||
|
||||
fragTexCoord = vertexTexCoord;
|
||||
|
||||
gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0);
|
||||
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
|
||||
}
|
|
@ -5,7 +5,7 @@ precision mediump float;
|
|||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ precision mediump float;
|
|||
|
||||
varying vec2 fragTexCoord;
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ precision mediump float;
|
|||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ precision mediump float;
|
|||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ precision mediump float;
|
|||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ precision mediump float;
|
|||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,16 +5,16 @@ precision mediump float;
|
|||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 base = texture2D(texture0, fragTexCoord)*tintColor;
|
||||
vec4 base = texture2D(texture0, fragTexCoord)*fragTintColor;
|
||||
|
||||
// Convert to grayscale using NTSC conversion weights
|
||||
float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
|
||||
|
||||
gl_FragColor = vec4(gray, gray, gray, tintColor.a);
|
||||
gl_FragColor = vec4(gray, gray, gray, fragTintColor.a);
|
||||
}
|
|
@ -5,7 +5,7 @@ precision mediump float;
|
|||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ precision mediump float;
|
|||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ precision mediump float;
|
|||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ precision mediump float;
|
|||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ precision mediump float;
|
|||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ precision mediump float;
|
|||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
|
@ -15,5 +15,5 @@ void main()
|
|||
|
||||
// NOTE: Implement here your fragment shader code
|
||||
|
||||
gl_FragColor = texelColor*tintColor;
|
||||
gl_FragColor = texelColor*fragTintColor;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue