36 lines
797 B
GLSL
36 lines
797 B
GLSL
#version 450
|
|
#extension GL_GOOGLE_include_directive : require
|
|
#extension GL_EXT_nonuniform_qualifier : enable
|
|
|
|
#include "bindless.glsl"
|
|
|
|
layout(location = 0) in vec2 uv;
|
|
layout(location = 0) out vec4 outColor;
|
|
|
|
layout(push_constant) uniform SkyboxPC {
|
|
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);
|
|
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);
|
|
} |