Advertisement
hololand1

Untitled

May 6th, 2021 (edited)
2,240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #version 440
  2. out vec4 FragColor;
  3.  
  4. in vec3 position;
  5. // HDR image
  6. uniform sampler2D equirectangularMap;
  7.  
  8. const vec2 invAtan = vec2(0.1591, 0.3183);
  9. // Get UV coordinate from Sphere Sample
  10. vec2 SampleSphericalMap(vec3 v)
  11. {
  12.     vec2 uv = vec2(atan(v.z, v.x), asin(v.y));
  13.     uv *= invAtan;
  14.     uv += 0.5;
  15.     return uv;
  16. }
  17. // Use UV coordinate to sample from HDR
  18. void main()
  19. {
  20.     vec2 uv = SampleSphericalMap(normalize(position));
  21.     vec3 color = texture(equirectangularMap, uv).rgb;
  22.  
  23.     FragColor = vec4(color, 1.0);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement