diff options
| author | raysan5 <raysan5@gmail.com> | 2016-01-13 17:13:28 +0100 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2016-01-13 17:13:28 +0100 |
| commit | fb6ef2c2f4fe22552908d339cda541453e43faec (patch) | |
| tree | 53d86522f6f1a5256e097a2e7bc82ce3e0101526 /shaders | |
| parent | bb49102a4b5ae7bf6a34b437b133e8c5e3557f8d (diff) | |
| download | raylib-fb6ef2c2f4fe22552908d339cda541453e43faec.tar.gz raylib-fb6ef2c2f4fe22552908d339cda541453e43faec.zip | |
Vertex shaders optimization
Diffstat (limited to 'shaders')
30 files changed, 40 insertions, 43 deletions
diff --git a/shaders/gl330/base.vs b/shaders/gl330/base.vs index 59eae0a0..b0f930b7 100644 --- a/shaders/gl330/base.vs +++ b/shaders/gl330/base.vs @@ -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); }
\ No newline at end of file diff --git a/shaders/gl330/bloom.fs b/shaders/gl330/bloom.fs index f9cebe18..2833ce33 100644 --- a/shaders/gl330/bloom.fs +++ b/shaders/gl330/bloom.fs @@ -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 diff --git a/shaders/gl330/blur.fs b/shaders/gl330/blur.fs index b4e5bd2b..bd2b521f 100644 --- a/shaders/gl330/blur.fs +++ b/shaders/gl330/blur.fs @@ -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 diff --git a/shaders/gl330/cross_hatching.fs b/shaders/gl330/cross_hatching.fs index e2362212..7e25b25b 100644 --- a/shaders/gl330/cross_hatching.fs +++ b/shaders/gl330/cross_hatching.fs @@ -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 diff --git a/shaders/gl330/cross_stitching.fs b/shaders/gl330/cross_stitching.fs index 041bf1dc..73f867b6 100644 --- a/shaders/gl330/cross_stitching.fs +++ b/shaders/gl330/cross_stitching.fs @@ -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 diff --git a/shaders/gl330/dream_vision.fs b/shaders/gl330/dream_vision.fs index de9c04eb..f9316342 100644 --- a/shaders/gl330/dream_vision.fs +++ b/shaders/gl330/dream_vision.fs @@ -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 diff --git a/shaders/gl330/fisheye.fs b/shaders/gl330/fisheye.fs index d0e42cca..bbbff65c 100644 --- a/shaders/gl330/fisheye.fs +++ b/shaders/gl330/fisheye.fs @@ -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 diff --git a/shaders/gl330/grayscale.fs b/shaders/gl330/grayscale.fs index 38337e00..af50b8c1 100644 --- a/shaders/gl330/grayscale.fs +++ b/shaders/gl330/grayscale.fs @@ -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); }
\ No newline at end of file diff --git a/shaders/gl330/phong.fs b/shaders/gl330/phong.fs index bb8826f4..75b7e6d7 100644 --- a/shaders/gl330/phong.fs +++ b/shaders/gl330/phong.fs @@ -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); diff --git a/shaders/gl330/phong.vs b/shaders/gl330/phong.vs index 25163902..ee6d34bf 100644 --- a/shaders/gl330/phong.vs +++ b/shaders/gl330/phong.vs @@ -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); }
\ No newline at end of file diff --git a/shaders/gl330/pixel.fs b/shaders/gl330/pixel.fs index ec9e13d7..feee1423 100644 --- a/shaders/gl330/pixel.fs +++ b/shaders/gl330/pixel.fs @@ -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 diff --git a/shaders/gl330/posterization.fs b/shaders/gl330/posterization.fs index 652cf609..a4e49466 100644 --- a/shaders/gl330/posterization.fs +++ b/shaders/gl330/posterization.fs @@ -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 diff --git a/shaders/gl330/predator.fs b/shaders/gl330/predator.fs index 77882917..2295d01b 100644 --- a/shaders/gl330/predator.fs +++ b/shaders/gl330/predator.fs @@ -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 diff --git a/shaders/gl330/scanlines.fs b/shaders/gl330/scanlines.fs index 7f33f882..57297299 100644 --- a/shaders/gl330/scanlines.fs +++ b/shaders/gl330/scanlines.fs @@ -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 diff --git a/shaders/gl330/swirl.fs b/shaders/gl330/swirl.fs index 18a47cec..e88b59c9 100644 --- a/shaders/gl330/swirl.fs +++ b/shaders/gl330/swirl.fs @@ -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 diff --git a/shaders/gl330/template.fs b/shaders/gl330/template.fs index 92221959..660e8484 100644 --- a/shaders/gl330/template.fs +++ b/shaders/gl330/template.fs @@ -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; } diff --git a/shaders/gles100/base.vs b/shaders/gles100/base.vs index eff89c56..9f339382 100644 --- a/shaders/gles100/base.vs +++ b/shaders/gles100/base.vs @@ -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); }
\ No newline at end of file diff --git a/shaders/gles100/bloom.fs b/shaders/gles100/bloom.fs index eba44d41..33754c7e 100644 --- a/shaders/gles100/bloom.fs +++ b/shaders/gles100/bloom.fs @@ -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 diff --git a/shaders/gles100/blur.fs b/shaders/gles100/blur.fs index 3c865ca0..a1069c6f 100644 --- a/shaders/gles100/blur.fs +++ b/shaders/gles100/blur.fs @@ -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 diff --git a/shaders/gles100/cross_hatching.fs b/shaders/gles100/cross_hatching.fs index c308acb6..cf01b65e 100644 --- a/shaders/gles100/cross_hatching.fs +++ b/shaders/gles100/cross_hatching.fs @@ -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 diff --git a/shaders/gles100/cross_stitching.fs b/shaders/gles100/cross_stitching.fs index 09b3ad4a..f1afef04 100644 --- a/shaders/gles100/cross_stitching.fs +++ b/shaders/gles100/cross_stitching.fs @@ -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 diff --git a/shaders/gles100/dream_vision.fs b/shaders/gles100/dream_vision.fs index 6cbdfcd6..bb828970 100644 --- a/shaders/gles100/dream_vision.fs +++ b/shaders/gles100/dream_vision.fs @@ -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 diff --git a/shaders/gles100/fisheye.fs b/shaders/gles100/fisheye.fs index a21257c7..e7a4485c 100644 --- a/shaders/gles100/fisheye.fs +++ b/shaders/gles100/fisheye.fs @@ -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 diff --git a/shaders/gles100/grayscale.fs b/shaders/gles100/grayscale.fs index 07e79614..e55545e2 100644 --- a/shaders/gles100/grayscale.fs +++ b/shaders/gles100/grayscale.fs @@ -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); }
\ No newline at end of file diff --git a/shaders/gles100/pixel.fs b/shaders/gles100/pixel.fs index eceff6e3..552e8900 100644 --- a/shaders/gles100/pixel.fs +++ b/shaders/gles100/pixel.fs @@ -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 diff --git a/shaders/gles100/posterization.fs b/shaders/gles100/posterization.fs index f635305e..4f4c4b93 100644 --- a/shaders/gles100/posterization.fs +++ b/shaders/gles100/posterization.fs @@ -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 diff --git a/shaders/gles100/predator.fs b/shaders/gles100/predator.fs index c85048a6..2fbdc7af 100644 --- a/shaders/gles100/predator.fs +++ b/shaders/gles100/predator.fs @@ -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 diff --git a/shaders/gles100/scanlines.fs b/shaders/gles100/scanlines.fs index 56a6f694..85de158d 100644 --- a/shaders/gles100/scanlines.fs +++ b/shaders/gles100/scanlines.fs @@ -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 diff --git a/shaders/gles100/swirl.fs b/shaders/gles100/swirl.fs index b50ed39e..b0d54b23 100644 --- a/shaders/gles100/swirl.fs +++ b/shaders/gles100/swirl.fs @@ -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 diff --git a/shaders/gles100/template.fs b/shaders/gles100/template.fs index 9d9499f3..1f4b8ccf 100644 --- a/shaders/gles100/template.fs +++ b/shaders/gles100/template.fs @@ -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; }
\ No newline at end of file |
