SSAO for monkeys

hi monkeys.



I've been working on an SSAO post filter for JME3 based on that article by Jos

Very nice! I am sure the sponza model would look excellent with it.

Perhaps you want developer access so you can include all those great filters in jME3?

Awesome! This'll make for a very picturesque blog update :smiley: You might actually make it in for alpha-2.

And there it is : Sponza with shadows and SSAO





the same but without SSAO





Just the AO channel





Note that there still no additional blur pass. The frame rate cries a little bit…no vsync here. geforce gtx 275, But actually PSSM is taking the biggest part of it.



Another shot





I have some clean up to do in the code, once it’s done, i’ll post it.



Enjoy


1 Like

Wow, that looks really great! Should make a great blog post, perhaps to coincide with the new website launch?  :wink:

Awesome!

Simply kick ass.

Brilliant!!!

Thank you guys :wink:

wow!.. I can't wait to try this out

Awakening this thread as it would be really cool to use this. I have tried the filter and its rather fps expensive if you want a good visible effect (the default settings is btw hardly noticeable in my scene). Any particular reason why a game like Minecraft has a very smooth ambient occlusion with rather high framerates? Are they using some trickery and not the same kind of algorithm?



A standard problem with all 3d games is that objects are not “rooted” and you have to paint shadow maps or a “darkness” layer to give them the look of being part of the scenery and not “floating”. Ambient Occlusion seems to do the trick for getting a similar effect and saves a lot of work. :slight_smile: - Hoping there will be some more development on this if possible.

@johncl said:
Any particular reason why a game like Minecraft has a very smooth ambient occlusion with rather high framerates?

I almost spilled my coffee on the screen reading this.
Minecraft has vertex color...at best

Ambient occlusion is expensive, and ours is one of the fastest implementation i have seen. reed this http://hub.jmonkeyengine.org/2010/08/16/screen-space-ambient-occlusion-for-jmonkeyengine-3-0/ there is a link to the original paper and implementation by José Maria Mendez.

I have some papers on nice implementation that give better results, but for similar frame rate. What ever you do...SSAO is expensive.

Hehe, sorry to ruin your screen with coffee, but for a long time a mod added ambient occlusion (BetterLight):



http://www.minecraftforum.net/topic/52079-mrmmods-betterlightgrass-simplemap-181/



And then Minecraft got a similar looking shading, but I guess its a type of shading that is is only calculated once and locally updated now and then (whenever you remove/add blocks) for shading the polygons and not something done on every frame of rendering like a true Ambient Occlusion thingy.



I just think it looks good, and wonder if it would be possible to do something similar in jMonkeyEngine for static objects? Its basically precomputed shadowing to make stuff look more “rooted” and get a feeling of ambience without turning to shadowmaps but by simple polygon shading. But I guess it will only look good for areas with high polygon count where this kind of shadowing feels “local”?

To elaborate a bit more. Would it be possible for objects that are placed on a terrain mesh to affect shading on polygons on the terrain in such a way that it looks like the effect of ambient occlusion, sort of like a shadow map but only affecting shading of the nearby polygons using simple gouraud/phong shading techniques? Likewise the same happening on the object itself for polygons near the surface of the terrain.

I think I found an article describing what I was thinking of:



http://www.iquilezles.org/www/articles/pervertexao/pervertexao.htm



Its a process that can be calculated quickly when the scene is set up and “just” requires a material that can store shadow values per vertex to be used for interpolation. The main problem is that the objects should have a fair amount of polygons unless its possible to weigh the “distance shadow should travel out on the polygon”.



It looks to me also that the Type.Color vertex buffer could be used for this effect. I see Lighting shader has a UseVertexColor. Hmm, challenge then is finding an algorithm that creates these color buffers depending on closeness to other objects.

A better way for static objects is to bake Ambient occlusion into the diffuse texture, it gives a very good lighting feeling.

For the minecraft mod, this is not Screen Space Ambient Occlusion, as I said it’s tweaking vertex color on the mesh level (not updated every frames)

It’s true that it give a nice impression of AO, but somehow it’s baked into the mesh and wouldn’t work for dynamic objects.



The thing is, Lighting in a 3D scene is an area of research on itself, there are thousandth of techniques that give a more or less realistic lighting feeling. SSAO is just one of them, that’s quite in vogue at the moment, but just one among thousandth.


@johncl said:
I think I found an article describing what I was thinking of:

http://www.iquilezles.org/www/articles/pervertexao/pervertexao.htm

That what I said, it's baked into the mesh, and won't work for dynamic objects. But this could be nice indeed.
But the advantage of this over baking AO into the diffuse texture is discutable.

Well for a diffuse texture you would have to do it for every object. Imagine a landscape with 2500 rocks and 3000 trees of varying size and shape, putting this in the mesh would then be advantageous, as well as you dont have to worry about where it is placed and can move stuff around and just run the terrain through a new AO-like calculation when you are ready, in fact it could be used on procedurally generated landscapes too if there is some CPU time before the objects become visible in the landscape.



Anyway, an interesting idea and perhaps someone has time to pursue… I got to learn how to assemble mesh’es myself before I start anything like that. :slight_smile:

@johncl said:
Well for a diffuse texture you would have to do it for every object. Imagine a landscape with 2500 rocks and 3000 trees of varying size and shape,

yeah but AO is a low frequency effect that support very well scaling and blurring, you could have one big map for the entire scene (light map), and just have different texture coordinates.

@johncl said:
Imagine a landscape with 2500 rocks and 3000 trees of varying size and shape

if your hardware can do that it can do SSAO...
Also you would need very dense meshes to get a result like ssao.

@johncl said:
putting this in the mesh would then be advantageous, as well as you dont have to worry about where it is placed and can move stuff around and just run the terrain through a new AO-like calculation when you are ready

No, it has to be for static objects only to be interesting. If you want to compute it on the fly for any moving object you're better off using SSAO.

In outside scenes sunlight dominates and AO is barely visible thus AO is rarely used in outdoor scenes. Also like johncl mentioned you would need unique texture coordinate sets for every object on the map, not to mention the texture space allocated per object and additional overhead. It is a lot of data to bake so definitely won’t work in a game you’re putting up for download and such. I estimate about 50-200 MB just for a single map (depending on map size), and you might have many maps, etc. It will only work for games distributed on CD.



For indoor scenes AO (or lightmapping) is better option and the scenes are smaller so the texture space is better utilized. It is a big gain too because indoor scenes have many lights with shadow effects and computing all of that in real time can be slow on low-end GPUs

@Momoko_Fan said:
In outside scenes sunlight dominates and AO is barely visible thus AO is rarely used in outdoor scenes. Also like johncl mentioned you would need unique texture coordinate sets for every object on the map, not to mention the texture space allocated per object and additional overhead. It is a lot of data to bake so definitely won't work in a game you're putting up for download and such. I estimate about 50-200 MB just for a single map (depending on map size), and you might have many maps, etc. It will only work for games distributed on CD.

For indoor scenes AO (or lightmapping) is better option and the scenes are smaller so the texture space is better utilized. It is a big gain too because indoor scenes have many lights with shadow effects and computing all of that in real time can be slow on low-end GPUs


If you see this video series from Rendering Architect Johan Andersson of Dice, then you might say otherwise.

I have seen a lot of games are having baked AO map for outdoor scenes. Overgrowth from wolfire is a good example. I agree with huge light/AO map size, but there is *should* be a way that I am missing here.