Files
gren/assets/shaders/skybox.frag
2026-01-09 13:50:52 +01:00

33 lines
895 B
GLSL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#version 450 core
layout(location = 0) out vec4 oColor;
layout(std140, binding = 0) uniform PerFrame {
mat4 uView;
mat4 uProj;
vec4 uLightDir; // unused
};
layout(std140, binding = 2) uniform Material {
vec4 uAlbedo; // unused
};
layout(location = 0) in vec3 vDir;
// sRGB-tuned colors; well convert to linear before mixing
vec3 srgb2lin(vec3 c){ return pow(c, vec3(2.2)); }
vec3 lin2srgb(vec3 c){ return pow(c, vec3(1.0/2.2)); }
void main() {
// nicer defaults (tweak to taste)
vec3 skyTopL = srgb2lin(vec3(0.15, 0.35, 0.75));
vec3 skyHorizonL = srgb2lin(vec3(0.75, 0.85, 0.98));
vec3 dir = normalize(vDir);
float t = clamp(dir.z * 0.5 + 0.5, 0.0, 1.0); // (B) world up = +Z
// shape the gradient a bit
t = pow(t, 1.45);
vec3 colorL = mix(skyHorizonL, skyTopL, t);
oColor = vec4(lin2srgb(colorL), 1.0); // manual gamma (your default FB isnt sRGB)
}