This commit is contained in:
2026-03-21 23:10:48 +01:00
parent 8cbb794dba
commit 3153735d0c
18 changed files with 249 additions and 195 deletions

View File

@@ -4,26 +4,33 @@
#include "bindless.glsl"
layout(location = 0) in vec2 uv; // from fullscreen triangle: 0..2 range
layout(location = 0) in vec2 uv;
layout(location = 0) out vec4 outColor;
layout(push_constant) uniform SkyboxPC {
mat4 invViewProj; // inverse(Proj * View) (your current setup)
vec4 cameraPos; // xyz = camera world position
uint skyboxTextureId; // index into textureCubes[]
mat4 invViewProj;
vec4 skyboxRot[3];
vec3 cameraPos;
uint skyboxTextureId;
} pcs;
void main()
{
vec2 ndcXY = uv * 2.0 - 1.0;
vec4 ndc = vec4(ndcXY, 1.0, 1.0);
vec4 world = pcs.invViewProj * ndc;
vec3 worldPos = world.xyz / world.w;
vec3 dir = normalize(worldPos - pcs.cameraPos.xyz);
vec3 dir = normalize(worldPos - pcs.cameraPos);
dir.y *= -1.0;
mat3 skyboxRot = mat3(
pcs.skyboxRot[0].xyz,
pcs.skyboxRot[1].xyz,
pcs.skyboxRot[2].xyz
);
dir = skyboxRot * dir;
outColor = sampleTextureCubeLinear(pcs.skyboxTextureId, dir);
}
}