Debian Codegraph @

src/extras/shaders/gl3/skybox.frag

raw
1 #version 330
2
3 in vec3 texCoord0;
4 out vec4 fragColor;
5 uniform samplerCube skyboxTexture;
6
7 // Gamma correction
8 uniform float gamma = 2.2;
9
10 uniform float gammaStrength;
11
12 vec3 gammaCorrect(const in vec3 color)
13 {
14 return pow(color, vec3(1.0 / gamma));
15 }
16
17 void main()
18 {
19 vec4 baseColor = texture(skyboxTexture, texCoord0);
20 vec4 gammaColor = vec4(gammaCorrect(baseColor.rgb), 1.0);
21 // This is an odd way to enable or not gamma correction,
22 // but this is a way to avoid branching until we can generate shaders
23 fragColor = mix(baseColor, gammaColor, gammaStrength);
24 }