summaryrefslogtreecommitdiffhomepage
path: root/docs/examples/web/resources/shaders
diff options
context:
space:
mode:
authorRay <[email protected]>2017-04-09 23:46:47 +0200
committerRay <[email protected]>2017-04-09 23:46:47 +0200
commitf7bebf9861734c47d0840868f243b186a59a96ba (patch)
treef5ca2d320c680ef5926b5455e4498646031cd5ac /docs/examples/web/resources/shaders
parent8374460c3986b16c68a6dea0643e9af541987d52 (diff)
downloadraylib-f7bebf9861734c47d0840868f243b186a59a96ba.tar.gz
raylib-f7bebf9861734c47d0840868f243b186a59a96ba.zip
Working on web examples
Reorganizing folders Review examples Work on makefile and loader.html
Diffstat (limited to 'docs/examples/web/resources/shaders')
-rw-r--r--docs/examples/web/resources/shaders/glsl100/base.vs26
-rw-r--r--docs/examples/web/resources/shaders/glsl100/bloom.fs37
-rw-r--r--docs/examples/web/resources/shaders/glsl100/distortion.fs54
-rw-r--r--docs/examples/web/resources/shaders/glsl100/grayscale.fs25
-rw-r--r--docs/examples/web/resources/shaders/glsl100/swirl.fs45
-rw-r--r--docs/examples/web/resources/shaders/glsl330/base.vs26
-rw-r--r--docs/examples/web/resources/shaders/glsl330/bloom.fs38
-rw-r--r--docs/examples/web/resources/shaders/glsl330/depth.fs27
-rw-r--r--docs/examples/web/resources/shaders/glsl330/distortion.fs56
-rw-r--r--docs/examples/web/resources/shaders/glsl330/grayscale.fs26
-rw-r--r--docs/examples/web/resources/shaders/glsl330/swirl.fs46
11 files changed, 0 insertions, 406 deletions
diff --git a/docs/examples/web/resources/shaders/glsl100/base.vs b/docs/examples/web/resources/shaders/glsl100/base.vs
deleted file mode 100644
index e9386939..00000000
--- a/docs/examples/web/resources/shaders/glsl100/base.vs
+++ /dev/null
@@ -1,26 +0,0 @@
-#version 100
-
-// Input vertex attributes
-attribute vec3 vertexPosition;
-attribute vec2 vertexTexCoord;
-attribute vec3 vertexNormal;
-attribute vec4 vertexColor;
-
-// 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()
-{
- // 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/docs/examples/web/resources/shaders/glsl100/bloom.fs b/docs/examples/web/resources/shaders/glsl100/bloom.fs
deleted file mode 100644
index 128736f2..00000000
--- a/docs/examples/web/resources/shaders/glsl100/bloom.fs
+++ /dev/null
@@ -1,37 +0,0 @@
-#version 100
-
-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
-
-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 += texture2D(texture0, fragTexCoord + vec2(j, i)*0.004) * 0.25;
- }
- }
-
- // Texel color fetching from texture sampler
- vec4 texelColor = texture2D(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/docs/examples/web/resources/shaders/glsl100/distortion.fs b/docs/examples/web/resources/shaders/glsl100/distortion.fs
deleted file mode 100644
index 50116ce0..00000000
--- a/docs/examples/web/resources/shaders/glsl100/distortion.fs
+++ /dev/null
@@ -1,54 +0,0 @@
-#version 100
-
-precision mediump float;
-
-// Input vertex attributes (from vertex shader)
-varying vec2 fragTexCoord;
-
-// Input uniform values
-uniform sampler2D texture0;
-
-// NOTE: Default parameters for Oculus Rift DK2 device
-const vec2 LeftLensCenter = vec2(0.2863248, 0.5);
-const vec2 RightLensCenter = vec2(0.7136753, 0.5);
-const vec2 LeftScreenCenter = vec2(0.25, 0.5);
-const vec2 RightScreenCenter = vec2(0.75, 0.5);
-const vec2 Scale = vec2(0.25, 0.45);
-const vec2 ScaleIn = vec2(4.0, 2.5);
-const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0);
-const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
-
-void main()
-{
- // The following two variables need to be set per eye
- vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter;
- vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter;
-
- // Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter)
- vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1]
- float rSq = theta.x*theta.x + theta.y*theta.y;
- vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq);
- //vec2 tc = LensCenter + Scale*theta1;
-
- // Detect whether blue texture coordinates are out of range since these will scaled out the furthest
- vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq);
- vec2 tcBlue = LensCenter + Scale*thetaBlue;
-
- if (any(bvec2(clamp(tcBlue, ScreenCenter - vec2(0.25, 0.5), ScreenCenter + vec2(0.25, 0.5)) - tcBlue))) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
- else
- {
- // Do blue texture lookup
- float blue = texture2D(texture0, tcBlue).b;
-
- // Do green lookup (no scaling)
- vec2 tcGreen = LensCenter + Scale*theta1;
- float green = texture2D(texture0, tcGreen).g;
-
- // Do red scale and lookup
- vec2 thetaRed = theta1*(ChromaAbParam.x + ChromaAbParam.y*rSq);
- vec2 tcRed = LensCenter + Scale*thetaRed;
- float red = texture2D(texture0, tcRed).r;
-
- gl_FragColor = vec4(red, green, blue, 1.0);
- }
-}
diff --git a/docs/examples/web/resources/shaders/glsl100/grayscale.fs b/docs/examples/web/resources/shaders/glsl100/grayscale.fs
deleted file mode 100644
index 15174ea5..00000000
--- a/docs/examples/web/resources/shaders/glsl100/grayscale.fs
+++ /dev/null
@@ -1,25 +0,0 @@
-#version 100
-
-precision mediump float;
-
-// Input vertex attributes (from vertex shader)
-varying vec2 fragTexCoord;
-varying vec4 fragColor;
-
-// Input uniform values
-uniform sampler2D texture0;
-uniform vec4 colDiffuse;
-
-// NOTE: Add here your custom variables
-
-void main()
-{
- // Texel color fetching from texture sampler
- vec4 texelColor = texture2D(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
- gl_FragColor = vec4(gray, gray, gray, texelColor.a);
-} \ No newline at end of file
diff --git a/docs/examples/web/resources/shaders/glsl100/swirl.fs b/docs/examples/web/resources/shaders/glsl100/swirl.fs
deleted file mode 100644
index 95de61fa..00000000
--- a/docs/examples/web/resources/shaders/glsl100/swirl.fs
+++ /dev/null
@@ -1,45 +0,0 @@
-#version 100
-
-precision mediump float;
-
-// Input vertex attributes (from vertex shader)
-varying vec2 fragTexCoord;
-varying vec4 fragColor;
-
-// Input uniform values
-uniform sampler2D texture0;
-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...
-
-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;
- vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;;
-
- gl_FragColor = vec4(color.rgb, 1.0);;
-} \ No newline at end of file
diff --git a/docs/examples/web/resources/shaders/glsl330/base.vs b/docs/examples/web/resources/shaders/glsl330/base.vs
deleted file mode 100644
index 638cb8ae..00000000
--- a/docs/examples/web/resources/shaders/glsl330/base.vs
+++ /dev/null
@@ -1,26 +0,0 @@
-#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/docs/examples/web/resources/shaders/glsl330/bloom.fs b/docs/examples/web/resources/shaders/glsl330/bloom.fs
deleted file mode 100644
index 0307bc06..00000000
--- a/docs/examples/web/resources/shaders/glsl330/bloom.fs
+++ /dev/null
@@ -1,38 +0,0 @@
-#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/docs/examples/web/resources/shaders/glsl330/depth.fs b/docs/examples/web/resources/shaders/glsl330/depth.fs
deleted file mode 100644
index 06d399f9..00000000
--- a/docs/examples/web/resources/shaders/glsl330/depth.fs
+++ /dev/null
@@ -1,27 +0,0 @@
-#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/docs/examples/web/resources/shaders/glsl330/distortion.fs b/docs/examples/web/resources/shaders/glsl330/distortion.fs
deleted file mode 100644
index cb4be8fc..00000000
--- a/docs/examples/web/resources/shaders/glsl330/distortion.fs
+++ /dev/null
@@ -1,56 +0,0 @@
-#version 330
-
-// Input vertex attributes (from vertex shader)
-in vec2 fragTexCoord;
-
-// Input uniform values
-uniform sampler2D texture0;
-
-// Output fragment color
-out vec4 finalColor;
-
-// NOTE: Default parameters for Oculus Rift DK2 device
-const vec2 LeftLensCenter = vec2(0.2863248, 0.5);
-const vec2 RightLensCenter = vec2(0.7136753, 0.5);
-const vec2 LeftScreenCenter = vec2(0.25, 0.5);
-const vec2 RightScreenCenter = vec2(0.75, 0.5);
-const vec2 Scale = vec2(0.25, 0.45);
-const vec2 ScaleIn = vec2(4.0, 2.5);
-const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0);
-const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
-
-void main()
-{
- // The following two variables need to be set per eye
- vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter;
- vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter;
-
- // Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter)
- vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1]
- float rSq = theta.x*theta.x + theta.y*theta.y;
- vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq);
- //vec2 tc = LensCenter + Scale*theta1;
-
- // Detect whether blue texture coordinates are out of range since these will scaled out the furthest
- vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq);
- vec2 tcBlue = LensCenter + Scale*thetaBlue;
-
- if (any(bvec2(clamp(tcBlue, ScreenCenter - vec2(0.25, 0.5), ScreenCenter + vec2(0.25, 0.5)) - tcBlue))) finalColor = vec4(0.0, 0.0, 0.0, 1.0);
- else
- {
- // Do blue texture lookup
- float blue = texture(texture0, tcBlue).b;
-
- // Do green lookup (no scaling)
- vec2 tcGreen = LensCenter + Scale*theta1;
- float green = texture(texture0, tcGreen).g;
-
- // Do red scale and lookup
- vec2 thetaRed = theta1*(ChromaAbParam.x + ChromaAbParam.y*rSq);
- vec2 tcRed = LensCenter + Scale*thetaRed;
- float red = texture(texture0, tcRed).r;
-
- finalColor = vec4(red, green, blue, 1.0);
- }
-}
-
diff --git a/docs/examples/web/resources/shaders/glsl330/grayscale.fs b/docs/examples/web/resources/shaders/glsl330/grayscale.fs
deleted file mode 100644
index 5b3e11be..00000000
--- a/docs/examples/web/resources/shaders/glsl330/grayscale.fs
+++ /dev/null
@@ -1,26 +0,0 @@
-#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/docs/examples/web/resources/shaders/glsl330/swirl.fs b/docs/examples/web/resources/shaders/glsl330/swirl.fs
deleted file mode 100644
index 788ffeec..00000000
--- a/docs/examples/web/resources/shaders/glsl330/swirl.fs
+++ /dev/null
@@ -1,46 +0,0 @@
-#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;
- vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;;
-
- finalColor = vec4(color.rgb, 1.0);;
-} \ No newline at end of file