• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
PixelSmasher

SSAO using line integrals

16 posts in this topic

Hello everyone !

I am currently implementing the SSAO technique used in Toy Story III in my rendering pipeline.
This technique is thoroughly described in the slides from [url="http://advances.realtimerendering.com/s2010/index.html"]Siggraph 2010[/url].

I had no problem implementing it, until I met an annoying banding issue, due to a high occlusion factor appearing on certain edges of the meshes, mainly on concave shapes.
After several days of eye-bleeding and struggling with black lines, I've come to think this is a natural flaw from this algorithm but would the wisdom of gamedev have any idea about how the guys from Toy Story solved it ?

Thanks in advance.

PS : this capture shows the problem in action : the SSAO quality is quite good (without any filtering) but the arches suffer from banding.
[img]http://i.imgur.com/CJQjz.jpg[/img]
0

Share this post


Link to post
Share on other sites
Apply a depth aware (bilateral) blur over it, and you're sorted :). You have to do that with most SSAO techniques due to the limited amount of samples you can take during occlusion computation.
0

Share this post


Link to post
Share on other sites
I intentionally disabled the blurring passes to show the banding artifact.
Even if the filter is applied, the black lines on the curved surfaces remain (blurred of course but still present). Edited by PixelSmasher
0

Share this post


Link to post
Share on other sites
The bands indeed appear specifically on edges between non-coplanar surfaces.

I thought about using the normals to discard edges forming an angle bigger than a given threshold, but I don't want to access the normal buffer to keep good perfs (and the Toy Story guys didn't use it after all !)
0

Share this post


Link to post
Share on other sites
Intuitively the bands are suppose to exist there. The problem is how intense they should be.

I'm not quite sure in the specific line integral implementation, but ambient occlusion should be with calculated using projected solid angle (i.e. cos(theta)/ndotl). Is the toy story slide accounting for the projected solid angle? It seems that they use occluded volume / total volume for the AO value. Edited by jameszhao00
0

Share this post


Link to post
Share on other sites
The line integrals method doesn't rely on the classical "ray-casting(-marching)" inside a sphere.
Here the volume integration is based on the contribution of the heightfield (the depth buffer) to the sphere volume.

Simplified, the formula looks like this
[CODE]
ao = 0
for each Samples
{
Sample.contribution = (Sample.depth - SphereCenter.depth) * Sample.volume
ao += Sample.contribution
}
// + insert fancy code to offset/scale the ao into [0,1]
[/CODE]

As you can see, the notion of solid angle (or angle itself!) doesn't exist here.


I'm currently trying to detect surface continuity using cheap normal reconstruction but I'm getting cheap results [img]http://public.gamedev.net//public/style_emoticons/default/unsure.png[/img] Edited by PixelSmasher
0

Share this post


Link to post
Share on other sites
[quote name='PixelSmasher' timestamp='1339188105' post='4947472']
The line integrals method doesn't rely on the classical "ray-casting(-marching)" inside a sphere.
Here the volume integration is based on the contribution of the heightfield (the depth buffer) to the sphere volume.

Simplified, the formula looks like this
[CODE]
ao = 0
for each Samples
{
Sample.contribution = (Sample.depth - SphereCenter.depth) * Sample.volume
ao += Sample.contribution
}
// + insert fancy code to offset/scale the ao into [0,1]
[/CODE]

As you see, the notion of solid angle (or angle itself!) doesn't exist here.


I'm currently trying to detect surface continuity using cheap normal reconstruction but I'm getting cheap results [img]http://public.gamedev.net//public/style_emoticons/default/unsure.png[/img]
[/quote]
Using projected solid angle makes obstruction near the horizon not matter much. In your case, you're having problems with slightly concave areas, which is essentially obstruction near the horizon. Not saying that projected solid angles will fix the issue, but it at least exaggerates the issue.

Anyways, using projected solid angle is similar to weighting slight obstructions (angle(n, l) approaches pi/2) less than big obstructions (angle(n, l) approaches 0). Edited by jameszhao00
0

Share this post


