mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-22 12:17:42 +02:00
59 lines
1.6 KiB
Text
59 lines
1.6 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// Generated on Sat Oct 24 09:34:37 2015
|
|
//
|
|
// Draw texture 0 fetched at texcoord.xy
|
|
//
|
|
// Created by Sam Gateau on 6/22/2015
|
|
// Copyright 2015 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
struct ToneMappingParams {
|
|
vec4 _exp_2powExp_s0_s1;
|
|
ivec4 _toneCurve_s0_s1_s2;
|
|
};
|
|
|
|
const float INV_GAMMA_22 = 1.0 / 2.2;
|
|
const int ToneCurveNone = 0;
|
|
const int ToneCurveGamma22 = 1;
|
|
const int ToneCurveReinhard = 2;
|
|
const int ToneCurveFilmic = 3;
|
|
|
|
uniform toneMappingParamsBuffer {
|
|
ToneMappingParams params;
|
|
};
|
|
float getTwoPowExposure() {
|
|
return params._exp_2powExp_s0_s1.y;
|
|
}
|
|
int getToneCurve() {
|
|
return params._toneCurve_s0_s1_s2.x;
|
|
}
|
|
|
|
uniform sampler2D colorMap;
|
|
|
|
in vec2 varTexCoord0;
|
|
out vec4 outFragColor;
|
|
|
|
void main(void) {
|
|
vec4 fragColorRaw = texture(colorMap, varTexCoord0);
|
|
vec3 fragColor = fragColorRaw.xyz;
|
|
|
|
vec3 srcColor = fragColor * getTwoPowExposure();
|
|
|
|
int toneCurve = getToneCurve();
|
|
vec3 tonedColor = srcColor;
|
|
if (toneCurve == ToneCurveFilmic) {
|
|
vec3 x = max(vec3(0.0), srcColor-0.004);
|
|
tonedColor = (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06);
|
|
} else if (toneCurve == ToneCurveReinhard) {
|
|
tonedColor = srcColor/(1.0 + srcColor);
|
|
tonedColor = pow(tonedColor, vec3(INV_GAMMA_22));
|
|
} else if (toneCurve == ToneCurveGamma22) {
|
|
tonedColor = pow(srcColor, vec3(INV_GAMMA_22));
|
|
} // else None toned = src
|
|
|
|
outFragColor = vec4(tonedColor, 1.0);
|
|
}
|