first commit
This commit is contained in:
33
assets/shaders/skybox.frag
Normal file
33
assets/shaders/skybox.frag
Normal file
@@ -0,0 +1,33 @@
|
||||
#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; we’ll 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 isn’t sRGB)
|
||||
}
|
||||
Reference in New Issue
Block a user