Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #version 330 core
  2. out vec4 FragColor;
  3. in vec3 WorldPos;
  4. uniform sampler2D equirectangularMap;
  5.  
  6. const vec2 invAtan = vec2(0.1591, 0.3183);
  7. vec2 SampleSphericalMap(vec3 v)
  8. {
  9. vec2 uv = vec2(atan(v.z, v.x), asin(v.y));
  10. uv *= invAtan;
  11. uv += 0.5;
  12. return uv;
  13. }
  14.  
  15. void main()
  16. {
  17. vec2 uv = SampleSphericalMap(normalize(WorldPos));
  18. vec3 color = texture(equirectangularMap, uv).rgb;
  19.  
  20. FragColor = vec4(color, 1.0);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement