2021-04-10 09:14:16 +00:00
|
|
|
#version 330 core
|
|
|
|
|
|
|
|
out vec4 fragColor;
|
|
|
|
|
2021-07-26 10:10:58 +00:00
|
|
|
in vec3 rayDir;
|
2021-04-10 09:14:16 +00:00
|
|
|
|
2021-07-26 10:10:58 +00:00
|
|
|
uniform sampler2D sky_view_lut;
|
2021-04-10 09:14:16 +00:00
|
|
|
|
2021-07-26 10:10:58 +00:00
|
|
|
const float PI = 3.141592653;
|
2021-04-10 09:14:16 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2021-07-26 10:10:58 +00:00
|
|
|
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
|
|
|
|
2021-07-26 10:10:58 +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);
|
|
|
|
}
|