From 61558ab83faa52e738b264ea85fe34448651ba87 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Tue, 19 Jul 2016 10:57:35 +0200 Subject: [PATCH] Updated shaders pack Some deep review of this shaders is required for optimization... --- shaders/glsl100/bloom.fs | 2 +- shaders/glsl100/blur.fs | 7 ++++--- shaders/glsl100/cross_hatching.fs | 2 +- shaders/glsl100/cross_stitching.fs | 7 ++++--- shaders/glsl100/dream_vision.fs | 2 +- shaders/glsl100/fisheye.fs | 2 +- shaders/glsl100/pixel.fs | 7 ++++--- shaders/glsl100/posterization.fs | 2 +- shaders/glsl100/predator.fs | 2 +- shaders/glsl100/scanlines.fs | 2 +- shaders/glsl100/standard.fs | 13 ++++--------- shaders/glsl100/swirl.fs | 7 ++++--- shaders/glsl330/bloom.fs | 2 +- shaders/glsl330/blur.fs | 7 ++++--- shaders/glsl330/cross_hatching.fs | 2 +- shaders/glsl330/cross_stitching.fs | 7 ++++--- shaders/glsl330/depth.fs | 2 +- shaders/glsl330/dream_vision.fs | 2 +- shaders/glsl330/fisheye.fs | 2 +- shaders/glsl330/pixel.fs | 7 ++++--- shaders/glsl330/posterization.fs | 2 +- shaders/glsl330/predator.fs | 2 +- shaders/glsl330/scanlines.fs | 7 +++++-- shaders/glsl330/standard.fs | 13 ++++--------- shaders/glsl330/swirl.fs | 7 ++++--- 25 files changed, 59 insertions(+), 58 deletions(-) diff --git a/shaders/glsl100/bloom.fs b/shaders/glsl100/bloom.fs index 128736f22..82278fc38 100644 --- a/shaders/glsl100/bloom.fs +++ b/shaders/glsl100/bloom.fs @@ -8,7 +8,7 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables diff --git a/shaders/glsl100/blur.fs b/shaders/glsl100/blur.fs index 80d408343..1935f0809 100644 --- a/shaders/glsl100/blur.fs +++ b/shaders/glsl100/blur.fs @@ -8,12 +8,13 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables -const float renderWidth = 1280; -const float renderHeight = 720; +// NOTE: Render size values must be passed from code +const float renderWidth = 800; +const float renderHeight = 450; float offset[3] = float[]( 0.0, 1.3846153846, 3.2307692308 ); float weight[3] = float[]( 0.2270270270, 0.3162162162, 0.0702702703 ); diff --git a/shaders/glsl100/cross_hatching.fs b/shaders/glsl100/cross_hatching.fs index 1f7dab087..ced0fd63c 100644 --- a/shaders/glsl100/cross_hatching.fs +++ b/shaders/glsl100/cross_hatching.fs @@ -8,7 +8,7 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables diff --git a/shaders/glsl100/cross_stitching.fs b/shaders/glsl100/cross_stitching.fs index 6fabc027c..67639a551 100644 --- a/shaders/glsl100/cross_stitching.fs +++ b/shaders/glsl100/cross_stitching.fs @@ -8,12 +8,13 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables -const float renderWidth = 1280; -const float renderHeight = 720; +// NOTE: Render size values must be passed from code +const float renderWidth = 800; +const float renderHeight = 450; float stitchingSize = 6.0f; diff --git a/shaders/glsl100/dream_vision.fs b/shaders/glsl100/dream_vision.fs index d0cdc6874..fa9c5b771 100644 --- a/shaders/glsl100/dream_vision.fs +++ b/shaders/glsl100/dream_vision.fs @@ -8,7 +8,7 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables diff --git a/shaders/glsl100/fisheye.fs b/shaders/glsl100/fisheye.fs index 9dba297b3..461e1405d 100644 --- a/shaders/glsl100/fisheye.fs +++ b/shaders/glsl100/fisheye.fs @@ -8,7 +8,7 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables diff --git a/shaders/glsl100/pixel.fs b/shaders/glsl100/pixel.fs index c532f2190..41ba3ed62 100644 --- a/shaders/glsl100/pixel.fs +++ b/shaders/glsl100/pixel.fs @@ -8,12 +8,13 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables -const float renderWidth = 1280; -const float renderHeight = 720; +// NOTE: Render size values must be passed from code +const float renderWidth = 800; +const float renderHeight = 450; uniform float pixelWidth = 5.0f; uniform float pixelHeight = 5.0f; diff --git a/shaders/glsl100/posterization.fs b/shaders/glsl100/posterization.fs index 801ca89cc..a7942c82e 100644 --- a/shaders/glsl100/posterization.fs +++ b/shaders/glsl100/posterization.fs @@ -8,7 +8,7 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables diff --git a/shaders/glsl100/predator.fs b/shaders/glsl100/predator.fs index 1f0e2ce54..efa7fe79b 100644 --- a/shaders/glsl100/predator.fs +++ b/shaders/glsl100/predator.fs @@ -8,7 +8,7 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables diff --git a/shaders/glsl100/scanlines.fs b/shaders/glsl100/scanlines.fs index d885e10b3..529120d00 100644 --- a/shaders/glsl100/scanlines.fs +++ b/shaders/glsl100/scanlines.fs @@ -8,7 +8,7 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables diff --git a/shaders/glsl100/standard.fs b/shaders/glsl100/standard.fs index d5daa4452..3e78022dc 100644 --- a/shaders/glsl100/standard.fs +++ b/shaders/glsl100/standard.fs @@ -34,7 +34,6 @@ struct Light { }; const int maxLights = 8; -uniform int lightsCount; uniform Light lights[maxLights]; vec3 CalcPointLight(Light l, vec3 n, vec3 v, float s) @@ -134,19 +133,15 @@ void main() float spec = 1.0; if (useSpecular == 1) spec *= normalize(texture2D(texture2, fragTexCoord).r); - for (int i = 0; i < lightsCount; i++) + for (int i = 0; i < maxLights; i++) { // Check if light is enabled if (lights[i].enabled == 1) { // Calculate lighting based on light type - switch (lights[i].type) - { - case 0: lighting += CalcPointLight(lights[i], n, v, spec); break; - case 1: lighting += CalcDirectionalLight(lights[i], n, v, spec); break; - case 2: lighting += CalcSpotLight(lights[i], n, v, spec); break; - default: break; - } + if(lights[i].type == 0) lighting += CalcPointLight(lights[i], n, v, spec); + else if(lights[i].type == 1) lighting += CalcDirectionalLight(lights[i], n, v, spec); + else if(lights[i].type == 2) lighting += CalcSpotLight(lights[i], n, v, spec); } } diff --git a/shaders/glsl100/swirl.fs b/shaders/glsl100/swirl.fs index 0d6d24f26..6b17874c4 100644 --- a/shaders/glsl100/swirl.fs +++ b/shaders/glsl100/swirl.fs @@ -8,12 +8,13 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables -const float renderWidth = 800.0; // HARDCODED for example! -const float renderHeight = 480.0; // Use uniforms instead... +// NOTE: Render size values must be passed from code +const float renderWidth = 800; +const float renderHeight = 450; float radius = 250.0; float angle = 0.8; diff --git a/shaders/glsl330/bloom.fs b/shaders/glsl330/bloom.fs index 0307bc06e..102e66052 100644 --- a/shaders/glsl330/bloom.fs +++ b/shaders/glsl330/bloom.fs @@ -6,7 +6,7 @@ in vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // Output fragment color out vec4 finalColor; diff --git a/shaders/glsl330/blur.fs b/shaders/glsl330/blur.fs index 7c31f727a..e4df406d7 100644 --- a/shaders/glsl330/blur.fs +++ b/shaders/glsl330/blur.fs @@ -6,15 +6,16 @@ in vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // Output fragment color out vec4 finalColor; // NOTE: Add here your custom variables -const float renderWidth = 1280.0; -const float renderHeight = 720.0; +// NOTE: Render size values must be passed from code +const float renderWidth = 800; +const float renderHeight = 450; float offset[3] = float[](0.0, 1.3846153846, 3.2307692308); float weight[3] = float[](0.2270270270, 0.3162162162, 0.0702702703); diff --git a/shaders/glsl330/cross_hatching.fs b/shaders/glsl330/cross_hatching.fs index c12c48cd9..f95ad0755 100644 --- a/shaders/glsl330/cross_hatching.fs +++ b/shaders/glsl330/cross_hatching.fs @@ -6,7 +6,7 @@ in vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // Output fragment color out vec4 finalColor; diff --git a/shaders/glsl330/cross_stitching.fs b/shaders/glsl330/cross_stitching.fs index 7c87c6cdf..9cdd36cad 100644 --- a/shaders/glsl330/cross_stitching.fs +++ b/shaders/glsl330/cross_stitching.fs @@ -6,15 +6,16 @@ in vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // Output fragment color out vec4 finalColor; // NOTE: Add here your custom variables -const float renderWidth = 1280.0; -const float renderHeight = 720.0; +// NOTE: Render size values must be passed from code +const float renderWidth = 800.0; +const float renderHeight = 450.0; float stitchingSize = 6.0; diff --git a/shaders/glsl330/depth.fs b/shaders/glsl330/depth.fs index 06d399f9f..2422f3906 100644 --- a/shaders/glsl330/depth.fs +++ b/shaders/glsl330/depth.fs @@ -6,7 +6,7 @@ in vec4 fragColor; // Input uniform values uniform sampler2D texture0; // Depth texture -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // Output fragment color out vec4 finalColor; diff --git a/shaders/glsl330/dream_vision.fs b/shaders/glsl330/dream_vision.fs index 0ea4ce200..031158628 100644 --- a/shaders/glsl330/dream_vision.fs +++ b/shaders/glsl330/dream_vision.fs @@ -5,7 +5,7 @@ in vec2 fragTexCoord; out vec4 fragColor; uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables diff --git a/shaders/glsl330/fisheye.fs b/shaders/glsl330/fisheye.fs index 5bd9abf4b..e85d7c9da 100644 --- a/shaders/glsl330/fisheye.fs +++ b/shaders/glsl330/fisheye.fs @@ -5,7 +5,7 @@ in vec2 fragTexCoord; out vec4 fragColor; uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables diff --git a/shaders/glsl330/pixel.fs b/shaders/glsl330/pixel.fs index 9ed3ea7d0..cf8aec443 100644 --- a/shaders/glsl330/pixel.fs +++ b/shaders/glsl330/pixel.fs @@ -6,15 +6,16 @@ in vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // Output fragment color out vec4 finalColor; // NOTE: Add here your custom variables -const float renderWidth = 1280.0; -const float renderHeight = 720.0; +// NOTE: Render size values must be passed from code +const float renderWidth = 800; +const float renderHeight = 450; uniform float pixelWidth = 5.0; uniform float pixelHeight = 5.0; diff --git a/shaders/glsl330/posterization.fs b/shaders/glsl330/posterization.fs index f1d72a196..be2b5dd65 100644 --- a/shaders/glsl330/posterization.fs +++ b/shaders/glsl330/posterization.fs @@ -6,7 +6,7 @@ in vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // Output fragment color out vec4 finalColor; diff --git a/shaders/glsl330/predator.fs b/shaders/glsl330/predator.fs index 9269dfd4c..6a55c7626 100644 --- a/shaders/glsl330/predator.fs +++ b/shaders/glsl330/predator.fs @@ -6,7 +6,7 @@ in vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // Output fragment color out vec4 finalColor; diff --git a/shaders/glsl330/scanlines.fs b/shaders/glsl330/scanlines.fs index 177f000df..22dc9cd53 100644 --- a/shaders/glsl330/scanlines.fs +++ b/shaders/glsl330/scanlines.fs @@ -6,20 +6,23 @@ in vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // Output fragment color out vec4 finalColor; // NOTE: Add here your custom variables +// NOTE: Render size values must be passed from code +const float renderWidth = 800; +const float renderHeight = 450; float offset = 0.0; -float frequency = 720.0/3.0; uniform float time; void main() { + float frequency = renderHeight/3.0; /* // Scanlines method 1 float tval = 0; //time diff --git a/shaders/glsl330/standard.fs b/shaders/glsl330/standard.fs index e5a6d1bc4..f728be81c 100644 --- a/shaders/glsl330/standard.fs +++ b/shaders/glsl330/standard.fs @@ -34,7 +34,6 @@ struct Light { }; const int maxLights = 8; -uniform int lightsCount; uniform Light lights[maxLights]; vec3 CalcPointLight(Light l, vec3 n, vec3 v, float s) @@ -134,19 +133,15 @@ void main() float spec = 1.0; if (useSpecular == 1) spec *= normalize(texture(texture2, fragTexCoord).r); - for (int i = 0; i < lightsCount; i++) + for (int i = 0; i < maxLights; i++) { // Check if light is enabled if (lights[i].enabled == 1) { // Calculate lighting based on light type - switch (lights[i].type) - { - case 0: lighting += CalcPointLight(lights[i], n, v, spec); break; - case 1: lighting += CalcDirectionalLight(lights[i], n, v, spec); break; - case 2: lighting += CalcSpotLight(lights[i], n, v, spec); break; - default: break; - } + if(lights[i].type == 0) lighting += CalcPointLight(lights[i], n, v, spec); + else if(lights[i].type == 1) lighting += CalcDirectionalLight(lights[i], n, v, spec); + else if(lights[i].type == 2) lighting += CalcSpotLight(lights[i], n, v, spec); } } diff --git a/shaders/glsl330/swirl.fs b/shaders/glsl330/swirl.fs index 80c16cc9e..c4b667685 100644 --- a/shaders/glsl330/swirl.fs +++ b/shaders/glsl330/swirl.fs @@ -6,15 +6,16 @@ in vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // Output fragment color out vec4 finalColor; // NOTE: Add here your custom variables -const float renderWidth = 800.0; // HARDCODED for example! -const float renderHeight = 480.0; // Use uniforms instead... +// NOTE: Render size values must be passed from code +const float renderWidth = 800; +const float renderHeight = 450; float radius = 250.0; float angle = 0.8;