Advertisement
Guest User

Untitled

a guest
Apr 29th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. void main() {
  2. float Strength = 1;
  3. float Height = tan(2.47837 * 0.5);//Vertical FOV in Radians https://themetalmuncher.github.io/fov-calc/ Degrees * pi/180 = Radians
  4. float AspectRatio = (4/3);
  5. float CylindricalRatio = 100.0; //1 = Spherical 0 = Flat but you can go beyond
  6.  
  7. float ScaledHeight = Strength * Height;
  8. float CylAspectRatio = AspectRatio * CylindricalRatio;
  9. float AspectDiagSq = AspectRatio * AspectRatio + 1.0;
  10. float DiagSq = ScaledHeight * ScaledHeight * AspectDiagSq;
  11. vec2 SignedUV = (2.0 * TexCoord + vec2(-1.0, -1.0));
  12.  
  13. float z = 0.5 * sqrt(DiagSq + 1.0) + 0.5;
  14. float ny = (z - 1.0) / (CylAspectRatio * CylAspectRatio + 1.0);
  15.  
  16. vec2 vUVDot = sqrt(ny) * vec2(CylAspectRatio, 1.0) * SignedUV;
  17. vec3 vUV = vec3(0.5, 0.5, 1.0) * z + vec3(-0.5, -0.5, 0.0);
  18. vUV.xy += TexCoord;
  19.  
  20. vec3 uv2 = dot(vUVDot, vUVDot) * vec3(-0.5, -0.5, -1.0) + vUV;
  21. //uv2.xy = uv2.xy / uv2.z;
  22.  
  23. vec4 c = texture2DProj(InputTexture, uv2);
  24.  
  25. FragColor = c;
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement