rtx: remove second gamma correction

On stream E180 after working on it for almost a year we found out that we're doing double gamma correction. Our swapchain colorspace is already SRGB, so no need to sqrt() in shaders.

Also, comment on the fact that we need to HDRize skyboxes, and leave the curren hack intact.
This commit is contained in:
Ivan 'provod' Avdeev 2021-12-20 12:26:29 -08:00 committed by Ivan Avdeev
parent 4d5dbd7f1e
commit 2ac0413a28
2 changed files with 16 additions and 7 deletions

View File

@ -6,11 +6,11 @@ layout(local_size_x = 16, local_size_y = 8, local_size_z = 1) in;
layout(set = 0, binding = 0, rgba16f) uniform image2D dest;
layout(set = 0, binding = 1, rgba8) uniform image2D src_base_color;
layout(set = 0, binding = 2, rgba16f) uniform image2D src_diffuse_gi;
layout(set = 0, binding = 3, rgba16f) uniform image2D src_specular;
layout(set = 0, binding = 4, rgba16f) uniform image2D src_additive;
layout(set = 0, binding = 5, rgba16f) uniform image2D src_normals;
layout(set = 0, binding = 1, rgba8) uniform readonly image2D src_base_color;
layout(set = 0, binding = 2, rgba16f) uniform readonly image2D src_diffuse_gi;
layout(set = 0, binding = 3, rgba16f) uniform readonly image2D src_specular;
layout(set = 0, binding = 4, rgba16f) uniform readonly image2D src_additive;
layout(set = 0, binding = 5, rgba16f) uniform readonly image2D src_normals;
// Blatantly copypasted from https://www.shadertoy.com/view/XsGfWV
vec3 aces_tonemap(vec3 color){
@ -27,7 +27,8 @@ vec3 aces_tonemap(vec3 color){
vec3 v = m1 * color;
vec3 a = v * (v + 0.0245786) - 0.000090537;
vec3 b = v * (0.983729 * v + 0.4329510) + 0.238081;
return pow(clamp(m2 * (a / b), 0.0, 1.0), vec3(1.0 / 2.2));
//return pow(clamp(m2 * (a / b), 0.0, 1.0), vec3(1.0 / 2.2));
return clamp(m2 * (a / b), 0.0, 1.0);
}
float normpdf2(in float x2, in float sigma) { return 0.39894*exp(-0.5*x2/(sigma*sigma))/sigma; }
@ -117,6 +118,10 @@ void main() {
//colour += imageLoad(src_specular, pix).rgb;
colour += imageLoad(src_additive, pix).rgb;
// HACK: exposure
// TODO: should be dynamic based on previous frames brightness
colour *= 4.;
colour = aces_tonemap(colour);
imageStore(dest, pix, vec4(colour, 0.));

View File

@ -97,11 +97,15 @@ void main() {
payload.transmissiveness = 0.;
payload.normal = vec3(0.);
payload.geometry_normal = vec3(0.);
payload.emissive = pow(texture(skybox, gl_WorldRayDirectionEXT).rgb, vec3(2.2)); // Why?! See #230
payload.kusok_index = -1;
payload.roughness = 0.;
payload.metalness = 0.;
payload.material_index = tex_base_color;
// HACK: skyboxes are LDR now. They will look really dull after tonemapping
// We need to remaster them into HDR. While that is not done, we just tune them with pow(x, 2.2) which looks okay-ish
// See #230
payload.emissive = pow(texture(skybox, gl_WorldRayDirectionEXT).rgb, vec3(2.2));
return;
}