You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
774 B

  1. #version 330
  2. in vec2 fragTexCoord;
  3. out vec4 fragColor;
  4. uniform sampler2D texture0;
  5. uniform vec4 fragTintColor;
  6. // NOTE: Add here your custom variables
  7. const float PI = 3.1415926535;
  8. void main()
  9. {
  10. float aperture = 178.0;
  11. float apertureHalf = 0.5 * aperture * (PI / 180.0);
  12. float maxFactor = sin(apertureHalf);
  13. vec2 uv = vec2(0);
  14. vec2 xy = 2.0 * fragTexCoord.xy - 1.0;
  15. float d = length(xy);
  16. if (d < (2.0 - maxFactor))
  17. {
  18. d = length(xy * maxFactor);
  19. float z = sqrt(1.0 - d * d);
  20. float r = atan(d, z) / PI;
  21. float phi = atan(xy.y, xy.x);
  22. uv.x = r * cos(phi) + 0.5;
  23. uv.y = r * sin(phi) + 0.5;
  24. }
  25. else
  26. {
  27. uv = fragTexCoord.xy;
  28. }
  29. fragColor = texture(texture0, uv);
  30. }