Noisy SSAO – no anti-aliasing

I’m new to jme but so far I like it.



I am playing with lighting and shadows and have noticed that the SSAO can be quite noisy (see below). Also, it doesn’t seem to work with anti-aliasing. Is there a way to enable both of these in jme or is it one or the other?



4xAA - no SSAO





SSAO - no AA





Edit: forgot to post code, even though it’s the same code you’ve all seen before.



[java]

private void setupSSAO() {

FilterPostProcessor fpp = new FilterPostProcessor(assetManager);

SSAOFilter ssaoFilter = new SSAOFilter(12.940201f, 43.928635f, 0.32999992f, 0.6059958f);

fpp.addFilter(ssaoFilter);

viewPort.addProcessor(fpp);

}

[/java]



Full code: http://pastebin.com/uBhcfPk2



Edit: Updated code, with SSAO and FXAA working in relative harmony: http://pastebin.com/vu1W1vJQ

This is normal afaik, using SSAO doesn’t let you use AA. You can try using the FXAA filter though.

SSAO is noisy, but it’s less noticeable if you have textured objects instead of plain colored ones.

You can use SSAO with AA, but there was an issue fixed recently about it, so maybe if you are using beta, you have this issue.

You can try FXAA as a workaround.

FXAA doesn’t work with small objects, stuff that are less then one pixel in size. They woun’t be anti aliased (obviously…). I noticed that with edges of branches, treetops etc. That makes this situation interesting to me.



Is the noise “flickering” or is it more or less static when you move the cam around? I’d like to know if FXAA works well in this particular case, if you are going to try it anyways.

@imdsm said:
[java]
private void setupSSAO() {
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
SSAOFilter ssaoFilter = new SSAOFilter(12.940201f, 43.928635f, 0.32999992f, 0.6059958f);
fpp.addFilter(ssaoFilter);
viewPort.addProcessor(fpp);
}
[/java]


Also, when you have AA enabled you need to set the sample size on the FilterPostProcessor. At least you used to... I don't know if this has been changed recently or not.
@normen said:
This is normal afaik, using SSAO doesn't let you use AA. You can try using the FXAA filter though.


FXAA works but very temperamentally. Sometimes it's fine, other times it causes the screen the freeze or go black. Could be the way I am applying it, but maybe not.

@nehon said:
SSAO is noisy, but it's less noticeable if you have textured objects instead of plain colored ones.
You can use SSAO with AA, but there was an issue fixed recently about it, so maybe if you are using beta, you have this issue.
You can try FXAA as a workaround.


I thought it may be less noisy with textures (e.g. the ssao test), but wasn't sure if there was something I could do for coloureds.

@androlo said:
FXAA doesn't work with small objects, stuff that are less then one pixel in size. They woun't be anti aliased (obviously..). I noticed that with edges of branches, treetops etc. That makes this situation interesting to me.

Is the noise "flickering" or is it more or less static when you move the cam around? I'd like to know if FXAA works well in this particular case, if you are going to try it anyways.


No flickering, it's nice and solid, just a bit noisy. When I enable FXAA it starts to have problems.

@pspeed said:
Also, when you have AA enabled you need to set the sample size on the FilterPostProcessor. At least you used to... I don't know if this has been changed recently or not.


Couldn't find any sample size to set, there is a sample radius, which is the first parameter (~ ssaoFilter.setSampleRadius(sampleRadius)).

----

I've only tried them on my work computer as of yet (old card..GTX 8800), so it may run better at home. I'll try again later and post the results. The code in case you want to try out FXAA and SSAO glitches:

http://pastebin.com/h73bJ0GU (HelloShadows.java)
http://pastebin.com/vqFavB24 (RtsCam.java)

Controls: O (Toggle SSAO), P (Toggle PSSM), K (Toggle AA 0,2,4,8,16), L (Toggle FXAA)

Oh, also, what type of AA does jme use with settings.setSamples?
@pspeed said:
Also, when you have AA enabled you need to set the sample size on the FilterPostProcessor. At least you used to... I don't know if this has been changed recently or not.

True! You have a fpp.setNumSample(int samples) method.

@imdsm said:
Oh, also, what type of AA does jme use with settings.setSamples?

hardware Multi sampling.
1 Like

The test cases work well for me, if I change the ssao and fxaa filters to use the same filterpostprocessor. One filterpostprocessor can contain many filters, don’t need one for each.



Tried multi-sampling as well. I didn’t notice any difference between FXAA and multi-sampling (other then the framerate).

1 Like

This of course is the expected result. FXAA can fail at anti-aliasing geometry (since there isn’t a MS framebuffer), but not textures. I was curious about how SSAO works in practice tho. It’s so advanced.

1 Like
@androlo said:
The test cases work well for me, if I change the ssao and fxaa filters to use the same filterpostprocessor. One filterpostprocessor can contain many filters, don't need one for each.

I would even say, that 2 fpp may yield unexpected result.
1 Like

Ah I see. I wasn’t sure if I should bunch them all together or not. In that case, would it be possible to get some like this added to FilterPostProcessor.java?



[java]

/**

  • Returns true if the filter exists in the filters<br>
  • @param filter the filter to look for

    */

    public boolean containsFilter(Filter filter) {

    return filters.contains(filter);

    }

    [/java]



    It would make it much easier to toggle filters.



    Edit: Combined into a single FilterPostProcessor with excellent results. Thank you.