aboutsummaryrefslogtreecommitdiff
path: root/shaders/glsl330
diff options
context:
space:
mode:
Diffstat (limited to 'shaders/glsl330')
-rw-r--r--shaders/glsl330/bloom.fs2
-rw-r--r--shaders/glsl330/blur.fs7
-rw-r--r--shaders/glsl330/cross_hatching.fs2
-rw-r--r--shaders/glsl330/cross_stitching.fs7
-rw-r--r--shaders/glsl330/depth.fs2
-rw-r--r--shaders/glsl330/dream_vision.fs2
-rw-r--r--shaders/glsl330/fisheye.fs2
-rw-r--r--shaders/glsl330/phong.fs85
-rw-r--r--shaders/glsl330/phong.vs29
-rw-r--r--shaders/glsl330/pixel.fs7
-rw-r--r--shaders/glsl330/posterization.fs2
-rw-r--r--shaders/glsl330/predator.fs2
-rw-r--r--shaders/glsl330/scanlines.fs7
-rw-r--r--shaders/glsl330/standard.fs13
-rw-r--r--shaders/glsl330/swirl.fs7
15 files changed, 32 insertions, 144 deletions
diff --git a/shaders/glsl330/bloom.fs b/shaders/glsl330/bloom.fs
index 0307bc06..102e6605 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 7c31f727..e4df406d 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 c12c48cd..f95ad075 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 7c87c6cd..9cdd36ca 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 06d399f9..2422f390 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 0ea4ce20..03115862 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 5bd9abf4..e85d7c9d 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/phong.fs b/shaders/glsl330/phong.fs
deleted file mode 100644
index b2414a15..00000000
--- a/shaders/glsl330/phong.fs
+++ /dev/null
@@ -1,85 +0,0 @@
-#version 330
-
-// Input vertex attributes (from vertex shader)
-in vec2 fragTexCoord;
-in vec3 fragNormal;
-
-// Input uniform values
-uniform sampler2D texture0;
-uniform vec4 colDiffuse;
-
-// Output fragment color
-out vec4 finalColor;
-
-// NOTE: Add here your custom variables
-
-// Light uniform values
-uniform vec3 lightAmbientColor = vec3(0.6, 0.3, 0.0);
-uniform vec3 lightDiffuseColor = vec3(1.0, 0.5, 0.0);
-uniform vec3 lightSpecularColor = vec3(0.0, 1.0, 0.0);
-uniform float lightIntensity = 1.0;
-uniform float lightSpecIntensity = 1.0;
-
-// Material uniform values
-uniform vec3 matAmbientColor = vec3(1.0, 1.0, 1.0);
-uniform vec3 matSpecularColor = vec3(1.0, 1.0, 1.0);
-uniform float matGlossiness = 50.0;
-
-// World uniform values
-uniform vec3 lightPosition;
-uniform vec3 cameraPosition;
-
-// Fragment shader output data
-out vec4 fragColor;
-
-// Calculate ambient lighting component
-vec3 AmbientLighting()
-{
- return (matAmbientColor*lightAmbientColor);
-}
-
-// Calculate diffuse lighting component
-vec3 DiffuseLighting(in vec3 N, in vec3 L)
-{
- // Lambertian reflection calculation
- float diffuse = clamp(dot(N, L), 0, 1);
-
- return (colDiffuse.xyz*lightDiffuseColor*lightIntensity*diffuse);
-}
-
-// Calculate specular lighting component
-vec3 SpecularLighting(in vec3 N, in vec3 L, in vec3 V)
-{
- float specular = 0.0;
-
- // Calculate specular reflection only if the surface is oriented to the light source
- if (dot(N, L) > 0)
- {
- // Calculate half vector
- vec3 H = normalize(L + V);
-
- // Calculate specular intensity
- specular = pow(dot(N, H), 3 + matGlossiness);
- }
-
- return (matSpecularColor*lightSpecularColor*lightSpecIntensity*specular);
-}
-
-void main()
-{
- // Normalize input vectors
- vec3 L = normalize(lightPosition);
- vec3 V = normalize(cameraPosition);
- vec3 N = normalize(fragNormal);
-
- // Calculate lighting components
- vec3 ambient = AmbientLighting();
- vec3 diffuse = DiffuseLighting(N, L);
- vec3 specular = SpecularLighting(N, L, V);
-
- // Texel color fetching from texture sampler
- vec4 texelColor = texture(texture0, fragTexCoord);
-
- // Calculate final fragment color
- finalColor = vec4(texelColor.rgb*(ambient + diffuse + specular), texelColor.a);
-} \ No newline at end of file
diff --git a/shaders/glsl330/phong.vs b/shaders/glsl330/phong.vs
deleted file mode 100644
index d68d9b3f..00000000
--- a/shaders/glsl330/phong.vs
+++ /dev/null
@@ -1,29 +0,0 @@
-#version 330
-
-// Input vertex attributes
-in vec3 vertexPosition;
-in vec2 vertexTexCoord;
-in vec3 vertexNormal;
-
-// Input uniform values
-uniform mat4 mvpMatrix;
-
-// Output vertex attributes (to fragment shader)
-out vec2 fragTexCoord;
-out vec3 fragNormal;
-
-// NOTE: Add here your custom variables
-uniform mat4 modelMatrix;
-
-void main()
-{
- // Send vertex attributes to fragment shader
- fragTexCoord = vertexTexCoord;
-
- // Calculate view vector normal from model
- mat3 normalMatrix = transpose(inverse(mat3(modelMatrix)));
- fragNormal = normalize(normalMatrix*vertexNormal);
-
- // Calculate final vertex position
- gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
-} \ No newline at end of file
diff --git a/shaders/glsl330/pixel.fs b/shaders/glsl330/pixel.fs
index 9ed3ea7d..cf8aec44 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 f1d72a19..be2b5dd6 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 9269dfd4..6a55c762 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 177f000d..22dc9cd5 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 e5a6d1bc..f728be81 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 80c16cc9..c4b66768 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;