Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const float PI = 3.1415926535;
- vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords)
- {
- float aperture = 178.0;
- float apertureHalf = 0.5 * aperture * (PI / 180.0);
- float maxFactor = sin(apertureHalf);
- vec2 uv;
- vec2 xy = 2.0 * texture_coords.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 = texture_coords.xy;
- }
- vec4 c = texture2D(texture, uv);
- return c;
- }
Add Comment
Please, Sign In to add comment