Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main() {
- float Strength = 1;
- float Height = tan(2.47837 * 0.5);//Vertical FOV in Radians https://themetalmuncher.github.io/fov-calc/ Degrees * pi/180 = Radians
- float AspectRatio = (4/3);
- float CylindricalRatio = 100.0; //1 = Spherical 0 = Flat but you can go beyond
- float ScaledHeight = Strength * Height;
- float CylAspectRatio = AspectRatio * CylindricalRatio;
- float AspectDiagSq = AspectRatio * AspectRatio + 1.0;
- float DiagSq = ScaledHeight * ScaledHeight * AspectDiagSq;
- vec2 SignedUV = (2.0 * TexCoord + vec2(-1.0, -1.0));
- float z = 0.5 * sqrt(DiagSq + 1.0) + 0.5;
- float ny = (z - 1.0) / (CylAspectRatio * CylAspectRatio + 1.0);
- vec2 vUVDot = sqrt(ny) * vec2(CylAspectRatio, 1.0) * SignedUV;
- vec3 vUV = vec3(0.5, 0.5, 1.0) * z + vec3(-0.5, -0.5, 0.0);
- vUV.xy += TexCoord;
- vec3 uv2 = dot(vUVDot, vUVDot) * vec3(-0.5, -0.5, -1.0) + vUV;
- //uv2.xy = uv2.xy / uv2.z;
- vec4 c = texture2DProj(InputTexture, uv2);
- FragColor = c;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement