Files
voxel-game/assets/shaders/skybox.frag
2025-12-07 23:27:42 +01:00

30 lines
820 B
GLSL

#version 460
in Varyings {
layout(location = 0) vec3 texCoord;
} var;
layout(set = 0, binding = 1) uniform sampler _Sampler;
layout(set = 0, binding = 2) uniform textureCube _Texture;
layout(location = 0) out vec4 fragColor;
vec3 toneMapAcesNarkowicz(vec3 color) {
const float A = 2.51;
const float B = 0.03;
const float C = 2.43;
const float D = 0.59;
const float E = 0.14;
return clamp((color * (A * color + B)) / (color * (C * color + D) + E), 0.0, 1.0);
}
void main() {
vec4 texel = texture(samplerCube(_Texture, _Sampler), var.texCoord);
vec3 outgoingRadiance = texel.rgb;
vec3 toneMappedLinearColor = toneMapAcesNarkowicz(outgoingRadiance);
vec3 toneMappedSrgbColor = pow(toneMappedLinearColor, vec3(1.0 / 2.2));
fragColor = vec4(toneMappedSrgbColor, 1.0);
}