Moved antialiasing before tonemapping

This commit is contained in:
Olivier Prat 2018-02-26 14:57:59 +01:00
parent d3114cbc67
commit 419e064e65
4 changed files with 13 additions and 9 deletions

View file

@ -41,15 +41,19 @@ vec3 color_LinearToYCoCg(vec3 rgb) {
); );
} }
vec3 color_YCoCgToLinear(vec3 ycocg) { vec3 color_YCoCgToUnclampedLinear(vec3 ycocg) {
// R = Y + Co - Cg // R = Y + Co - Cg
// G = Y + Cg // G = Y + Cg
// B = Y - Co - Cg // B = Y - Co - Cg
return clamp(vec3( return vec3(
ycocg.x + ycocg.y - ycocg.z, ycocg.x + ycocg.y - ycocg.z,
ycocg.x + ycocg.z, ycocg.x + ycocg.z,
ycocg.x - ycocg.y - ycocg.z ycocg.x - ycocg.y - ycocg.z
), vec3(0.0), vec3(1.0)); );
}
vec3 color_YCoCgToLinear(vec3 ycocg) {
return clamp(color_YCoCgToUnclampedLinear(ycocg), vec3(0.0), vec3(1.0));
} }
<@func declareColorWheel()@> <@func declareColorWheel()@>

View file

@ -333,7 +333,7 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
auto& antiAliasingBuffer = _antialiasingBuffers->edit(i); auto& antiAliasingBuffer = _antialiasingBuffers->edit(i);
antiAliasingBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("antialiasing")); antiAliasingBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("antialiasing"));
auto format = gpu::Element::COLOR_SRGBA_32; // DependencyManager::get<FramebufferCache>()->getLightingTexture()->getTexelFormat(); auto format = sourceBuffer->getRenderBuffer(0)->getTexelFormat();
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR); auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR);
_antialiasingTextures[i] = gpu::Texture::createRenderBuffer(format, width, height, gpu::Texture::SINGLE_MIP, defaultSampler); _antialiasingTextures[i] = gpu::Texture::createRenderBuffer(format, width, height, gpu::Texture::SINGLE_MIP, defaultSampler);
antiAliasingBuffer->setRenderBuffer(0, _antialiasingTextures[i]); antiAliasingBuffer->setRenderBuffer(0, _antialiasingTextures[i]);

View file

@ -190,6 +190,10 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
const auto toneAndPostRangeTimer = task.addJob<BeginGPURangeTimer>("BeginToneAndPostRangeTimer", "PostToneOverlaysAntialiasing"); const auto toneAndPostRangeTimer = task.addJob<BeginGPURangeTimer>("BeginToneAndPostRangeTimer", "PostToneOverlaysAntialiasing");
// AA job to be revisited
const auto antialiasingInputs = Antialiasing::Inputs(deferredFrameTransform, lightingFramebuffer, linearDepthTarget, velocityBuffer).asVarying();
task.addJob<Antialiasing>("Antialiasing", antialiasingInputs);
// Add bloom // Add bloom
const auto bloomInputs = Bloom::Inputs(deferredFrameTransform, lightingFramebuffer).asVarying(); const auto bloomInputs = Bloom::Inputs(deferredFrameTransform, lightingFramebuffer).asVarying();
task.addJob<Bloom>("Bloom", bloomInputs); task.addJob<Bloom>("Bloom", bloomInputs);
@ -246,10 +250,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
task.addJob<DrawBounds>("DrawOverlayInFrontTransparentBounds", overlaysInFrontTransparent); task.addJob<DrawBounds>("DrawOverlayInFrontTransparentBounds", overlaysInFrontTransparent);
} }
// AA job to be revisited
const auto antialiasingInputs = Antialiasing::Inputs(deferredFrameTransform, primaryFramebuffer, linearDepthTarget, velocityBuffer).asVarying();
task.addJob<Antialiasing>("Antialiasing", antialiasingInputs);
// Debugging stages // Debugging stages
{ {
// Debugging Deferred buffer job // Debugging Deferred buffer job

View file

@ -94,7 +94,7 @@ vec4 taa_fetchColor(sampler2D map, vec2 uv) {
vec3 taa_resolveColor(vec3 color) { vec3 taa_resolveColor(vec3 color) {
#if USE_YCOCG #if USE_YCOCG
return color_YCoCgToLinear(color); return max(vec3(0), color_YCoCgToUnclampedLinear(color));
#else #else
return color; return color;
#endif #endif