2
0

skybox.frag.glsl 462 B

123456789101112131415161718192021
  1. #version 150
  2. in vec3 skybox_pos;
  3. out vec4 color;
  4. uniform sampler2D p3d_Texture0;
  5. void main() {
  6. vec3 view_dir = normalize(skybox_pos);
  7. vec2 skybox_uv;
  8. // Convert spherical coordinates
  9. const float pi = 3.14159265359;
  10. skybox_uv.x = (atan(view_dir.y, view_dir.x) + (0.5 * pi)) / (2 * pi);
  11. skybox_uv.y = clamp(view_dir.z * 0.72 + 0.35, 0.0, 1.0);
  12. vec3 skybox_color = textureLod(p3d_Texture0, skybox_uv, 0).xyz;
  13. color = vec4(skybox_color, 1);
  14. }