Better SSAO

Hey guys I updated the SSAOFilter today.

I randomized the samples in the ssao computation and added a blur pass to the output.

The result is a bit slower than before, but the render is way better



Here are some screens of the sponza scene (the new TestSSAO in the repo)

I added a stone texture (diffuse + normal maps) and just added an ambient light.

This is the result with and w/o SSAO





direct link to fullres screen : http://i.imgur.com/cADFk.jpg

4 Likes

I really love progress on such things, got to learn that shader stuff myself one day :stuck_out_tongue:

Just wondering, in the down right image, on the left side, my eyes may deceive me but it looks like the edge of the cylindrical object is a bit fuzzy, is that due to the blur you added?



Other than that, got any pics to compare with the old SSAO? I really liked the old one already so I’m keen on seeing the differences :wink:

Yeah, the Common/MatDefs/SSAO/Textures/random.png texture is missing, @nehon only committed the code :slight_smile:

:frowning:

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.NullPointerException

at com.jme3.post.ssao.SSAOFilter.initFilter(SSAOFilter.java:145)

at com.jme3.post.Filter.init(Filter.java:168)

at com.jme3.post.FilterPostProcessor.initFilter(FilterPostProcessor.java:122)

at com.jme3.post.FilterPostProcessor.reshape(FilterPostProcessor.java:332)

at com.jme3.post.FilterPostProcessor.initialize(FilterPostProcessor.java:118)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:695)

at com.jme3.renderer.RenderManager.render(RenderManager.java:742)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:249)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:158)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:203)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221)

at java.lang.Thread.run(Thread.java:619)

erf sorry.

this should work now



@baalgarnaal the blur is a bilateral blur that doesn’t blur edges to avoid that kind of “fuzzyness” you are talking about. So …i guess that’s you eyes :stuck_out_tongue:



About the comparison with the old one, yeah why not… I could do that.

The thing before there was visible bandings, so if the sample radius was too wide this was ugly and if it was to low, it was ok but the filter acted more like and outliner than ssao.



Now you can spread the sample radius and have this “shadowing” feeling.



thanks for your comments

Hi,



if I try to run the SSAO-File, I get:

[java]

SCHWERWIEGEND: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IllegalArgumentException: Material parameter is not defined: NumSamples

at com.jme3.material.Material.checkSetParam(Material.java:300)

at com.jme3.material.Material.setParam(Material.java:319)

at com.jme3.material.Material.setInt(Material.java:475)

at com.jme3.post.ssao.SSAOFilter.initFilter(SSAOFilter.java:173)

at com.jme3.post.Filter.init(Filter.java:168)

at com.jme3.post.FilterPostProcessor.initFilter(FilterPostProcessor.java:122)

at com.jme3.post.FilterPostProcessor.reshape(FilterPostProcessor.java:332)

at com.jme3.post.FilterPostProcessor.initialize(FilterPostProcessor.java:118)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:695)

at com.jme3.renderer.RenderManager.render(RenderManager.java:742)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:249)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:158)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:203)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221)

at java.lang.Thread.run(Thread.java:680)

[/java]

mhhh wait…you sure you are using the last version?

btw what version do you use?

line 173 of SSAO filter is a blank line

http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/desktop-fx/com/jme3/post/ssao/SSAOFilter.java

Hi,



this line comes from me trying to fix it. I use the the new Alpha4 and the svn engine version from today.



The real error message reads:

[java]

SCHWERWIEGEND: Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]

java.lang.IllegalArgumentException: Material parameter is not defined: NumSamples

at com.jme3.material.Material.checkSetParam(Material.java:300)

at com.jme3.material.Material.clearParam(Material.java:338)

at com.jme3.post.FilterPostProcessor.renderFilterChain(FilterPostProcessor.java:204)

at com.jme3.post.FilterPostProcessor.postFrame(FilterPostProcessor.java:224)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:725)

at com.jme3.renderer.RenderManager.render(RenderManager.java:742)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:249)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:158)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:203)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221)

at java.lang.Thread.run(Thread.java:680)

[/java]

fixed in last SVN

Works…beautiful :slight_smile: Thx

hi nehon, I’m not good with shaders but I found this guy did a pretty good implementation in openGL GLSL and provided the code for the shader. If you are interested in fast good looking shader perhaps you could take a look at his article and shader and study it so you can improve your shader or perhaps even integrate his version an optional to yours SSAO.

also an article of interest HSAO (Horizon Based Occlusion)



excerpt from the article:



“Since Ambient Occlusion seemed liked the simplest, I decided to tackle it first. After I read a few white papers and this presentation on the NVIDIA Site it was pretty easy to implement. I used HBAO, Horizon Based Ambient Occlusion, an improved form of screen-space ambient occlusion (SSAO). Here is the final result.”



implementation of it:

http://vimeo.com/19686472



nvidia article on SSAO

NVIDIA Direct3D SDK 10 Code Samples



I hope these can help in making even better SSAO for jMOnkey



over and out

Well I bow down, my friend normen let me know that actual shader in jmonkey is based on the article above and article in gamedev :slight_smile: well perhaps my second link could offer something then, HBAO in case its really better as XNA guy claims! :smiley:

Hey , the ssao implementation is based on this article by Jose Maria Mendez http://www.gamedev.net/reference/articles/article2753.asp



the video you posted is nice, but, IMO, Mendez’s way of doing it is better.

As you can see in the video, “shadows” seems to be cast in the camera looking direction.

One issue though in this implementation is that ssao disappear on the border of the screen and it’s a lot more noticeable with a wide radius.

But i guess this can be fixed.



Maybe i should do a video like this one with sponza textures, so we could compare.

yeah please do that if you have time :slight_smile: btw SSAOTest,java and SSAOTest2.java we should update these with better models or something, right now the effect is so poorly visible and I even doubt that what I’m looking is SSAO in those tests. perhaps new tests that better showcase this technology should be prepared, SSAO is one of features jMonkey should boast about being able to deliver, so it would be nice with better demos :slight_smile:

mhh wait

there is only one TestSSAO now, I removed the old ones for the reason you’re mentioning.

What version do you use?

The testSSAO use the sponza model with a rock wall texture.

Well I think my jMP has last been updated 2-3 weeks ago, with source code since I checked in options that I want nightly builds, question is when did you add this? if its recent then its not strange that I see test1, test2 files, if its over a month old then I should have seen it?

yeah i added this just before alpha 4 release a couple of weeks ago.

@nehon: I don’t know why when I try to run TestSSAO.java , I get a poorly framerate of 8fps for my WindowXP SP3 and NVIDIA GeFocre 8600GT… The same with the TestHoverTank in BulletTest , 8fps with or without PSSM the same ??



But all other examples work pretty well for me at higher than 40fps , including the last “WaterScene” with island!

you are not the only one with the TestHoverTank, I get poor FPS there as well around 5-7 fps. ATI Radeon HD 5700 1 gb