Download

Screenspace blur for SSAO [C++]

Hi!

I originally posted this in the engine source section, but wasn’t getting much luck, so I’ve deleted that thread, and moved it over here.

So, I’ve been having a quick look into adding a gaussian blur pass to the SSAO, so it doesn’t need to rely on TXAA (Which has been causing a bunch of issues in my project).

So far, I’ve tried adding the following snippet to “ProcessAfterBasePass” in CompositionLighting.cpp, however it doesn’t seem to be having any real effect.


FRCPassPostProcessWeightedSampleSum* PostProcessBlurX = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessWeightedSampleSum(EFS_Horiz, EFCM_Weighted, 1.1f, TEXT("AO Blur X"), FLinearColor::White));
FRenderingCompositePass* SSAO = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(SceneContext.ScreenSpaceAO));
PostProcessBlurX->SetInput(ePId_Input0, SSAO);

FRCPassPostProcessWeightedSampleSum* PostProcessBlurY = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessWeightedSampleSum(EFS_Vert, EFCM_Weighted, 1.1f, TEXT("AO Blur Y"), FLinearColor::White));
PostProcessBlurY->SetInput(ePId_Input0, FRenderingCompositeOutputRef(PostProcessBlurX));

Does anyone have any advice on why this isn’t working, and any suggestions on how to proceed?

and them, where PostProcessBlurX is used ?
if you do not use PostProcessBlurX, then the whole part of graph will be eliminated …

Hi MXADD, thanks for the reply!

PostProcessBlurX is being used as ePId_Input0, for the PostProcessBlurY. See:


PostProcessBlurY->SetInput(ePId_Input0, FRenderingCompositeOutputRef(PostProcessBlurX));

Figured it out on my own. Added some Cvars to control the blur radius, and to turn the blur on/off based. Added a pull request to have it added.

Sorry to bump an old thread, but I’ve been working on blurring the SSAO buffer for use with FXAA as well. I grabbed PBKS’s pull request from git (here) and got it to compile with 4.12, but I’m not seeing any changes to the SSAO. I ended up commenting out the CVARS just to narrow it down, and after debugging with VS I found that in PostProcessWeightedSampleSum this line:


FRCPassPostProcessWeightedSampleSumInputBlur::FRCPassPostProcessWeightedSampleSumInputBlur(EFilterShape InFilterShape, EFilterCombineMethod InCombineMethod, float InSizeScale, const TCHAR* InDebugName, FLinearColor InTintValue)
	: FRCPassPostProcessWeightedSampleSum(InFilterShape, InCombineMethod, InSizeScale, InDebugName, InTintValue)
{
 
}

is getting called just fine, but this line:


void FRCPassPostProcessWeightedSampleSumInputBlur::Process(FRenderingCompositePassContext& Context)
{

never gets called. I looked into how the full screen blur and bloom calls it but it looks identical to what was written here and they somehow call the process function, so I’m not sure what I am missing. Anyone get this pull successfully implemented in 4.12?

I would love to see a comparison screenshot between TAA blur and gaussian blur with SSAO :slight_smile:

I’ve figured out my problem - the original poster changed his username and posted some more code here for those following.

No blurring, single pass SSAO (super dithering)
NoBlurOneLevelSSAO.JPG

Screenspace Gaussian blur using WeightedSampleSum, single pass SSAO
0789a44bc95119fa0b5de399701c7313f3cd11d6.jpeg

Temporal Filtered, single pass SSAO
TAAOneLevelSSAO.JPG

Temporal still definitely looks the best when looking at the buffer directly, but in the complete scene blurriness of the Gaussian blur is far superior to the grainy dithered look of the unfiltered image if you are using FXAA. We are using a full 1080p buffer for PS4 anyways so the lack of super clean AA is not as noticeable as if we were up-scaling.

Thanks for the comparison! I’m trying to implement this too, but unfortunately I get some strange results. I also see everything turning red when the static friction is more than 0, but that’s not really a problem. The blur itself doesn’t seem to work correctly, it looks way worse than on your screenshot:

No blur:

With blur (radius 5):

I’ve tried different values for the radius, but the problem stays the same.

When you look at it closer you see that there is some strange vertical pattern in the blurred SSAO:

http://puu.sh/sVaiy/bbe0ea1112.png

Any idea what causes that? What engine version are you using this with?

So, a bit of a tangent, but I’ve been having absolutely wonderful results with NVIDIA GameWorks’ HBAO+ (v3 – huge improvement over the commonly-used v2 that’s floating around): https://joy-machine.com/devlog/2016/11/27/engine-development

I have still not found how to make this work in 4.14 or 4.15, so if anyone knows how to get this working without getting those strange artifacts, I would love to hear about it :slight_smile:
[MENTION=2791]James Steininger[/MENTION]

I also had the problem that I only got the SSAO to appear on one eye in VR when I had the changes applied, the other eye would not see any SSAO.