diff options
| author | raysan5 <raysan5@gmail.com> | 2016-04-07 11:48:09 +0200 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2016-04-07 11:48:09 +0200 |
| commit | 78b502b0bf1ee796d86837c611150ed5f8d58fd2 (patch) | |
| tree | f0efc476e32c3141e7a3395f32ac971caa478649 /shaders/glsl100/fisheye.fs | |
| parent | 3b67a4cfba7d3b5dca805b1d1718fd2c9db64e99 (diff) | |
| download | raylib-78b502b0bf1ee796d86837c611150ed5f8d58fd2.tar.gz raylib-78b502b0bf1ee796d86837c611150ed5f8d58fd2.zip | |
Folders rename for consistency on shaders version
Diffstat (limited to 'shaders/glsl100/fisheye.fs')
| -rw-r--r-- | shaders/glsl100/fisheye.fs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/shaders/glsl100/fisheye.fs b/shaders/glsl100/fisheye.fs new file mode 100644 index 00000000..e7a4485c --- /dev/null +++ b/shaders/glsl100/fisheye.fs @@ -0,0 +1,40 @@ +#version 100 + +precision mediump float; + +varying vec2 fragTexCoord; + +uniform sampler2D texture0; +uniform vec4 fragTintColor; + +// 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 |
