Add skybox rendering support

This commit is contained in:
reo 2025-07-15 01:27:50 +03:00
parent f6a9d18c5c
commit f943e4c945
4 changed files with 93 additions and 3 deletions

View file

@ -0,0 +1,22 @@
#version 330 core
in vec3 direction;
out vec4 frag_color;
uniform sampler2D equirect;
const vec2 inv_atan = vec2(0.15915494309, 0.31830988618);
vec2 sample_spherical_map(vec3 v) {
vec2 uv = vec2(atan(v.z, v.x), asin(v.y));
uv *= inv_atan;
uv += 0.5;
return uv;
}
void main() {
vec2 uv = sample_spherical_map(normalize(direction));
vec3 color = texture(equirect, uv).rgb;
frag_color = vec4(color, 1.0);
}