38 lines
789 B
GLSL
38 lines
789 B
GLSL
#version 450
|
|
#extension GL_GOOGLE_include_directive : require
|
|
#include "bindless.glsl"
|
|
|
|
|
|
layout(location = 0) in vec3 localPos;
|
|
|
|
// Input equirectangular HDR texture
|
|
|
|
layout(location = 0) out vec4 outColor;
|
|
|
|
const float PI = 3.14159265359;
|
|
|
|
layout(push_constant) uniform PushConstants {
|
|
mat4 view;
|
|
mat4 proj;
|
|
uint skyboxId;
|
|
} pcs;
|
|
|
|
vec2 sampleSphericalMap(vec3 v) {
|
|
// Convert direction to spherical coordinates
|
|
vec2 uv = vec2(atan(v.z, v.x), asin(v.y));
|
|
uv /= vec2(2.0 * PI, PI);
|
|
uv += 0.5;
|
|
return uv;
|
|
}
|
|
|
|
void main() {
|
|
// Normalize direction vector
|
|
vec3 dir = normalize(localPos);
|
|
|
|
// Sample from equirectangular texture
|
|
vec2 uv = sampleSphericalMap(dir);
|
|
vec4 color = sampleTexture2DNearest(pcs.skyboxId, uv);
|
|
|
|
|
|
outColor = color;
|
|
} |