Use some diffent value/equation for tonemap
This commit is contained in:
parent
2aa6676050
commit
b0e56ca2b0
@ -1,4 +1,4 @@
|
||||
#define AUTO_EXPOSURE
|
||||
// From http://www.ceng.metu.edu.tr/~akyuz/files/hdrgpu.pdf
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D logluminancetex;
|
||||
@ -9,19 +9,23 @@ out vec4 FragColor;
|
||||
vec3 getCIEYxy(vec3 rgbColor);
|
||||
vec3 getRGBFromCIEXxy(vec3 YxyColor);
|
||||
|
||||
float exposure = .2;
|
||||
float whitePoint = 1.;
|
||||
float exposure = .18;
|
||||
float Lwhite = 1.;
|
||||
float delta = .0001;
|
||||
float saturation = 1.;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col = texture(tex, uv);
|
||||
float avgLuminance = textureLod(logluminancetex, uv, 10.).x;
|
||||
avgLuminance = max(exp(avgLuminance) - delta, delta);
|
||||
float avgLw = textureLod(logluminancetex, uv, 10.).x;
|
||||
avgLw = max(exp(avgLw) - delta, delta);
|
||||
|
||||
vec3 Yxy = getCIEYxy(col.xyz);
|
||||
float Lp = Yxy.r * exposure / avgLuminance;
|
||||
Yxy.r = (Lp * (1. * Lp / (whitePoint * whitePoint))) / (1. + Lp);
|
||||
FragColor = vec4(getRGBFromCIEXxy(Yxy), 1.);
|
||||
vec3 Cw = getCIEYxy(col.xyz);
|
||||
float Lw = Cw.y;
|
||||
float L = Lw * exposure / avgLw;
|
||||
float Ld = L * (1. + L / (Lwhite * Lwhite));
|
||||
Ld /= (1. + L);
|
||||
|
||||
FragColor = vec4(Ld * pow(col.xyz / Lw, vec3(saturation)), 1.);
|
||||
|
||||
}
|
||||
|
@ -3,15 +3,10 @@
|
||||
|
||||
vec3 getCIEYxy(vec3 rgbColor)
|
||||
{
|
||||
// convert rgb to srgb
|
||||
vec3 sRGBColor = rgbColor;//vec3(pow(rgbColor.x, 1. / 2.2), pow(rgbColor.y, 1. / 2.2), pow(rgbColor.z, 1. / 2.2));
|
||||
|
||||
mat3 sRGB2XYZ = transpose(mat3(
|
||||
vec3(.4125, .2126, .0193),
|
||||
vec3(.3576, .7152, .1192),
|
||||
vec3(.1805, .0722, .9505)));
|
||||
|
||||
vec3 XYZ = sRGB2XYZ * sRGBColor;
|
||||
float sum = dot(vec3(1.), XYZ);
|
||||
return vec3(XYZ.y, XYZ.xy / sum);
|
||||
return sRGB2XYZ * rgbColor;
|
||||
}
|
@ -637,11 +637,6 @@ void PostProcessing::render()
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
computeLogLuminance(in_rtt);
|
||||
toneMap(out_fbo, in_rtt);
|
||||
std::swap(in_rtt, out_rtt);
|
||||
std::swap(in_fbo, out_fbo);
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Bloom", 0xFF, 0x00, 0x00);
|
||||
if (UserConfigParams::m_bloom)
|
||||
{
|
||||
@ -699,6 +694,11 @@ void PostProcessing::render()
|
||||
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
computeLogLuminance(in_rtt);
|
||||
toneMap(out_fbo, in_rtt);
|
||||
std::swap(in_rtt, out_rtt);
|
||||
std::swap(in_fbo, out_fbo);
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Godrays", 0xFF, 0x00, 0x00);
|
||||
if (UserConfigParams::m_light_shaft && m_sunpixels > 30)//World::getWorld()->getTrack()->hasGodRays() && ) // god rays
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user