1
0
Fork 0
fgdata/Shaders/HDR/skydome.frag

21 lines
460 B
GLSL
Raw Normal View History

2021-04-10 09:14:16 +00:00
#version 330 core
out vec4 fragColor;
in vec3 rayDir;
2021-04-10 09:14:16 +00:00
uniform sampler2D sky_view_lut;
2021-04-10 09:14:16 +00:00
const float PI = 3.141592653;
2021-04-10 09:14:16 +00:00
void main()
{
float azimuth = atan(rayDir.y, rayDir.x) / PI * 0.5 + 0.5;
// Undo the non-linear transformation from the sky-view LUT
float l = asin(rayDir.z);
float elev = sqrt(abs(l) / (PI * 0.5)) * sign(l) * 0.5 + 0.5;
2021-04-10 09:14:16 +00:00
vec3 color = texture(sky_view_lut, vec2(azimuth, elev)).rgb;
2021-04-10 09:14:16 +00:00
fragColor = vec4(color, 1.0);
}