summaryrefslogtreecommitdiffhomepage
path: root/examples/shaders/resources
diff options
context:
space:
mode:
authorRay <[email protected]>2017-05-16 00:14:14 +0200
committerRay <[email protected]>2017-05-16 00:14:14 +0200
commit65e6a6db53552fa241e81ae52b4258f7969b8771 (patch)
treefd4e83886e52c8aca3b9c5d9586a338546f2044e /examples/shaders/resources
parentc9d6b7e3567bdd02af014e8a7cd1956157307303 (diff)
downloadraylib-65e6a6db53552fa241e81ae52b4258f7969b8771.tar.gz
raylib-65e6a6db53552fa241e81ae52b4258f7969b8771.zip
Improved shaders_postprocessing example
Diffstat (limited to 'examples/shaders/resources')
-rw-r--r--examples/shaders/resources/shaders/glsl100/blur.fs22
-rw-r--r--examples/shaders/resources/shaders/glsl100/cross_hatching.fs10
-rw-r--r--examples/shaders/resources/shaders/glsl100/cross_stitching.fs9
-rw-r--r--examples/shaders/resources/shaders/glsl100/fisheye.fs4
-rw-r--r--examples/shaders/resources/shaders/glsl100/pixelizer.fs (renamed from examples/shaders/resources/shaders/glsl100/pixel.fs)8
-rw-r--r--examples/shaders/resources/shaders/glsl100/predator.fs11
-rw-r--r--examples/shaders/resources/shaders/glsl100/scanlines.fs6
-rw-r--r--examples/shaders/resources/shaders/glsl100/sobel.fs13
8 files changed, 41 insertions, 42 deletions
diff --git a/examples/shaders/resources/shaders/glsl100/blur.fs b/examples/shaders/resources/shaders/glsl100/blur.fs
index 1935f080..96f780e1 100644
--- a/examples/shaders/resources/shaders/glsl100/blur.fs
+++ b/examples/shaders/resources/shaders/glsl100/blur.fs
@@ -13,22 +13,22 @@ uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
// NOTE: Render size values must be passed from code
-const float renderWidth = 800;
-const float renderHeight = 450;
+const float renderWidth = 800.0;
+const float renderHeight = 450.0;
-float offset[3] = float[]( 0.0, 1.3846153846, 3.2307692308 );
-float weight[3] = float[]( 0.2270270270, 0.3162162162, 0.0702702703 );
+vec3 offset = vec3(0.0, 1.3846153846, 3.2307692308);
+vec3 weight = vec3(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++)
- {
- tc += texture2D(texture0, fragTexCoord + vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
- tc += texture2D(texture0, fragTexCoord - vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
- }
+ vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight.x;
+
+ tc += texture2D(texture0, fragTexCoord + vec2(offset.y)/renderWidth, 0.0).rgb*weight.y;
+ tc += texture2D(texture0, fragTexCoord - vec2(offset.y)/renderWidth, 0.0).rgb*weight.y;
+
+ tc += texture2D(texture0, fragTexCoord + vec2(offset.z)/renderWidth, 0.0).rgb*weight.z;
+ tc += texture2D(texture0, fragTexCoord - vec2(offset.z)/renderWidth, 0.0).rgb*weight.z;
gl_FragColor = vec4(tc, 1.0);
} \ No newline at end of file
diff --git a/examples/shaders/resources/shaders/glsl100/cross_hatching.fs b/examples/shaders/resources/shaders/glsl100/cross_hatching.fs
index ced0fd63..7d63b0a5 100644
--- a/examples/shaders/resources/shaders/glsl100/cross_hatching.fs
+++ b/examples/shaders/resources/shaders/glsl100/cross_hatching.fs
@@ -12,11 +12,11 @@ uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
-float hatchOffsetY = 5.0f;
-float lumThreshold01 = 0.9f;
-float lumThreshold02 = 0.7f;
-float lumThreshold03 = 0.5f;
-float lumThreshold04 = 0.3f;
+float hatchOffsetY = 5.0;
+float lumThreshold01 = 0.9;
+float lumThreshold02 = 0.7;
+float lumThreshold03 = 0.5;
+float lumThreshold04 = 0.3;
void main()
{
diff --git a/examples/shaders/resources/shaders/glsl100/cross_stitching.fs b/examples/shaders/resources/shaders/glsl100/cross_stitching.fs
index 67639a55..de6d4f40 100644
--- a/examples/shaders/resources/shaders/glsl100/cross_stitching.fs
+++ b/examples/shaders/resources/shaders/glsl100/cross_stitching.fs
@@ -13,12 +13,11 @@ uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
// NOTE: Render size values must be passed from code
-const float renderWidth = 800;
-const float renderHeight = 450;
+const float renderWidth = 800.0;
+const float renderHeight = 450.0;
-float stitchingSize = 6.0f;
-
-uniform int invert = 0;
+float stitchingSize = 6.0;
+int invert = 0;
vec4 PostFX(sampler2D tex, vec2 uv)
{
diff --git a/examples/shaders/resources/shaders/glsl100/fisheye.fs b/examples/shaders/resources/shaders/glsl100/fisheye.fs
index 461e1405..8beb3d4a 100644
--- a/examples/shaders/resources/shaders/glsl100/fisheye.fs
+++ b/examples/shaders/resources/shaders/glsl100/fisheye.fs
@@ -16,11 +16,11 @@ const float PI = 3.1415926535;
void main()
{
- float aperture = 178.0f;
+ float aperture = 178.0;
float apertureHalf = 0.5 * aperture * (PI / 180.0);
float maxFactor = sin(apertureHalf);
- vec2 uv = vec2(0);
+ vec2 uv = vec2(0.0);
vec2 xy = 2.0 * fragTexCoord.xy - 1.0;
float d = length(xy);
diff --git a/examples/shaders/resources/shaders/glsl100/pixel.fs b/examples/shaders/resources/shaders/glsl100/pixelizer.fs
index 41ba3ed6..44fb0ca2 100644
--- a/examples/shaders/resources/shaders/glsl100/pixel.fs
+++ b/examples/shaders/resources/shaders/glsl100/pixelizer.fs
@@ -13,11 +13,11 @@ uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
// NOTE: Render size values must be passed from code
-const float renderWidth = 800;
-const float renderHeight = 450;
+const float renderWidth = 800.0;
+const float renderHeight = 450.0;
-uniform float pixelWidth = 5.0f;
-uniform float pixelHeight = 5.0f;
+float pixelWidth = 5.0;
+float pixelHeight = 5.0;
void main()
{
diff --git a/examples/shaders/resources/shaders/glsl100/predator.fs b/examples/shaders/resources/shaders/glsl100/predator.fs
index efa7fe79..37dc0bdf 100644
--- a/examples/shaders/resources/shaders/glsl100/predator.fs
+++ b/examples/shaders/resources/shaders/glsl100/predator.fs
@@ -13,7 +13,7 @@ uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
void main()
-{
+{
vec3 color = texture2D(texture0, fragTexCoord).rgb;
vec3 colors[3];
colors[0] = vec3(0.0, 0.0, 1.0);
@@ -21,10 +21,11 @@ void main()
colors[2] = vec3(1.0, 0.0, 0.0);
float lum = (color.r + color.g + color.b)/3.0;
+
+ vec3 tc = vec3(0.0, 0.0, 0.0);
- int ix = (lum < 0.5)? 0:1;
-
- vec3 tc = mix(colors[ix], colors[ix+1], (lum-float(ix)*0.5)/0.5);
-
+ if (lum < 0.5) tc = mix(colors[0], colors[1], lum/0.5);
+ else tc = mix(colors[1], colors[2], (lum - 0.5)/0.5);
+
gl_FragColor = vec4(tc, 1.0);
} \ No newline at end of file
diff --git a/examples/shaders/resources/shaders/glsl100/scanlines.fs b/examples/shaders/resources/shaders/glsl100/scanlines.fs
index 529120d0..ce649e1a 100644
--- a/examples/shaders/resources/shaders/glsl100/scanlines.fs
+++ b/examples/shaders/resources/shaders/glsl100/scanlines.fs
@@ -12,8 +12,8 @@ uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
-float offset = 0;
-float frequency = 720/3.0;
+float offset = 0.0;
+float frequency = 450.0/3.0;
uniform float time;
@@ -40,5 +40,5 @@ void main()
vec4 color = texture2D(texture0, fragTexCoord);
- gl_FragColor = mix(vec4(0, 0.3, 0, 0), color, wavePos);
+ gl_FragColor = mix(vec4(0.0, 0.3, 0.0, 0.0), color, wavePos);
} \ No newline at end of file
diff --git a/examples/shaders/resources/shaders/glsl100/sobel.fs b/examples/shaders/resources/shaders/glsl100/sobel.fs
index 9617592e..745562ad 100644
--- a/examples/shaders/resources/shaders/glsl100/sobel.fs
+++ b/examples/shaders/resources/shaders/glsl100/sobel.fs
@@ -1,18 +1,17 @@
-#version 330
+#version 100
+
+precision mediump float;
// Input vertex attributes (from vertex shader)
-in vec2 fragTexCoord;
-in vec4 fragColor;
+varying vec2 fragTexCoord;
+varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
-// Output fragment color
-out vec4 finalColor;
-
// NOTE: Add here your custom variables
-uniform vec2 resolution = vec2(800, 450);
+vec2 resolution = vec2(800.0, 450.0);
void main()
{