aboutsummaryrefslogtreecommitdiff
path: root/shaders/glsl330
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2016-06-06 20:46:06 +0200
committerRay <raysan5@gmail.com>2016-06-06 20:46:06 +0200
commit1c98e6b698b8002e0c6c769c6d9f23a6e15f3bdf (patch)
tree0aba231bb77034cae38dc44e39d53b63197c6a2c /shaders/glsl330
parent75a73d94171051037fcf670852877977d9251520 (diff)
parent4dada3269374a82fa2c4a06bd29dfc0f37a64380 (diff)
downloadraylib-1c98e6b698b8002e0c6c769c6d9f23a6e15f3bdf.tar.gz
raylib-1c98e6b698b8002e0c6c769c6d9f23a6e15f3bdf.zip
Merge pull request #125 from raysan5/develop
Develop branch integration
Diffstat (limited to 'shaders/glsl330')
-rw-r--r--shaders/glsl330/base.vs26
-rw-r--r--shaders/glsl330/bloom.fs38
-rw-r--r--shaders/glsl330/blur.fs34
-rw-r--r--shaders/glsl330/cross_hatching.fs48
-rw-r--r--shaders/glsl330/cross_stitching.fs58
-rw-r--r--shaders/glsl330/depth.fs27
-rw-r--r--shaders/glsl330/dream_vision.fs34
-rw-r--r--shaders/glsl330/fisheye.fs40
-rw-r--r--shaders/glsl330/grayscale.fs26
-rw-r--r--shaders/glsl330/phong.fs85
-rw-r--r--shaders/glsl330/phong.vs29
-rw-r--r--shaders/glsl330/pixel.fs32
-rw-r--r--shaders/glsl330/posterization.fs31
-rw-r--r--shaders/glsl330/predator.fs32
-rw-r--r--shaders/glsl330/scanlines.fs46
-rw-r--r--shaders/glsl330/swirl.fs46
-rw-r--r--shaders/glsl330/template.fs24
17 files changed, 656 insertions, 0 deletions
diff --git a/shaders/glsl330/base.vs b/shaders/glsl330/base.vs
new file mode 100644
index 00000000..638cb8ae
--- /dev/null
+++ b/shaders/glsl330/base.vs
@@ -0,0 +1,26 @@
+#version 330
+
+// Input vertex attributes
+in vec3 vertexPosition;
+in vec2 vertexTexCoord;
+in vec3 vertexNormal;
+in vec4 vertexColor;
+
+// Input uniform values
+uniform mat4 mvpMatrix;
+
+// Output vertex attributes (to fragment shader)
+out vec2 fragTexCoord;
+out vec4 fragColor;
+
+// NOTE: Add here your custom variables
+
+void main()
+{
+ // 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/glsl330/bloom.fs b/shaders/glsl330/bloom.fs
new file mode 100644
index 00000000..0307bc06
--- /dev/null
+++ b/shaders/glsl330/bloom.fs
@@ -0,0 +1,38 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 fragTintColor;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+void main()
+{
+ vec4 sum = vec4(0);
+ vec4 tc = vec4(0);
+
+ for (int i = -4; i < 4; i++)
+ {
+ for (int j = -3; j < 3; j++)
+ {
+ sum += texture(texture0, fragTexCoord + vec2(j, i)*0.004)*0.25;
+ }
+ }
+
+ // 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;
+
+ finalColor = tc;
+} \ No newline at end of file
diff --git a/shaders/glsl330/blur.fs b/shaders/glsl330/blur.fs
new file mode 100644
index 00000000..7c31f727
--- /dev/null
+++ b/shaders/glsl330/blur.fs
@@ -0,0 +1,34 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 fragTintColor;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+const float renderWidth = 1280.0;
+const float renderHeight = 720.0;
+
+float offset[3] = float[](0.0, 1.3846153846, 3.2307692308);
+float weight[3] = float[](0.2270270270, 0.3162162162, 0.0702702703);
+
+void main()
+{
+ // Texel color fetching from texture sampler
+ vec3 texelColor = texture(texture0, fragTexCoord).rgb*weight[0];
+
+ for (int i = 1; i < 3; i++)
+ {
+ texelColor += texture(texture0, fragTexCoord + vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
+ texelColor += texture(texture0, fragTexCoord - vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
+ }
+
+ finalColor = vec4(texelColor, 1.0);
+} \ No newline at end of file
diff --git a/shaders/glsl330/cross_hatching.fs b/shaders/glsl330/cross_hatching.fs
new file mode 100644
index 00000000..c12c48cd
--- /dev/null
+++ b/shaders/glsl330/cross_hatching.fs
@@ -0,0 +1,48 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 fragTintColor;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+float hatchOffsetY = 5.0;
+float lumThreshold01 = 0.9;
+float lumThreshold02 = 0.7;
+float lumThreshold03 = 0.5;
+float lumThreshold04 = 0.3;
+
+void main()
+{
+ vec3 tc = vec3(1.0, 1.0, 1.0);
+ float lum = length(texture(texture0, fragTexCoord).rgb);
+
+ if (lum < lumThreshold01)
+ {
+ if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
+ }
+
+ if (lum < lumThreshold02)
+ {
+ if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
+ }
+
+ if (lum < lumThreshold03)
+ {
+ if (mod(gl_FragCoord.x + gl_FragCoord.y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
+ }
+
+ if (lum < lumThreshold04)
+ {
+ if (mod(gl_FragCoord.x - gl_FragCoord.y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
+ }
+
+ finalColor = vec4(tc, 1.0);
+} \ No newline at end of file
diff --git a/shaders/glsl330/cross_stitching.fs b/shaders/glsl330/cross_stitching.fs
new file mode 100644
index 00000000..7c87c6cd
--- /dev/null
+++ b/shaders/glsl330/cross_stitching.fs
@@ -0,0 +1,58 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 fragTintColor;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+const float renderWidth = 1280.0;
+const float renderHeight = 720.0;
+
+float stitchingSize = 6.0;
+
+uniform int invert = 0;
+
+vec4 PostFX(sampler2D tex, vec2 uv)
+{
+ vec4 c = vec4(0.0);
+ float size = stitchingSize;
+ vec2 cPos = uv * vec2(renderWidth, renderHeight);
+ vec2 tlPos = floor(cPos / vec2(size, size));
+ tlPos *= size;
+
+ int remX = int(mod(cPos.x, size));
+ int remY = int(mod(cPos.y, size));
+
+ if (remX == 0 && remY == 0) tlPos = cPos;
+
+ vec2 blPos = tlPos;
+ blPos.y += (size - 1.0);
+
+ if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
+ {
+ if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0);
+ else c = texture(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
+ }
+ else
+ {
+ if (invert == 1) c = texture(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
+ else c = vec4(0.0, 0.0, 0.0, 1.0);
+ }
+
+ return c;
+}
+
+void main()
+{
+ vec3 tc = PostFX(texture0, fragTexCoord).rgb;
+
+ finalColor = vec4(tc, 1.0);
+} \ No newline at end of file
diff --git a/shaders/glsl330/depth.fs b/shaders/glsl330/depth.fs
new file mode 100644
index 00000000..06d399f9
--- /dev/null
+++ b/shaders/glsl330/depth.fs
@@ -0,0 +1,27 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0; // Depth texture
+uniform vec4 fragTintColor;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+void main()
+{
+ float zNear = 0.01; // camera z near
+ float zFar = 10.0; // camera z far
+ float z = texture(texture0, fragTexCoord).x;
+
+ // Linearize depth value
+ float depth = (2.0*zNear)/(zFar + zNear - z*(zFar - zNear));
+
+ // Calculate final fragment color
+ finalColor = vec4(depth, depth, depth, 1.0f);
+} \ No newline at end of file
diff --git a/shaders/glsl330/dream_vision.fs b/shaders/glsl330/dream_vision.fs
new file mode 100644
index 00000000..0ea4ce20
--- /dev/null
+++ b/shaders/glsl330/dream_vision.fs
@@ -0,0 +1,34 @@
+#version 330
+
+in vec2 fragTexCoord;
+
+out vec4 fragColor;
+
+uniform sampler2D texture0;
+uniform vec4 fragTintColor;
+
+// NOTE: Add here your custom variables
+
+void main()
+{
+ vec4 color = texture(texture0, fragTexCoord);
+
+ color += texture(texture0, fragTexCoord + 0.001);
+ color += texture(texture0, fragTexCoord + 0.003);
+ color += texture(texture0, fragTexCoord + 0.005);
+ color += texture(texture0, fragTexCoord + 0.007);
+ color += texture(texture0, fragTexCoord + 0.009);
+ color += texture(texture0, fragTexCoord + 0.011);
+
+ color += texture(texture0, fragTexCoord - 0.001);
+ color += texture(texture0, fragTexCoord - 0.003);
+ color += texture(texture0, fragTexCoord - 0.005);
+ color += texture(texture0, fragTexCoord - 0.007);
+ color += texture(texture0, fragTexCoord - 0.009);
+ color += texture(texture0, fragTexCoord - 0.011);
+
+ color.rgb = vec3((color.r + color.g + color.b)/3.0);
+ color = color/9.5;
+
+ fragColor = color;
+} \ No newline at end of file
diff --git a/shaders/glsl330/fisheye.fs b/shaders/glsl330/fisheye.fs
new file mode 100644
index 00000000..5bd9abf4
--- /dev/null
+++ b/shaders/glsl330/fisheye.fs
@@ -0,0 +1,40 @@
+#version 330
+
+in vec2 fragTexCoord;
+
+out vec4 fragColor;
+
+uniform sampler2D texture0;
+uniform vec4 fragTintColor;
+
+// NOTE: Add here your custom variables
+
+const float PI = 3.1415926535;
+
+void main()
+{
+ float aperture = 178.0;
+ float apertureHalf = 0.5 * aperture * (PI / 180.0);
+ float maxFactor = sin(apertureHalf);
+
+ vec2 uv = vec2(0);
+ vec2 xy = 2.0 * fragTexCoord.xy - 1.0;
+ float d = length(xy);
+
+ if (d < (2.0 - maxFactor))
+ {
+ d = length(xy * maxFactor);
+ float z = sqrt(1.0 - d * d);
+ float r = atan(d, z) / PI;
+ float phi = atan(xy.y, xy.x);
+
+ uv.x = r * cos(phi) + 0.5;
+ uv.y = r * sin(phi) + 0.5;
+ }
+ else
+ {
+ uv = fragTexCoord.xy;
+ }
+
+ fragColor = texture(texture0, uv);
+} \ No newline at end of file
diff --git a/shaders/glsl330/grayscale.fs b/shaders/glsl330/grayscale.fs
new file mode 100644
index 00000000..5b3e11be
--- /dev/null
+++ b/shaders/glsl330/grayscale.fs
@@ -0,0 +1,26 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 colDiffuse;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+void main()
+{
+ // Texel color fetching from texture sampler
+ vec4 texelColor = texture(texture0, fragTexCoord)*colDiffuse*fragColor;
+
+ // Convert texel color to grayscale using NTSC conversion weights
+ float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114));
+
+ // Calculate final fragment color
+ finalColor = vec4(gray, gray, gray, texelColor.a);
+} \ No newline at end of file
diff --git a/shaders/glsl330/phong.fs b/shaders/glsl330/phong.fs
new file mode 100644
index 00000000..b2414a15
--- /dev/null
+++ b/shaders/glsl330/phong.fs
@@ -0,0 +1,85 @@
+#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
new file mode 100644
index 00000000..d68d9b3f
--- /dev/null
+++ b/shaders/glsl330/phong.vs
@@ -0,0 +1,29 @@
+#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
new file mode 100644
index 00000000..9ed3ea7d
--- /dev/null
+++ b/shaders/glsl330/pixel.fs
@@ -0,0 +1,32 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 fragTintColor;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+const float renderWidth = 1280.0;
+const float renderHeight = 720.0;
+
+uniform float pixelWidth = 5.0;
+uniform float pixelHeight = 5.0;
+
+void main()
+{
+ float dx = pixelWidth*(1.0/renderWidth);
+ float dy = pixelHeight*(1.0/renderHeight);
+
+ vec2 coord = vec2(dx*floor(fragTexCoord.x/dx), dy*floor(fragTexCoord.y/dy));
+
+ vec3 tc = texture(texture0, coord).rgb;
+
+ finalColor = vec4(tc, 1.0);
+} \ No newline at end of file
diff --git a/shaders/glsl330/posterization.fs b/shaders/glsl330/posterization.fs
new file mode 100644
index 00000000..f1d72a19
--- /dev/null
+++ b/shaders/glsl330/posterization.fs
@@ -0,0 +1,31 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 fragTintColor;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+float gamma = 0.6;
+float numColors = 8.0;
+
+void main()
+{
+ // Texel color fetching from texture sampler
+ vec3 texelColor = texture(texture0, fragTexCoord.xy).rgb;
+
+ texelColor = pow(texelColor, vec3(gamma, gamma, gamma));
+ texelColor = texelColor*numColors;
+ texelColor = floor(texelColor);
+ texelColor = texelColor/numColors;
+ texelColor = pow(texelColor, vec3(1.0/gamma));
+
+ finalColor = vec4(texelColor, 1.0);
+} \ No newline at end of file
diff --git a/shaders/glsl330/predator.fs b/shaders/glsl330/predator.fs
new file mode 100644
index 00000000..9269dfd4
--- /dev/null
+++ b/shaders/glsl330/predator.fs
@@ -0,0 +1,32 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 fragTintColor;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+void main()
+{
+ // Texel color fetching from texture sampler
+ vec3 texelColor = texture(texture0, fragTexCoord).rgb;
+ vec3 colors[3];
+ colors[0] = vec3(0.0, 0.0, 1.0);
+ colors[1] = vec3(1.0, 1.0, 0.0);
+ colors[2] = vec3(1.0, 0.0, 0.0);
+
+ float lum = (texelColor.r + texelColor.g + texelColor.b)/3.0;
+
+ int ix = (lum < 0.5)? 0:1;
+
+ vec3 tc = mix(colors[ix], colors[ix + 1], (lum - float(ix)*0.5)/0.5);
+
+ finalColor = vec4(tc, 1.0);
+} \ No newline at end of file
diff --git a/shaders/glsl330/scanlines.fs b/shaders/glsl330/scanlines.fs
new file mode 100644
index 00000000..177f000d
--- /dev/null
+++ b/shaders/glsl330/scanlines.fs
@@ -0,0 +1,46 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 fragTintColor;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+float offset = 0.0;
+float frequency = 720.0/3.0;
+
+uniform float time;
+
+void main()
+{
+/*
+ // Scanlines method 1
+ float tval = 0; //time
+ vec2 uv = 0.5 + (fragTexCoord - 0.5)*(0.9 + 0.01*sin(0.5*tval));
+
+ vec4 color = texture(texture0, fragTexCoord);
+
+ color = clamp(color*0.5 + 0.5*color*color*1.2, 0.0, 1.0);
+ color *= 0.5 + 0.5*16.0*uv.x*uv.y*(1.0 - uv.x)*(1.0 - uv.y);
+ color *= vec4(0.8, 1.0, 0.7, 1);
+ color *= 0.9 + 0.1*sin(10.0*tval + uv.y*1000.0);
+ color *= 0.97 + 0.03*sin(110.0*tval);
+
+ fragColor = color;
+*/
+ // Scanlines method 2
+ float globalPos = (fragTexCoord.y + offset) * frequency;
+ float wavePos = cos((fract(globalPos) - 0.5)*3.14);
+
+ // Texel color fetching from texture sampler
+ vec4 texelColor = texture(texture0, fragTexCoord);
+
+ finalColor = mix(vec4(0.0, 0.3, 0.0, 0.0), texelColor, wavePos);
+} \ No newline at end of file
diff --git a/shaders/glsl330/swirl.fs b/shaders/glsl330/swirl.fs
new file mode 100644
index 00000000..80c16cc9
--- /dev/null
+++ b/shaders/glsl330/swirl.fs
@@ -0,0 +1,46 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 fragTintColor;
+
+// 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...
+
+float radius = 250.0;
+float angle = 0.8;
+
+uniform vec2 center = vec2(200.0, 200.0);
+
+void main()
+{
+ vec2 texSize = vec2(renderWidth, renderHeight);
+ vec2 tc = fragTexCoord*texSize;
+ tc -= center;
+
+ float dist = length(tc);
+
+ if (dist < radius)
+ {
+ float percent = (radius - dist)/radius;
+ float theta = percent*percent*angle*8.0;
+ float s = sin(theta);
+ float c = cos(theta);
+
+ tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c)));
+ }
+
+ tc += center;
+ vec3 color = texture(texture0, tc/texSize).rgb;
+
+ finalColor = vec4(color, 1.0);;
+} \ No newline at end of file
diff --git a/shaders/glsl330/template.fs b/shaders/glsl330/template.fs
new file mode 100644
index 00000000..2e73de14
--- /dev/null
+++ b/shaders/glsl330/template.fs
@@ -0,0 +1,24 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 colDiffuse;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+void main()
+{
+ // Texel color fetching from texture sampler
+ vec4 texelColor = texture(texture0, fragTexCoord);
+
+ // NOTE: Implement here your fragment shader code
+
+ finalColor = texelColor*colDiffuse;
+}