aboutsummaryrefslogtreecommitdiff
path: root/shaders/glsl100
diff options
context:
space:
mode:
Diffstat (limited to 'shaders/glsl100')
-rw-r--r--shaders/glsl100/base.vs14
-rw-r--r--shaders/glsl100/bloom.fs25
-rw-r--r--shaders/glsl100/blur.fs5
-rw-r--r--shaders/glsl100/cross_hatching.fs5
-rw-r--r--shaders/glsl100/cross_stitching.fs5
-rw-r--r--shaders/glsl100/dream_vision.fs3
-rw-r--r--shaders/glsl100/fisheye.fs5
-rw-r--r--shaders/glsl100/grayscale.fs13
-rw-r--r--shaders/glsl100/pixel.fs3
-rw-r--r--shaders/glsl100/posterization.fs3
-rw-r--r--shaders/glsl100/predator.fs3
-rw-r--r--shaders/glsl100/scanlines.fs5
-rw-r--r--shaders/glsl100/swirl.fs16
-rw-r--r--shaders/glsl100/template.fs4
14 files changed, 76 insertions, 33 deletions
diff --git a/shaders/glsl100/base.vs b/shaders/glsl100/base.vs
index 9f339382..e9386939 100644
--- a/shaders/glsl100/base.vs
+++ b/shaders/glsl100/base.vs
@@ -1,20 +1,26 @@
#version 100
+// Input vertex attributes
attribute vec3 vertexPosition;
attribute vec2 vertexTexCoord;
attribute vec3 vertexNormal;
+attribute vec4 vertexColor;
-varying vec2 fragTexCoord;
-
+// Input uniform values
uniform mat4 mvpMatrix;
+// Output vertex attributes (to fragment shader)
+varying vec2 fragTexCoord;
+varying vec4 fragColor;
+
// NOTE: Add here your custom variables
void main()
{
- vec3 normal = vertexNormal;
-
+ // Send vertex attributes to fragment shader
fragTexCoord = vertexTexCoord;
+ fragColor = vertexColor;
+ // Calculate final vertex position
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
} \ No newline at end of file
diff --git a/shaders/glsl100/bloom.fs b/shaders/glsl100/bloom.fs
index 33754c7e..280d2fb6 100644
--- a/shaders/glsl100/bloom.fs
+++ b/shaders/glsl100/bloom.fs
@@ -2,8 +2,11 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
@@ -22,21 +25,13 @@ void main()
}
}
- if (texture2D(texture0, fragTexCoord).r < 0.3)
- {
- tc = sum*sum*0.012 + texture2D(texture0, fragTexCoord);
- }
- else
- {
- if (texture2D(texture0, fragTexCoord).r < 0.5)
- {
- tc = sum*sum*0.009 + texture2D(texture0, fragTexCoord);
- }
- else
- {
- tc = sum*sum*0.0075 + texture2D(texture0, fragTexCoord);
- }
- }
+ // Texel color fetching from texture sampler
+ vec4 texelColor = texture(texture0, fragTexCoord);
+
+ // Calculate final fragment color
+ if (texelColor.r < 0.3) tc = sum*sum*0.012 + texelColor;
+ else if (texelColor.r < 0.5) tc = sum*sum*0.009 + texelColor;
+ else tc = sum*sum*0.0075 + texelColor;
gl_FragColor = tc;
} \ No newline at end of file
diff --git a/shaders/glsl100/blur.fs b/shaders/glsl100/blur.fs
index a1069c6f..80d40834 100644
--- a/shaders/glsl100/blur.fs
+++ b/shaders/glsl100/blur.fs
@@ -2,7 +2,11 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
@@ -16,6 +20,7 @@ float weight[3] = float[]( 0.2270270270, 0.3162162162, 0.0702702703 );
void main()
{
+ // Texel color fetching from texture sampler
vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight[0];
for (int i = 1; i < 3; i++)
diff --git a/shaders/glsl100/cross_hatching.fs b/shaders/glsl100/cross_hatching.fs
index cf01b65e..1f7dab08 100644
--- a/shaders/glsl100/cross_hatching.fs
+++ b/shaders/glsl100/cross_hatching.fs
@@ -2,12 +2,15 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
-// NOTE: Add here your custom variables
+// NOTE: Add here your custom variables
float hatchOffsetY = 5.0f;
float lumThreshold01 = 0.9f;
diff --git a/shaders/glsl100/cross_stitching.fs b/shaders/glsl100/cross_stitching.fs
index f1afef04..6fabc027 100644
--- a/shaders/glsl100/cross_stitching.fs
+++ b/shaders/glsl100/cross_stitching.fs
@@ -2,8 +2,11 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
@@ -46,7 +49,7 @@ vec4 PostFX(sampler2D tex, vec2 uv)
return c;
}
-void main(void)
+void main()
{
vec3 tc = PostFX(texture0, fragTexCoord).rgb;
diff --git a/shaders/glsl100/dream_vision.fs b/shaders/glsl100/dream_vision.fs
index bb828970..d0cdc687 100644
--- a/shaders/glsl100/dream_vision.fs
+++ b/shaders/glsl100/dream_vision.fs
@@ -2,8 +2,11 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
diff --git a/shaders/glsl100/fisheye.fs b/shaders/glsl100/fisheye.fs
index e7a4485c..9dba297b 100644
--- a/shaders/glsl100/fisheye.fs
+++ b/shaders/glsl100/fisheye.fs
@@ -2,12 +2,15 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
-// NOTE: Add here your custom variables
+// NOTE: Add here your custom variables
const float PI = 3.1415926535;
diff --git a/shaders/glsl100/grayscale.fs b/shaders/glsl100/grayscale.fs
index e55545e2..f92ec335 100644
--- a/shaders/glsl100/grayscale.fs
+++ b/shaders/glsl100/grayscale.fs
@@ -2,8 +2,11 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
@@ -11,10 +14,12 @@ uniform vec4 fragTintColor;
void main()
{
- vec4 base = texture2D(texture0, fragTexCoord)*fragTintColor;
+ // Texel color fetching from texture sampler
+ vec4 texelColor = texture(texture0, fragTexCoord)*fragTintColor*fragColor;
- // Convert to grayscale using NTSC conversion weights
- float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
+ // Convert texel color to grayscale using NTSC conversion weights
+ float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114));
- gl_FragColor = vec4(gray, gray, gray, fragTintColor.a);
+ // Calculate final fragment color
+ gl_FragColor = vec4(gray, gray, gray, texelColor.a);
} \ No newline at end of file
diff --git a/shaders/glsl100/pixel.fs b/shaders/glsl100/pixel.fs
index 552e8900..c532f219 100644
--- a/shaders/glsl100/pixel.fs
+++ b/shaders/glsl100/pixel.fs
@@ -2,8 +2,11 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
diff --git a/shaders/glsl100/posterization.fs b/shaders/glsl100/posterization.fs
index 4f4c4b93..801ca89c 100644
--- a/shaders/glsl100/posterization.fs
+++ b/shaders/glsl100/posterization.fs
@@ -2,8 +2,11 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
diff --git a/shaders/glsl100/predator.fs b/shaders/glsl100/predator.fs
index 2fbdc7af..1f0e2ce5 100644
--- a/shaders/glsl100/predator.fs
+++ b/shaders/glsl100/predator.fs
@@ -2,8 +2,11 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
diff --git a/shaders/glsl100/scanlines.fs b/shaders/glsl100/scanlines.fs
index 85de158d..d885e10b 100644
--- a/shaders/glsl100/scanlines.fs
+++ b/shaders/glsl100/scanlines.fs
@@ -2,8 +2,11 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
@@ -14,7 +17,7 @@ float frequency = 720/3.0;
uniform float time;
-void main (void)
+void main()
{
/*
// Scanlines method 1
diff --git a/shaders/glsl100/swirl.fs b/shaders/glsl100/swirl.fs
index b0d54b23..0d6d24f2 100644
--- a/shaders/glsl100/swirl.fs
+++ b/shaders/glsl100/swirl.fs
@@ -2,28 +2,32 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
// NOTE: Add here your custom variables
-const float renderWidth = 1280;
-const float renderHeight = 720;
+const float renderWidth = 800.0; // HARDCODED for example!
+const float renderHeight = 480.0; // Use uniforms instead...
float radius = 250.0;
float angle = 0.8;
-uniform vec2 center = vec2(200, 200);
+uniform vec2 center = vec2(200.0, 200.0);
-void main (void)
+void main()
{
vec2 texSize = vec2(renderWidth, renderHeight);
vec2 tc = fragTexCoord*texSize;
tc -= center;
- float dist = length(tc);
+ float dist = length(tc);
+
if (dist < radius)
{
float percent = (radius - dist)/radius;
@@ -33,7 +37,7 @@ void main (void)
tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c)));
}
-
+
tc += center;
vec3 color = texture2D(texture0, tc/texSize).rgb;
diff --git a/shaders/glsl100/template.fs b/shaders/glsl100/template.fs
index 1f4b8ccf..a3942890 100644
--- a/shaders/glsl100/template.fs
+++ b/shaders/glsl100/template.fs
@@ -2,8 +2,11 @@
precision mediump float;
+// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
+varying vec4 fragColor;
+// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
@@ -11,6 +14,7 @@ uniform vec4 fragTintColor;
void main()
{
+ // Texel color fetching from texture sampler
vec4 texelColor = texture2D(texture0, fragTexCoord);
// NOTE: Implement here your fragment shader code