Tonemapping, I guess;

This commit is contained in:
bjorn 2022-08-26 10:34:32 -07:00
parent ad7c854571
commit 085550da33
1 changed files with 14 additions and 0 deletions

View File

@ -15,6 +15,7 @@ layout(constant_id = 1012) const bool flag_metalnessTexture = true;
layout(constant_id = 1013) const bool flag_roughnessTexture = true;
layout(constant_id = 1014) const bool flag_occlusionTexture = false;
layout(constant_id = 1015) const bool flag_clearcoatTexture = false;
layout(constant_id = 1016) const bool flag_tonemap = false;
// Resources
#ifndef GL_COMPUTE_SHADER
@ -317,6 +318,15 @@ vec3 evaluateSphericalHarmonics(vec3 sh[9], vec3 n) {
sh[8] * (n.x * n.x - n.y * n.y)
, 0.);
}
vec3 tonemap(vec3 x) {
float a = 2.51;
float b = 0.03;
float c = 2.43;
float d = 0.59;
float e = 0.14;
return (x * (a * x + b)) / (x * (c * x + d) + e);
}
#endif
// Entrypoints
@ -360,6 +370,10 @@ void main() {
}
}
if (flag_tonemap) {
PixelColor[0].rgb = tonemap(PixelColor[0].rgb);
}
if (flag_alphaCutoff && PixelColor[0].a <= Material.alphaCutoff) {
discard;
}