Skip to content

Commit

Permalink
#86 Update anti aliasing FXAA on linear color space
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed Oct 7, 2020
1 parent fdeb312 commit 0bd017c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
55 changes: 30 additions & 25 deletions Projects/Skylicht/Engine/Source/RenderPipeline/CPostProcessorRP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace Skylicht
CPostProcessorRP::CPostProcessorRP() :
m_adaptLum(NULL),
m_lumTarget(0),
m_autoExposure(true),
m_bloomEffect(false),
m_autoExposure(false),
m_bloomEffect(true),
m_fxaa(false),
m_brightFilter(NULL),
m_blurFilter(NULL),
Expand Down Expand Up @@ -242,35 +242,19 @@ namespace Skylicht
renderBufferToTarget(0.0f, 0.0f, renderW, renderH, m_effectPass);
}

if (m_fxaa)
{
if (colorID >= 0)
colorBuffer = m_rtt[colorID];

core::dimension2du rrtSize = colorBuffer->getSize();
float params[2];
params[0] = 1.0f / (float)rrtSize.Width;
params[1] = 1.0f / (float)rrtSize.Height;
m_fxaaFilter->setUniform2("uRCPFrame", params);
m_fxaaFilter->setTexture(0, colorBuffer);
m_fxaaFilter->applyMaterial(m_effectPass);

CShaderMaterial::setMaterial(m_fxaaFilter);

colorID = !colorID;
driver->setRenderTarget(m_rtt[colorID], false, false);

beginRender2D(renderW, renderH);
renderBufferToTarget(0.0f, 0.0f, renderW, renderH, m_effectPass);
}

if (colorID >= 0)
colorBuffer = m_rtt[colorID];

if (m_autoExposure == true)
luminanceMapGeneration(colorBuffer);

driver->setRenderTarget(finalTarget);
if (m_fxaa)
{
colorID = !colorID;
driver->setRenderTarget(m_rtt[colorID]);
}
else
driver->setRenderTarget(finalTarget);

if (m_autoExposure == true)
{
Expand All @@ -290,6 +274,27 @@ namespace Skylicht

m_lumTarget = !m_lumTarget;

if (m_fxaa)
{
if (colorID >= 0)
colorBuffer = m_rtt[colorID];

core::dimension2du rrtSize = colorBuffer->getSize();
float params[2];
params[0] = 1.0f / (float)rrtSize.Width;
params[1] = 1.0f / (float)rrtSize.Height;
m_fxaaFilter->setUniform2("uRCPFrame", params);
m_fxaaFilter->setTexture(0, colorBuffer);
m_fxaaFilter->applyMaterial(m_effectPass);

CShaderMaterial::setMaterial(m_fxaaFilter);

driver->setRenderTarget(finalTarget, false, false);

beginRender2D(renderW, renderH);
renderBufferToTarget(0.0f, 0.0f, renderW, renderH, m_effectPass);
}

// test to target
/*
ITexture *tex = m_rtt[2];
Expand Down
1 change: 1 addition & 0 deletions Samples/SampleFW/Context/CContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ CBaseRP* CContext::initRenderPipeline(int w, int h, bool postEffect)
{
// post processor
m_postProcessor = new CPostProcessorRP();
m_postProcessor->enableAutoExposure(true);
m_postProcessor->enableBloomEffect(true);
m_postProcessor->enableFXAA(true);
m_postProcessor->initRender(w, h);
Expand Down

0 comments on commit 0bd017c

Please # to comment.