2015-09-02 03:44:16 +03:00
|
|
|
#version 100
|
|
|
|
|
|
|
|
precision mediump float;
|
|
|
|
|
2016-05-18 13:04:27 +03:00
|
|
|
// Input vertex attributes (from vertex shader)
|
2015-09-02 03:44:16 +03:00
|
|
|
varying vec2 fragTexCoord;
|
2016-05-18 13:04:27 +03:00
|
|
|
varying vec4 fragColor;
|
2015-09-02 03:44:16 +03:00
|
|
|
|
2016-05-18 13:04:27 +03:00
|
|
|
// Input uniform values
|
2015-09-02 03:44:16 +03:00
|
|
|
uniform sampler2D texture0;
|
2016-07-19 11:57:35 +03:00
|
|
|
uniform vec4 colDiffuse;
|
2015-09-02 03:44:16 +03:00
|
|
|
|
2016-05-18 13:04:27 +03:00
|
|
|
// NOTE: Add here your custom variables
|
2015-09-02 03:44:16 +03:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|