Link to post
Share on other sites
Weighting slight obstructions is achieved by the value attributed to Sample.volume (used before in the algorithm)

Sample.volume is the volume of the sphere above and below the area that the sample covers (search for pretty Voronoi pictures in the slides)
The further the sample is from the center, the smaller is the sphere height and so is the sample volume.

Edit : I may have misused these weights. I'm going to explore in that direction. Edited by PixelSmasher
0

Share this post


Link to post
Share on other sites
Imagine the shading point as being on the geometric boundary. As we decrease the angle between the two sides (i.e. fold it like a book), sphere obstruction (analytical) increases linearly. The ambient occlusion doesn't. Edited by jameszhao00
0

Share this post


Link to post
Share on other sites
I see your point but I have to disagree.

Let's imagine this book completely open (the angle between the pages is Pi).
If we fold it slightly, the depth difference would mainly benefit to the volume of the sample furthest from the shading point... multiplied by the lowest weight.

If we reach a smaller angle (let's say Pi/2), the contribution of the furthest sample would have reached its maximum value and a sample closer to the shading point would start its real contribution, weighted with a higher value.

This behaviour is not linear and I feel it mimics the contribution of the projected solid angle.

----------------------------

I tried some low value detection on the occlusion coefficients and obtained this image
It is not a satisfactory result as a lot of subtle details are lost.
[img]http://i.imgur.com/wagcc.png[/img] Edited by PixelSmasher
0

Share this post


Link to post
Share on other sites
Is the 'weight' the vertical volume in that slice?
If so, you're still approximating AO with spherical obstruction (albeit sample based)...

------

I think you have to take into account normals to compensate for those bands.

Pretend you're looking at only the depth buffer. You have no way to differentiate between a hard edge and a smooth edge, as the smooth edge appears hard in the depth buffer. The interpolated shading normal is where you get the 'oh it's a smooth edge' information.

Also if you discard, don't forget to scale the resulting stuff (total volume is no longer volume of a sphere) Edited by jameszhao00
1

Share this post


Link to post
Share on other sites
[quote name='jameszhao00' timestamp='1339202969' post='4947538']
Is the 'weight' the vertical volume in that slice?
If so, you're still approximating AO with spherical obstruction (albeit sample based)...
[/quote]
Yes it is, and I have to agree with you [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img].

I eventually tried some smooth-edge detection based on normal difference. The results are not that great, the GPU bandwidth has exploded and the slightest idea of performance is dead on the battlefield
(Yeah I know it should be painless in a proper deferred pipeline, but I have to integrate this code in an odd, bloated and insulting pipeline where outputting normals in the G-Buffer is prohibited).

I'm still working on it.
0

Share this post


Link to post
Share on other sites
After another day of math tips and tricks, here is the latest version of my SSAO (after a bilateral blur pass).
With good per-scene adjustements, I think this one will do.

[img]http://i.imgur.com/has6Y.png[/img] Edited by PixelSmasher
0

Share this post


Link to post
Share on other sites
I get good results on PC (5 ms with an unoptimized version).

On console, which is the release target, I get disastrous perf (8 ms on a 720p resolution), mainly due to a low texture cache.
I'm currently working on aggressive optimizations and will update this post when I'll get a shippable implementation.
0

Share this post


Link to post
Share on other sites
Hi again and sorry for the late answer.
After several optimizations, loop unrolling and code vectorization, I get awesome results with the same image produced in 2.36ms for a 720p resolution ![list]
[*]AO computation pass : [b]1.5 ms[/b]
[*]Horizontal bilateral blur : [b]0.43 ms[/b]
[*]Vertical bilateral blur : [b]0.43 ms[/b]
[/list]
Hints :
- The GL_AMD_texture_texture4 extension (allowing to quickly fetch 4 adjacent pixels) was available on the target console. Always use it (or fetch4 or textureGather or whatever with the same behaviour) and smile while looking at your perf counter.
- Kill loops with fire ! They are horridly slow ! (Look at the code generated by your shader compiler to see if they were not unrolled at compil time) Edited by PixelSmasher
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0