From aba25e9ba379cdf2e68b65f55dd08ab4e0d713d8 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 15 May 2017 22:48:04 +0200 Subject: Move shaders to examples --- examples/shaders/resources/shaders/glsl100/base.fs | 24 ++++ examples/shaders/resources/shaders/glsl100/blur.fs | 34 +++++ .../resources/shaders/glsl100/cross_hatching.fs | 47 +++++++ .../resources/shaders/glsl100/cross_stitching.fs | 58 ++++++++ .../resources/shaders/glsl100/dream_vision.fs | 37 +++++ .../shaders/resources/shaders/glsl100/fisheye.fs | 43 ++++++ .../shaders/resources/shaders/glsl100/pixel.fs | 32 +++++ .../resources/shaders/glsl100/posterization.fs | 29 ++++ .../shaders/resources/shaders/glsl100/predator.fs | 30 +++++ .../shaders/resources/shaders/glsl100/scanlines.fs | 44 ++++++ .../shaders/resources/shaders/glsl100/sobel.fs | 41 ++++++ .../shaders/resources/shaders/glsl100/swirl.fs | 5 +- examples/shaders/resources/shaders/glsl330/base.fs | 25 ++++ examples/shaders/resources/shaders/glsl330/blur.fs | 35 +++++ .../resources/shaders/glsl330/cross_hatching.fs | 48 +++++++ .../resources/shaders/glsl330/cross_stitching.fs | 59 ++++++++ .../shaders/resources/shaders/glsl330/depth.fs | 2 +- .../resources/shaders/glsl330/dream_vision.fs | 34 +++++ .../shaders/resources/shaders/glsl330/fisheye.fs | 40 ++++++ .../shaders/resources/shaders/glsl330/overdraw.fs | 26 ++++ .../shaders/resources/shaders/glsl330/pixelizer.fs | 33 +++++ .../resources/shaders/glsl330/posterization.fs | 31 +++++ .../shaders/resources/shaders/glsl330/predator.fs | 32 +++++ .../shaders/resources/shaders/glsl330/scanlines.fs | 49 +++++++ .../shaders/resources/shaders/glsl330/sobel.fs | 41 ++++++ .../shaders/resources/shaders/glsl330/swirl.fs | 5 +- shaders/glsl100/base.vs | 26 ---- shaders/glsl100/bloom.fs | 39 ------ shaders/glsl100/blur.fs | 34 ----- shaders/glsl100/cross_hatching.fs | 47 ------- shaders/glsl100/cross_stitching.fs | 58 -------- shaders/glsl100/dream_vision.fs | 37 ----- shaders/glsl100/fisheye.fs | 43 ------ shaders/glsl100/grayscale.fs | 25 ---- shaders/glsl100/pixel.fs | 32 ----- shaders/glsl100/posterization.fs | 29 ---- shaders/glsl100/predator.fs | 30 ----- shaders/glsl100/scanlines.fs | 44 ------ shaders/glsl100/standard.fs | 150 --------------------- shaders/glsl100/standard.vs | 23 ---- shaders/glsl100/swirl.fs | 46 ------- shaders/glsl100/template.fs | 23 ---- shaders/glsl330/base.vs | 26 ---- shaders/glsl330/bloom.fs | 40 ------ shaders/glsl330/blur.fs | 35 ----- shaders/glsl330/cross_hatching.fs | 48 ------- shaders/glsl330/cross_stitching.fs | 59 -------- shaders/glsl330/depth.fs | 27 ---- shaders/glsl330/dream_vision.fs | 34 ----- shaders/glsl330/fisheye.fs | 40 ------ shaders/glsl330/grayscale.fs | 26 ---- shaders/glsl330/pixel.fs | 33 ----- shaders/glsl330/posterization.fs | 31 ----- shaders/glsl330/predator.fs | 32 ----- shaders/glsl330/scanlines.fs | 49 ------- shaders/glsl330/standard.fs | 150 --------------------- shaders/glsl330/standard.vs | 23 ---- shaders/glsl330/swirl.fs | 47 ------- shaders/glsl330/template.fs | 24 ---- 59 files changed, 879 insertions(+), 1415 deletions(-) create mode 100644 examples/shaders/resources/shaders/glsl100/base.fs create mode 100644 examples/shaders/resources/shaders/glsl100/blur.fs create mode 100644 examples/shaders/resources/shaders/glsl100/cross_hatching.fs create mode 100644 examples/shaders/resources/shaders/glsl100/cross_stitching.fs create mode 100644 examples/shaders/resources/shaders/glsl100/dream_vision.fs create mode 100644 examples/shaders/resources/shaders/glsl100/fisheye.fs create mode 100644 examples/shaders/resources/shaders/glsl100/pixel.fs create mode 100644 examples/shaders/resources/shaders/glsl100/posterization.fs create mode 100644 examples/shaders/resources/shaders/glsl100/predator.fs create mode 100644 examples/shaders/resources/shaders/glsl100/scanlines.fs create mode 100644 examples/shaders/resources/shaders/glsl100/sobel.fs create mode 100644 examples/shaders/resources/shaders/glsl330/base.fs create mode 100644 examples/shaders/resources/shaders/glsl330/blur.fs create mode 100644 examples/shaders/resources/shaders/glsl330/cross_hatching.fs create mode 100644 examples/shaders/resources/shaders/glsl330/cross_stitching.fs create mode 100644 examples/shaders/resources/shaders/glsl330/dream_vision.fs create mode 100644 examples/shaders/resources/shaders/glsl330/fisheye.fs create mode 100644 examples/shaders/resources/shaders/glsl330/overdraw.fs create mode 100644 examples/shaders/resources/shaders/glsl330/pixelizer.fs create mode 100644 examples/shaders/resources/shaders/glsl330/posterization.fs create mode 100644 examples/shaders/resources/shaders/glsl330/predator.fs create mode 100644 examples/shaders/resources/shaders/glsl330/scanlines.fs create mode 100644 examples/shaders/resources/shaders/glsl330/sobel.fs delete mode 100644 shaders/glsl100/base.vs delete mode 100644 shaders/glsl100/bloom.fs delete mode 100644 shaders/glsl100/blur.fs delete mode 100644 shaders/glsl100/cross_hatching.fs delete mode 100644 shaders/glsl100/cross_stitching.fs delete mode 100644 shaders/glsl100/dream_vision.fs delete mode 100644 shaders/glsl100/fisheye.fs delete mode 100644 shaders/glsl100/grayscale.fs delete mode 100644 shaders/glsl100/pixel.fs delete mode 100644 shaders/glsl100/posterization.fs delete mode 100644 shaders/glsl100/predator.fs delete mode 100644 shaders/glsl100/scanlines.fs delete mode 100644 shaders/glsl100/standard.fs delete mode 100644 shaders/glsl100/standard.vs delete mode 100644 shaders/glsl100/swirl.fs delete mode 100644 shaders/glsl100/template.fs delete mode 100644 shaders/glsl330/base.vs delete mode 100644 shaders/glsl330/bloom.fs delete mode 100644 shaders/glsl330/blur.fs delete mode 100644 shaders/glsl330/cross_hatching.fs delete mode 100644 shaders/glsl330/cross_stitching.fs delete mode 100644 shaders/glsl330/depth.fs delete mode 100644 shaders/glsl330/dream_vision.fs delete mode 100644 shaders/glsl330/fisheye.fs delete mode 100644 shaders/glsl330/grayscale.fs delete mode 100644 shaders/glsl330/pixel.fs delete mode 100644 shaders/glsl330/posterization.fs delete mode 100644 shaders/glsl330/predator.fs delete mode 100644 shaders/glsl330/scanlines.fs delete mode 100644 shaders/glsl330/standard.fs delete mode 100644 shaders/glsl330/standard.vs delete mode 100644 shaders/glsl330/swirl.fs delete mode 100644 shaders/glsl330/template.fs diff --git a/examples/shaders/resources/shaders/glsl100/base.fs b/examples/shaders/resources/shaders/glsl100/base.fs new file mode 100644 index 00000000..b004ba0b --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/base.fs @@ -0,0 +1,24 @@ +#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 +uniform vec2 resolution = vec2(800, 450); + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture2D(texture0, fragTexCoord); + + // NOTE: Implement here your fragment shader code + + gl_FragColor = texelColor*colDiffuse; +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/blur.fs b/examples/shaders/resources/shaders/glsl100/blur.fs new file mode 100644 index 00000000..1935f080 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/blur.fs @@ -0,0 +1,34 @@ +#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 + +// 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 ); + +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]; + } + + 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 new file mode 100644 index 00000000..ced0fd63 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/cross_hatching.fs @@ -0,0 +1,47 @@ +# 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 + +float hatchOffsetY = 5.0f; +float lumThreshold01 = 0.9f; +float lumThreshold02 = 0.7f; +float lumThreshold03 = 0.5f; +float lumThreshold04 = 0.3f; + +void main() +{ + vec3 tc = vec3(1.0, 1.0, 1.0); + float lum = length(texture2D(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); + } + + gl_FragColor = vec4(tc, 1.0); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/cross_stitching.fs b/examples/shaders/resources/shaders/glsl100/cross_stitching.fs new file mode 100644 index 00000000..67639a55 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/cross_stitching.fs @@ -0,0 +1,58 @@ +# 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 + +// NOTE: Render size values must be passed from code +const float renderWidth = 800; +const float renderHeight = 450; + +float stitchingSize = 6.0f; + +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 = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4; + } + else + { + if (invert == 1) c = texture2D(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; + + gl_FragColor = vec4(tc, 1.0); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/dream_vision.fs b/examples/shaders/resources/shaders/glsl100/dream_vision.fs new file mode 100644 index 00000000..fa9c5b77 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/dream_vision.fs @@ -0,0 +1,37 @@ +#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() +{ + vec4 color = texture2D(texture0, fragTexCoord); + + color += texture2D(texture0, fragTexCoord + 0.001); + color += texture2D(texture0, fragTexCoord + 0.003); + color += texture2D(texture0, fragTexCoord + 0.005); + color += texture2D(texture0, fragTexCoord + 0.007); + color += texture2D(texture0, fragTexCoord + 0.009); + color += texture2D(texture0, fragTexCoord + 0.011); + + color += texture2D(texture0, fragTexCoord - 0.001); + color += texture2D(texture0, fragTexCoord - 0.003); + color += texture2D(texture0, fragTexCoord - 0.005); + color += texture2D(texture0, fragTexCoord - 0.007); + color += texture2D(texture0, fragTexCoord - 0.009); + color += texture2D(texture0, fragTexCoord - 0.011); + + color.rgb = vec3((color.r + color.g + color.b)/3.0); + color = color/9.5; + + gl_FragColor = color; +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/fisheye.fs b/examples/shaders/resources/shaders/glsl100/fisheye.fs new file mode 100644 index 00000000..461e1405 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/fisheye.fs @@ -0,0 +1,43 @@ +#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 PI = 3.1415926535; + +void main() +{ + float aperture = 178.0f; + 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; + } + + gl_FragColor = texture2D(texture0, uv); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/pixel.fs b/examples/shaders/resources/shaders/glsl100/pixel.fs new file mode 100644 index 00000000..41ba3ed6 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/pixel.fs @@ -0,0 +1,32 @@ +#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 + +// NOTE: Render size values must be passed from code +const float renderWidth = 800; +const float renderHeight = 450; + +uniform float pixelWidth = 5.0f; +uniform float pixelHeight = 5.0f; + +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 = texture2D(texture0, coord).rgb; + + gl_FragColor = vec4(tc, 1.0); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/posterization.fs b/examples/shaders/resources/shaders/glsl100/posterization.fs new file mode 100644 index 00000000..a7942c82 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/posterization.fs @@ -0,0 +1,29 @@ +#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 + +float gamma = 0.6; +float numColors = 8.0; + +void main() +{ + vec3 color = texture2D(texture0, fragTexCoord.xy).rgb; + + color = pow(color, vec3(gamma, gamma, gamma)); + color = color*numColors; + color = floor(color); + color = color/numColors; + color = pow(color, vec3(1.0/gamma)); + + gl_FragColor = vec4(color, 1.0); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/predator.fs b/examples/shaders/resources/shaders/glsl100/predator.fs new file mode 100644 index 00000000..efa7fe79 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/predator.fs @@ -0,0 +1,30 @@ +#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() +{ + vec3 color = texture2D(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 = (color.r + color.g + color.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); + + 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 new file mode 100644 index 00000000..529120d0 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/scanlines.fs @@ -0,0 +1,44 @@ +#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 + +float offset = 0; +float frequency = 720/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 = texture2D(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); + + vec4 color = texture2D(texture0, fragTexCoord); + + gl_FragColor = mix(vec4(0, 0.3, 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 new file mode 100644 index 00000000..9617592e --- /dev/null +++ b/examples/shaders/resources/shaders/glsl100/sobel.fs @@ -0,0 +1,41 @@ +#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 +uniform vec2 resolution = vec2(800, 450); + +void main() +{ + float x = 1.0/resolution.x; + float y = 1.0/resolution.y; + + vec4 horizEdge = vec4(0.0); + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + + vec4 vertEdge = vec4(0.0); + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + + vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); + + gl_FragColor = vec4(edge, texture2D(texture0, fragTexCoord).a); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl100/swirl.fs b/examples/shaders/resources/shaders/glsl100/swirl.fs index ca7668b2..b969aab7 100644 --- a/examples/shaders/resources/shaders/glsl100/swirl.fs +++ b/examples/shaders/resources/shaders/glsl100/swirl.fs @@ -12,8 +12,9 @@ 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... +// NOTE: Render size values should be passed from code +const float renderWidth = 800; +const float renderHeight = 450; float radius = 250.0; float angle = 0.8; diff --git a/examples/shaders/resources/shaders/glsl330/base.fs b/examples/shaders/resources/shaders/glsl330/base.fs new file mode 100644 index 00000000..f1418df1 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/base.fs @@ -0,0 +1,25 @@ +#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; +} + diff --git a/examples/shaders/resources/shaders/glsl330/blur.fs b/examples/shaders/resources/shaders/glsl330/blur.fs new file mode 100644 index 00000000..e4df406d --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/blur.fs @@ -0,0 +1,35 @@ +#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 + +// 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); + +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/examples/shaders/resources/shaders/glsl330/cross_hatching.fs b/examples/shaders/resources/shaders/glsl330/cross_hatching.fs new file mode 100644 index 00000000..f95ad075 --- /dev/null +++ b/examples/shaders/resources/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 colDiffuse; + +// 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/examples/shaders/resources/shaders/glsl330/cross_stitching.fs b/examples/shaders/resources/shaders/glsl330/cross_stitching.fs new file mode 100644 index 00000000..9cdd36ca --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/cross_stitching.fs @@ -0,0 +1,59 @@ +#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 + +// NOTE: Render size values must be passed from code +const float renderWidth = 800.0; +const float renderHeight = 450.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/examples/shaders/resources/shaders/glsl330/depth.fs b/examples/shaders/resources/shaders/glsl330/depth.fs index 06d399f9..2422f390 100644 --- a/examples/shaders/resources/shaders/glsl330/depth.fs +++ b/examples/shaders/resources/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/examples/shaders/resources/shaders/glsl330/dream_vision.fs b/examples/shaders/resources/shaders/glsl330/dream_vision.fs new file mode 100644 index 00000000..03115862 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/dream_vision.fs @@ -0,0 +1,34 @@ +#version 330 + +in vec2 fragTexCoord; + +out vec4 fragColor; + +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// 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/examples/shaders/resources/shaders/glsl330/fisheye.fs b/examples/shaders/resources/shaders/glsl330/fisheye.fs new file mode 100644 index 00000000..e85d7c9d --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/fisheye.fs @@ -0,0 +1,40 @@ +#version 330 + +in vec2 fragTexCoord; + +out vec4 fragColor; + +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// 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/examples/shaders/resources/shaders/glsl330/overdraw.fs b/examples/shaders/resources/shaders/glsl330/overdraw.fs new file mode 100644 index 00000000..435217c3 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/overdraw.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() +{ + // To show overdraw, we just render all the fragments + // with a solid color and some transparency + + // NOTE: This is not a postpro render, + // it will only render all screen texture in a plain color + + finalColor = vec4(1.0, 0.0, 0.0, 0.2); +} + diff --git a/examples/shaders/resources/shaders/glsl330/pixelizer.fs b/examples/shaders/resources/shaders/glsl330/pixelizer.fs new file mode 100644 index 00000000..cf8aec44 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/pixelizer.fs @@ -0,0 +1,33 @@ +#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 + +// 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; + +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/examples/shaders/resources/shaders/glsl330/posterization.fs b/examples/shaders/resources/shaders/glsl330/posterization.fs new file mode 100644 index 00000000..be2b5dd6 --- /dev/null +++ b/examples/shaders/resources/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 colDiffuse; + +// 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/examples/shaders/resources/shaders/glsl330/predator.fs b/examples/shaders/resources/shaders/glsl330/predator.fs new file mode 100644 index 00000000..6a55c762 --- /dev/null +++ b/examples/shaders/resources/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 colDiffuse; + +// 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/examples/shaders/resources/shaders/glsl330/scanlines.fs b/examples/shaders/resources/shaders/glsl330/scanlines.fs new file mode 100644 index 00000000..22dc9cd5 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/scanlines.fs @@ -0,0 +1,49 @@ +#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 + +// NOTE: Render size values must be passed from code +const float renderWidth = 800; +const float renderHeight = 450; +float offset = 0.0; + +uniform float time; + +void main() +{ + float frequency = renderHeight/3.0; +/* + // 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/examples/shaders/resources/shaders/glsl330/sobel.fs b/examples/shaders/resources/shaders/glsl330/sobel.fs new file mode 100644 index 00000000..a1430cdd --- /dev/null +++ b/examples/shaders/resources/shaders/glsl330/sobel.fs @@ -0,0 +1,41 @@ +#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 +uniform vec2 resolution = vec2(800, 450); + +void main() +{ + float x = 1.0/resolution.x; + float y = 1.0/resolution.y; + + vec4 horizEdge = vec4(0.0); + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + + vec4 vertEdge = vec4(0.0); + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + + vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); + + finalColor = vec4(edge, texture2D(texture0, fragTexCoord).a); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/swirl.fs b/examples/shaders/resources/shaders/glsl330/swirl.fs index 5d238ac9..4741e597 100644 --- a/examples/shaders/resources/shaders/glsl330/swirl.fs +++ b/examples/shaders/resources/shaders/glsl330/swirl.fs @@ -13,8 +13,9 @@ 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 should be passed from code +const float renderWidth = 800; +const float renderHeight = 450; float radius = 250.0; float angle = 0.8; diff --git a/shaders/glsl100/base.vs b/shaders/glsl100/base.vs deleted file mode 100644 index e9386939..00000000 --- a/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/shaders/glsl100/bloom.fs b/shaders/glsl100/bloom.fs deleted file mode 100644 index a8e1d20f..00000000 --- a/shaders/glsl100/bloom.fs +++ /dev/null @@ -1,39 +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 vec2 size = vec2(800, 450); // render size -const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance -const float quality = 2.5; // lower = smaller glow, better quality - -void main() -{ - vec4 sum = vec4(0); - vec2 sizeFactor = vec2(1)/size*quality; - - // Texel color fetching from texture sampler - vec4 source = texture2D(texture0, fragTexCoord); - - const int range = 2; // should be = (samples - 1)/2; - - for (int x = -range; x <= range; x++) - { - for (int y = -range; y <= range; y++) - { - sum += texture2D(texture0, fragTexCoord + vec2(x, y)*sizeFactor); - } - } - - // Calculate final fragment color - gl_FragColor = ((sum/(samples*samples)) + source)*colDiffuse; -} \ No newline at end of file diff --git a/shaders/glsl100/blur.fs b/shaders/glsl100/blur.fs deleted file mode 100644 index 1935f080..00000000 --- a/shaders/glsl100/blur.fs +++ /dev/null @@ -1,34 +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 - -// 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 ); - -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]; - } - - gl_FragColor = vec4(tc, 1.0); -} \ No newline at end of file diff --git a/shaders/glsl100/cross_hatching.fs b/shaders/glsl100/cross_hatching.fs deleted file mode 100644 index ced0fd63..00000000 --- a/shaders/glsl100/cross_hatching.fs +++ /dev/null @@ -1,47 +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 - -float hatchOffsetY = 5.0f; -float lumThreshold01 = 0.9f; -float lumThreshold02 = 0.7f; -float lumThreshold03 = 0.5f; -float lumThreshold04 = 0.3f; - -void main() -{ - vec3 tc = vec3(1.0, 1.0, 1.0); - float lum = length(texture2D(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); - } - - gl_FragColor = vec4(tc, 1.0); -} \ No newline at end of file diff --git a/shaders/glsl100/cross_stitching.fs b/shaders/glsl100/cross_stitching.fs deleted file mode 100644 index 67639a55..00000000 --- a/shaders/glsl100/cross_stitching.fs +++ /dev/null @@ -1,58 +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 - -// NOTE: Render size values must be passed from code -const float renderWidth = 800; -const float renderHeight = 450; - -float stitchingSize = 6.0f; - -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 = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4; - } - else - { - if (invert == 1) c = texture2D(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; - - gl_FragColor = vec4(tc, 1.0); -} \ No newline at end of file diff --git a/shaders/glsl100/dream_vision.fs b/shaders/glsl100/dream_vision.fs deleted file mode 100644 index fa9c5b77..00000000 --- a/shaders/glsl100/dream_vision.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 colDiffuse; - -// NOTE: Add here your custom variables - -void main() -{ - vec4 color = texture2D(texture0, fragTexCoord); - - color += texture2D(texture0, fragTexCoord + 0.001); - color += texture2D(texture0, fragTexCoord + 0.003); - color += texture2D(texture0, fragTexCoord + 0.005); - color += texture2D(texture0, fragTexCoord + 0.007); - color += texture2D(texture0, fragTexCoord + 0.009); - color += texture2D(texture0, fragTexCoord + 0.011); - - color += texture2D(texture0, fragTexCoord - 0.001); - color += texture2D(texture0, fragTexCoord - 0.003); - color += texture2D(texture0, fragTexCoord - 0.005); - color += texture2D(texture0, fragTexCoord - 0.007); - color += texture2D(texture0, fragTexCoord - 0.009); - color += texture2D(texture0, fragTexCoord - 0.011); - - color.rgb = vec3((color.r + color.g + color.b)/3.0); - color = color/9.5; - - gl_FragColor = color; -} \ No newline at end of file diff --git a/shaders/glsl100/fisheye.fs b/shaders/glsl100/fisheye.fs deleted file mode 100644 index 461e1405..00000000 --- a/shaders/glsl100/fisheye.fs +++ /dev/null @@ -1,43 +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 PI = 3.1415926535; - -void main() -{ - float aperture = 178.0f; - 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; - } - - gl_FragColor = texture2D(texture0, uv); -} \ No newline at end of file diff --git a/shaders/glsl100/grayscale.fs b/shaders/glsl100/grayscale.fs deleted file mode 100644 index 15174ea5..00000000 --- a/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/shaders/glsl100/pixel.fs b/shaders/glsl100/pixel.fs deleted file mode 100644 index 41ba3ed6..00000000 --- a/shaders/glsl100/pixel.fs +++ /dev/null @@ -1,32 +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 - -// NOTE: Render size values must be passed from code -const float renderWidth = 800; -const float renderHeight = 450; - -uniform float pixelWidth = 5.0f; -uniform float pixelHeight = 5.0f; - -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 = texture2D(texture0, coord).rgb; - - gl_FragColor = vec4(tc, 1.0); -} \ No newline at end of file diff --git a/shaders/glsl100/posterization.fs b/shaders/glsl100/posterization.fs deleted file mode 100644 index a7942c82..00000000 --- a/shaders/glsl100/posterization.fs +++ /dev/null @@ -1,29 +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 - -float gamma = 0.6; -float numColors = 8.0; - -void main() -{ - vec3 color = texture2D(texture0, fragTexCoord.xy).rgb; - - color = pow(color, vec3(gamma, gamma, gamma)); - color = color*numColors; - color = floor(color); - color = color/numColors; - color = pow(color, vec3(1.0/gamma)); - - gl_FragColor = vec4(color, 1.0); -} \ No newline at end of file diff --git a/shaders/glsl100/predator.fs b/shaders/glsl100/predator.fs deleted file mode 100644 index efa7fe79..00000000 --- a/shaders/glsl100/predator.fs +++ /dev/null @@ -1,30 +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() -{ - vec3 color = texture2D(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 = (color.r + color.g + color.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); - - gl_FragColor = vec4(tc, 1.0); -} \ No newline at end of file diff --git a/shaders/glsl100/scanlines.fs b/shaders/glsl100/scanlines.fs deleted file mode 100644 index 529120d0..00000000 --- a/shaders/glsl100/scanlines.fs +++ /dev/null @@ -1,44 +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 - -float offset = 0; -float frequency = 720/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 = texture2D(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); - - vec4 color = texture2D(texture0, fragTexCoord); - - gl_FragColor = mix(vec4(0, 0.3, 0, 0), color, wavePos); -} \ No newline at end of file diff --git a/shaders/glsl100/standard.fs b/shaders/glsl100/standard.fs deleted file mode 100644 index 3e78022d..00000000 --- a/shaders/glsl100/standard.fs +++ /dev/null @@ -1,150 +0,0 @@ -#version 100 - -precision mediump float; - -varying vec3 fragPosition; -varying vec2 fragTexCoord; -varying vec4 fragColor; -varying vec3 fragNormal; - -uniform sampler2D texture0; -uniform sampler2D texture1; -uniform sampler2D texture2; - -uniform vec4 colAmbient; -uniform vec4 colDiffuse; -uniform vec4 colSpecular; -uniform float glossiness; - -uniform int useNormal; -uniform int useSpecular; - -uniform mat4 modelMatrix; -uniform vec3 viewDir; - -struct Light { - int enabled; - int type; - vec3 position; - vec3 direction; - vec4 diffuse; - float intensity; - float radius; - float coneAngle; -}; - -const int maxLights = 8; -uniform Light lights[maxLights]; - -vec3 CalcPointLight(Light l, vec3 n, vec3 v, float s) -{ - vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); - vec3 surfaceToLight = l.position - surfacePos; - - // Diffuse shading - float brightness = clamp(dot(n, surfaceToLight)/(length(surfaceToLight)*length(n)), 0, 1); - float diff = 1.0/dot(surfaceToLight/l.radius, surfaceToLight/l.radius)*brightness*l.intensity; - - // Specular shading - float spec = 0.0; - if (diff > 0.0) - { - vec3 h = normalize(-l.direction + v); - spec = pow(dot(n, h), 3 + glossiness)*s; - } - - return (diff*l.diffuse.rgb + spec*colSpecular.rgb); -} - -vec3 CalcDirectionalLight(Light l, vec3 n, vec3 v, float s) -{ - vec3 lightDir = normalize(-l.direction); - - // Diffuse shading - float diff = clamp(dot(n, lightDir), 0.0, 1.0)*l.intensity; - - // Specular shading - float spec = 0.0; - if (diff > 0.0) - { - vec3 h = normalize(lightDir + v); - spec = pow(dot(n, h), 3 + glossiness)*s; - } - - // Combine results - return (diff*l.intensity*l.diffuse.rgb + spec*colSpecular.rgb); -} - -vec3 CalcSpotLight(Light l, vec3 n, vec3 v, float s) -{ - vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); - vec3 lightToSurface = normalize(surfacePos - l.position); - vec3 lightDir = normalize(-l.direction); - - // Diffuse shading - float diff = clamp(dot(n, lightDir), 0.0, 1.0)*l.intensity; - - // Spot attenuation - float attenuation = clamp(dot(n, lightToSurface), 0.0, 1.0); - attenuation = dot(lightToSurface, -lightDir); - - float lightToSurfaceAngle = degrees(acos(attenuation)); - if (lightToSurfaceAngle > l.coneAngle) attenuation = 0.0; - - float falloff = (l.coneAngle - lightToSurfaceAngle)/l.coneAngle; - - // Combine diffuse and attenuation - float diffAttenuation = diff*attenuation; - - // Specular shading - float spec = 0.0; - if (diffAttenuation > 0.0) - { - vec3 h = normalize(lightDir + v); - spec = pow(dot(n, h), 3 + glossiness)*s; - } - - return (falloff*(diffAttenuation*l.diffuse.rgb + spec*colSpecular.rgb)); -} - -void main() -{ - // Calculate fragment normal in screen space - // NOTE: important to multiply model matrix by fragment normal to apply model transformation (rotation and scale) - mat3 normalMatrix = transpose(inverse(mat3(modelMatrix))); - vec3 normal = normalize(normalMatrix*fragNormal); - - // Normalize normal and view direction vectors - vec3 n = normalize(normal); - vec3 v = normalize(viewDir); - - // Calculate diffuse texture color fetching - vec4 texelColor = texture2D(texture0, fragTexCoord); - vec3 lighting = colAmbient.rgb; - - // Calculate normal texture color fetching or set to maximum normal value by default - if (useNormal == 1) - { - n *= texture2D(texture1, fragTexCoord).rgb; - n = normalize(n); - } - - // Calculate specular texture color fetching or set to maximum specular value by default - float spec = 1.0; - if (useSpecular == 1) spec *= normalize(texture2D(texture2, fragTexCoord).r); - - for (int i = 0; i < maxLights; i++) - { - // Check if light is enabled - if (lights[i].enabled == 1) - { - // Calculate lighting based on light type - 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); - } - } - - // Calculate final fragment color - gl_FragColor = vec4(texelColor.rgb*lighting*colDiffuse.rgb, texelColor.a*colDiffuse.a); -} diff --git a/shaders/glsl100/standard.vs b/shaders/glsl100/standard.vs deleted file mode 100644 index 49c5a3eb..00000000 --- a/shaders/glsl100/standard.vs +++ /dev/null @@ -1,23 +0,0 @@ -#version 100 - -attribute vec3 vertexPosition; -attribute vec3 vertexNormal; -attribute vec2 vertexTexCoord; -attribute vec4 vertexColor; - -varying vec3 fragPosition; -varying vec2 fragTexCoord; -varying vec4 fragColor; -varying vec3 fragNormal; - -uniform mat4 mvpMatrix; - -void main() -{ - fragPosition = vertexPosition; - fragTexCoord = vertexTexCoord; - fragColor = vertexColor; - fragNormal = vertexNormal; - - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file diff --git a/shaders/glsl100/swirl.fs b/shaders/glsl100/swirl.fs deleted file mode 100644 index 6b17874c..00000000 --- a/shaders/glsl100/swirl.fs +++ /dev/null @@ -1,46 +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 - -// 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; - -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 = texture2D(texture0, tc/texSize).rgb; - - gl_FragColor = vec4(color, 1.0);; -} \ No newline at end of file diff --git a/shaders/glsl100/template.fs b/shaders/glsl100/template.fs deleted file mode 100644 index c1126423..00000000 --- a/shaders/glsl100/template.fs +++ /dev/null @@ -1,23 +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); - - // NOTE: Implement here your fragment shader code - - gl_FragColor = texelColor*colDiffuse; -} \ No newline at end of file diff --git a/shaders/glsl330/base.vs b/shaders/glsl330/base.vs deleted file mode 100644 index 638cb8ae..00000000 --- a/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/shaders/glsl330/bloom.fs b/shaders/glsl330/bloom.fs deleted file mode 100644 index 333d5b05..00000000 --- a/shaders/glsl330/bloom.fs +++ /dev/null @@ -1,40 +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 - -const vec2 size = vec2(800, 450); // render size -const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance -const float quality = 2.5; // lower = smaller glow, better quality - -void main() -{ - vec4 sum = vec4(0); - vec2 sizeFactor = vec2(1)/size*quality; - - // Texel color fetching from texture sampler - vec4 source = texture(texture0, fragTexCoord); - - const int range = 2; // should be = (samples - 1)/2; - - for (int x = -range; x <= range; x++) - { - for (int y = -range; y <= range; y++) - { - sum += texture(texture0, fragTexCoord + vec2(x, y)*sizeFactor); - } - } - - // Calculate final fragment color - finalColor = ((sum/(samples*samples)) + source)*colDiffuse; -} \ No newline at end of file diff --git a/shaders/glsl330/blur.fs b/shaders/glsl330/blur.fs deleted file mode 100644 index e4df406d..00000000 --- a/shaders/glsl330/blur.fs +++ /dev/null @@ -1,35 +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 - -// 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); - -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 deleted file mode 100644 index f95ad075..00000000 --- a/shaders/glsl330/cross_hatching.fs +++ /dev/null @@ -1,48 +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 - -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 deleted file mode 100644 index 9cdd36ca..00000000 --- a/shaders/glsl330/cross_stitching.fs +++ /dev/null @@ -1,59 +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 - -// NOTE: Render size values must be passed from code -const float renderWidth = 800.0; -const float renderHeight = 450.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 deleted file mode 100644 index 2422f390..00000000 --- a/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 colDiffuse; - -// 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 deleted file mode 100644 index 03115862..00000000 --- a/shaders/glsl330/dream_vision.fs +++ /dev/null @@ -1,34 +0,0 @@ -#version 330 - -in vec2 fragTexCoord; - -out vec4 fragColor; - -uniform sampler2D texture0; -uniform vec4 colDiffuse; - -// 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 deleted file mode 100644 index e85d7c9d..00000000 --- a/shaders/glsl330/fisheye.fs +++ /dev/null @@ -1,40 +0,0 @@ -#version 330 - -in vec2 fragTexCoord; - -out vec4 fragColor; - -uniform sampler2D texture0; -uniform vec4 colDiffuse; - -// 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 deleted file mode 100644 index 5b3e11be..00000000 --- a/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/shaders/glsl330/pixel.fs b/shaders/glsl330/pixel.fs deleted file mode 100644 index cf8aec44..00000000 --- a/shaders/glsl330/pixel.fs +++ /dev/null @@ -1,33 +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 - -// 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; - -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 deleted file mode 100644 index be2b5dd6..00000000 --- a/shaders/glsl330/posterization.fs +++ /dev/null @@ -1,31 +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 - -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 deleted file mode 100644 index 6a55c762..00000000 --- a/shaders/glsl330/predator.fs +++ /dev/null @@ -1,32 +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 - 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 deleted file mode 100644 index 22dc9cd5..00000000 --- a/shaders/glsl330/scanlines.fs +++ /dev/null @@ -1,49 +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 - -// NOTE: Render size values must be passed from code -const float renderWidth = 800; -const float renderHeight = 450; -float offset = 0.0; - -uniform float time; - -void main() -{ - float frequency = renderHeight/3.0; -/* - // 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/standard.fs b/shaders/glsl330/standard.fs deleted file mode 100644 index f728be81..00000000 --- a/shaders/glsl330/standard.fs +++ /dev/null @@ -1,150 +0,0 @@ -#version 330 - -in vec3 fragPosition; -in vec2 fragTexCoord; -in vec4 fragColor; -in vec3 fragNormal; - -out vec4 finalColor; - -uniform sampler2D texture0; -uniform sampler2D texture1; -uniform sampler2D texture2; - -uniform vec4 colAmbient; -uniform vec4 colDiffuse; -uniform vec4 colSpecular; -uniform float glossiness; - -uniform int useNormal; -uniform int useSpecular; - -uniform mat4 modelMatrix; -uniform vec3 viewDir; - -struct Light { - int enabled; - int type; - vec3 position; - vec3 direction; - vec4 diffuse; - float intensity; - float radius; - float coneAngle; -}; - -const int maxLights = 8; -uniform Light lights[maxLights]; - -vec3 CalcPointLight(Light l, vec3 n, vec3 v, float s) -{ - vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); - vec3 surfaceToLight = l.position - surfacePos; - - // Diffuse shading - float brightness = clamp(dot(n, surfaceToLight)/(length(surfaceToLight)*length(n)), 0, 1); - float diff = 1.0/dot(surfaceToLight/l.radius, surfaceToLight/l.radius)*brightness*l.intensity; - - // Specular shading - float spec = 0.0; - if (diff > 0.0) - { - vec3 h = normalize(-l.direction + v); - spec = pow(dot(n, h), 3 + glossiness)*s; - } - - return (diff*l.diffuse.rgb + spec*colSpecular.rgb); -} - -vec3 CalcDirectionalLight(Light l, vec3 n, vec3 v, float s) -{ - vec3 lightDir = normalize(-l.direction); - - // Diffuse shading - float diff = clamp(dot(n, lightDir), 0.0, 1.0)*l.intensity; - - // Specular shading - float spec = 0.0; - if (diff > 0.0) - { - vec3 h = normalize(lightDir + v); - spec = pow(dot(n, h), 3 + glossiness)*s; - } - - // Combine results - return (diff*l.intensity*l.diffuse.rgb + spec*colSpecular.rgb); -} - -vec3 CalcSpotLight(Light l, vec3 n, vec3 v, float s) -{ - vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); - vec3 lightToSurface = normalize(surfacePos - l.position); - vec3 lightDir = normalize(-l.direction); - - // Diffuse shading - float diff = clamp(dot(n, lightDir), 0.0, 1.0)*l.intensity; - - // Spot attenuation - float attenuation = clamp(dot(n, lightToSurface), 0.0, 1.0); - attenuation = dot(lightToSurface, -lightDir); - - float lightToSurfaceAngle = degrees(acos(attenuation)); - if (lightToSurfaceAngle > l.coneAngle) attenuation = 0.0; - - float falloff = (l.coneAngle - lightToSurfaceAngle)/l.coneAngle; - - // Combine diffuse and attenuation - float diffAttenuation = diff*attenuation; - - // Specular shading - float spec = 0.0; - if (diffAttenuation > 0.0) - { - vec3 h = normalize(lightDir + v); - spec = pow(dot(n, h), 3 + glossiness)*s; - } - - return (falloff*(diffAttenuation*l.diffuse.rgb + spec*colSpecular.rgb)); -} - -void main() -{ - // Calculate fragment normal in screen space - // NOTE: important to multiply model matrix by fragment normal to apply model transformation (rotation and scale) - mat3 normalMatrix = transpose(inverse(mat3(modelMatrix))); - vec3 normal = normalize(normalMatrix*fragNormal); - - // Normalize normal and view direction vectors - vec3 n = normalize(normal); - vec3 v = normalize(viewDir); - - // Calculate diffuse texture color fetching - vec4 texelColor = texture(texture0, fragTexCoord); - vec3 lighting = colAmbient.rgb; - - // Calculate normal texture color fetching or set to maximum normal value by default - if (useNormal == 1) - { - n *= texture(texture1, fragTexCoord).rgb; - n = normalize(n); - } - - // Calculate specular texture color fetching or set to maximum specular value by default - float spec = 1.0; - if (useSpecular == 1) spec *= normalize(texture(texture2, fragTexCoord).r); - - for (int i = 0; i < maxLights; i++) - { - // Check if light is enabled - if (lights[i].enabled == 1) - { - // Calculate lighting based on light type - 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); - } - } - - // Calculate final fragment color - finalColor = vec4(texelColor.rgb*lighting*colDiffuse.rgb, texelColor.a*colDiffuse.a); -} diff --git a/shaders/glsl330/standard.vs b/shaders/glsl330/standard.vs deleted file mode 100644 index fc0a5ff4..00000000 --- a/shaders/glsl330/standard.vs +++ /dev/null @@ -1,23 +0,0 @@ -#version 330 - -in vec3 vertexPosition; -in vec3 vertexNormal; -in vec2 vertexTexCoord; -in vec4 vertexColor; - -out vec3 fragPosition; -out vec2 fragTexCoord; -out vec4 fragColor; -out vec3 fragNormal; - -uniform mat4 mvpMatrix; - -void main() -{ - fragPosition = vertexPosition; - fragTexCoord = vertexTexCoord; - fragColor = vertexColor; - fragNormal = vertexNormal; - - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file diff --git a/shaders/glsl330/swirl.fs b/shaders/glsl330/swirl.fs deleted file mode 100644 index c4b66768..00000000 --- a/shaders/glsl330/swirl.fs +++ /dev/null @@ -1,47 +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 - -// 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; - -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 deleted file mode 100644 index 2e73de14..00000000 --- a/shaders/glsl330/template.fs +++ /dev/null @@ -1,24 +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); - - // NOTE: Implement here your fragment shader code - - finalColor = texelColor*colDiffuse; -} -- cgit v1.2.3