| 1 |
#version 450 |
| 2 |
|
| 3 |
layout(location = 0) in vec3 texCoord0; |
| 4 |
layout(location = 0) out vec4 fragColor; |
| 5 |
|
| 6 |
|
| 7 |
// Gamma correction |
| 8 |
|
| 9 |
layout(std140, binding = 0) uniform qt3d_render_view_uniforms { |
| 10 |
mat4 viewMatrix; |
| 11 |
mat4 projectionMatrix; |
| 12 |
mat4 uncorrectedProjectionMatrix; |
| 13 |
mat4 clipCorrectionMatrix; |
| 14 |
mat4 viewProjectionMatrix; |
| 15 |
mat4 inverseViewMatrix; |
| 16 |
mat4 inverseProjectionMatrix; |
| 17 |
mat4 inverseViewProjectionMatrix; |
| 18 |
mat4 viewportMatrix; |
| 19 |
mat4 inverseViewportMatrix; |
| 20 |
vec4 textureTransformMatrix; |
| 21 |
vec3 eyePosition; |
| 22 |
float aspectRatio; |
| 23 |
float gamma; |
| 24 |
float exposure; |
| 25 |
float time; |
| 26 |
}; |
| 27 |
|
| 28 |
layout(std140, binding = 2) uniform qt3d_morph_uniforms { |
| 29 |
float gammaStrength; |
| 30 |
}; |
| 31 |
|
| 32 |
layout(binding = 3) uniform samplerCube skyboxTexture; |
| 33 |
|
| 34 |
vec3 gammaCorrect(const in vec3 color) |
| 35 |
{ |
| 36 |
return pow(color, vec3(1.0 / gamma)); |
| 37 |
} |
| 38 |
|
| 39 |
void main() |
| 40 |
{ |
| 41 |
vec4 baseColor = texture(skyboxTexture, texCoord0); |
| 42 |
vec4 gammaColor = vec4(gammaCorrect(baseColor.rgb), 1.0); |
| 43 |
// This is an odd way to enable or not gamma correction, |
| 44 |
// but this is a way to avoid branching until we can generate shaders |
| 45 |
fragColor = mix(baseColor, gammaColor, gammaStrength); |
| 46 |
} |