PDA

View Full Version : Ambinet Occlusion


Maxim_311
08-11-2005, 02:28 AM
Can someone explain to me what ambient occlusion is and how/what its used for? I've seen render passes of peoples images and they have a ambient occlusion pass and I was wondering how its used in comping the final image? Why use a ambient occlusion pass? Any information/help is greatly appreiciated. Thanks.

jeremybirn
08-11-2005, 02:53 AM
Ambient occlusion is basically just a process where, when the renderer renders each point on each surface, it basically shoots rays out from that point and measures how many nearby objects are around it, and how close any other objects are. The theory is, if you were out in the open, and could see nothing but sky all from that point, it should be brighter, because ambient light could reach the point from more directions. If a point is right underneath something, covered up, or in a crack, then it would go darker because of its proximity to other geometry, on the theory that less ambient light would reach that point.

In the composite, an ambient occlusion pass can be multiplied with your fill light to create an impression of soft shadows in your scene. Usually you don't need it to influence your key light - let's say if a scene were outdoors, the sunlight wouldn't need it (it would have its own shadows anyway), but all the fill from the sky and bounce from the ground, that would get multiplied by the ambient occlusion. Ambient Occlusion makes a better impression of contact between surfaces that are touching or near to eachother, adds the impression of soft shadows and makes your fill light more realistic.

-jeremy

Maxim_311
08-11-2005, 03:14 AM
So to create a ambient occlusion pass is it a shader applied to the models or is it something done with the lights in the scene?

Since you said it meant to be used to make you fill lights give a better impression do you disable you key light (or not apply it to your key) when rendering? I'm just trying now to get my head around the workflow associated with creating a ambient occlusion pass. I understand it will be different depending on the software, I'm just trying to get an idea.

And when you say "an ambient occlusion pass can be multiplied with your fill light to create an impression of soft shadows in your scene" is this something normally done or is it situational depending on what look your going for?

Another little question is are abient occlusion passes normally done all/most of the time? Or are they only used when the occasion calls for it?

Thanks for all the info!

jeremybirn
08-11-2005, 03:24 AM
Whether it's a shader applied to all your surfaces (as it is in Mental Ray) or a global switch to render an occlusion pass, would depend on your software. Ambient occlusion does not use or take into account any lights at all (it is just based on distance to other surfaces) so you don't need any lights visible when rendering an ambient occlusion pass.

If you have rendered your fill lights as a separate pass, you could multiply that with your AO.

Ambient occlusion adds greatly to realistic scenes, so it's always useful. Exceptions might be scenes rendered with Global Illumination or Final Gathering, which naturally already include occlusion, making AO redundant.

-jeremy

Wiro
08-11-2005, 04:32 AM
Ambient Occlusion is a word that's been mentioned very frequently lately in big movies but I remember using a 3ds max plugin 6-7 years ago called Dirtyreyes that did exactly that (shoot out hemispherical rays and then save the result in a texture). But back then this effect was used to mask dirt into corners.
Sorry for rambling but I just don't get why this is better than *real* skylight renders which today are very fast as well. Is there some coding reason? Renderman or Mental Ray limitations?

Wiro

jeremybirn
08-11-2005, 09:12 AM
Ambient Occlusion is a word that's been mentioned very frequently lately in big movies but I remember using a 3ds max plugin 6-7 years ago called Dirtyreyes that did exactly that (shoot out hemispherical rays and then save the result in a texture). But back then this effect was used to mask dirt into corners.
Sorry for rambling but I just don't get why this is better than *real* skylight renders which today are very fast as well. Is there some coding reason? Renderman or Mental Ray limitations?

I don't know which software you are using when you coin phrases like "*real* skylight renders" - it sounds like you are refering to something specific that you could describe for us?

Ambient occlusion is certainly not "better" than a full GI or even FG solution, or even than an Image Based Lighting (IBL) solution with integrated occlusion which you seem to be favoring. If anything, people use it because it is simpler, because it only measures the distance to another surface without calling the other object's shader or evaluating the shader or lighting on the other surface. In some renderers, like Mental Ray, you can often get performance that's about as good with FG (Final Gather) renders as with AO, so it becomes a real question whether you want to use AO at all.

-jeremy

playmesumch00ns
08-11-2005, 11:47 AM
The first reason to use it is because it's fast.

The second reason to use it is because you can bake it and mix it in with your existing lighting (even GI if you want), and only need to re-bake when your animation changes.

In terms of bang for your buck (i.e. extra realism for increased render time), ambient occlusion is, imho, better value than GI.

Ian Jones
08-11-2005, 12:07 PM
From my brief experience with Mentalray... I have found that Final Gathering is often a bit faster than Ambient Occlusion. So I agree with Jeremy that at times, it can become redundant. In the case of simulating dirt accumulating in corners, it is extremely useful.

Wth Mentalray I find that to get a clean result from AO I have to use 128 samples (3dsmax7) to get anywhere near a smooth result without too much grain. This is usually an equivalent speed to using FG at around 1000-1500 samples.

Of course, it's great to have both tools. Combining AO with a keylight pass (multiply blend mode) can work really nicely as Jeremy mentioned.

JamesMK
08-11-2005, 12:19 PM
In terms of bang for your buck (i.e. extra realism for increased render time), ambient occlusion is, imho, better value than GI.
Have to agree entirely with this. Even though AO sometimes can appear not much faster than full GI, it is so much more manageable - you know exactly how it will behave and exactly how many samples you will need in advance for a given scene, and you never get any surprises in terms of weird artifacts.


.

jeremybirn
08-11-2005, 04:34 PM
From my brief experience with Mentalray... I have found that Final Gathering is often a bit faster than Ambient Occlusion.

That's often true, but it's very much an exception to the general rule others have been saying. In general, AO ought to be much faster than FG, because FG needs to evaluate the shaders on the objects that contribute to the indirect diffuse bounce, whereas AO only needs to check the location of surrounding objects without evaluating their shaders.

In Mental Ray, however, Final Gathering is implemented as a highly optimized part of the renderer that appears to be calculated mostly during an under-sampled pre-pass, whereas AO is just a regular MR shader that needs a fairly high number of samples to avoid looking grainy.

-jeremy

Wiro
08-12-2005, 01:52 AM
Not having used PRMan or MR I'm just very curious about the benefits. When I said skylight I didn't mean a fullblown GI solution but only a first bounce. In for example VRay one can store this solution. And you could techincally also just do a skylight pass and add over a main light (non-GI) pass. I'm wondering because I once heard calculationtimes of an ambience occlusion pass taking hours (I think this was in a Spiderman1 talk at Siggy) which seems even more than a skylight pass.

Another reason why I'm wondering about the difference between what many renderers call skylight and what you call ambient occlusion is that the particular method seems to be the same; rays are being shot out hemispherically from objects until they either hit another surface (dark) or the skylight (light).

I'm just wondering if it's a matter of terminology or if there really is a deeper difference. It's been something I've asked on this forum several times but apart from a lot of handwaving never really gotten a satisfactory answer to :)

[edit] I just read Jeremy mentioning AO passes not having to call up shaders. That makes sense for renderspeeds but wouldn't that be the same as applying a flat grey shader before doing a skylight pass?

Wiro

jeremybirn
08-12-2005, 03:13 AM
Ah, thanks for clarifying on "skylight" - that sounded like a term for something like Image Based Lighting or something - indeed "how much sky is visible" is very much what AO is about.

You can produce a lot of passes that look similar to or identical to an AO pass using a range of different tools. Almost any GI or single-bounce GI-type solution basically will look like AO if you illuminate a big white dome around your scene. Except - often AO sets a falloff distance (only looking for a certain number of units away from the surface) so even in areas where the sky is already blocked, AO creates shading based on the proximity of other objects within the falloff distance.

In terms of render speed, not checking shaders at all is much faster than checking shaders on each surface only to find that they are gray. In terms of results things might look the same though.

-jeremy

Wiro
08-12-2005, 04:50 AM
In terms of render speed, not checking shaders at all is much faster than checking shaders on each surface only to find that they are gray. In terms of results things might look the same though.

Thanks Jeremy, that makes perfect sense. Not having compared with PRMan I wasn't aware there was that much of a speed penalty.

When I said "real skylight" in my first post I was referring to the difference between AO which, as you say only calculates out to a certain distance and skylight which always looks for the dome. So with AO if you had, for example, a bridge crossing a highway, you'd not get any of the bridge's soft shadow on the highway.

Anyway, it's cleared up the differences for me, thanks!

Wiro

JamesMK
08-12-2005, 08:29 AM
Inbetween the ambient occlusions, skylights and different terminology, it might perhaps be of interest to mention that there are also two distictively different ways to calculate occlusion: inside-out and outside-in respectively.

The former makes the calculation as mentioned above by tracing a number of rays in a hemispherical arrangement from the surface point and outwards to the maximum sampling distance to see if it hits another surface or the imaginary sky - while the latter sends rays from a sphere encompassing the object to see which surfaces are not hit by all rays, as neatly described by Andrew Whitehurst in this article: http://www.andrew-whitehurst.net/amb_occlude.html (a rather old article mind you, but it still has validity to visualise the concept even if it might not be done that way nowadays)

And if anyone is interested, I recently wrote two tutorials (specific to Cinema 4D however, but with a fair bit of package-neutral info) about AO and IBL: http://web.telia.com/~u48040664/ao_ibl_tut_02.zip and http://web.telia.com/~u48040664/ao_ibl_global.zip (both are zipped html archives: download, unpack and browse - unfortunately it does not include anything on bent normals, which really should be part of such a discussion, but alas, it is not)



.

stew
08-12-2005, 01:32 PM
In Mental Ray, however, Final Gathering is implemented as a highly optimized part of the renderer that appears to be calculated mostly during an under-sampled pre-pass, whereas AO is just a regular MR shader that needs a fairly high number of samples to avoid looking grainy.
Then again, you can also undersample AO and store it in an irradiance cache for some extra speed.

gerardo
08-13-2005, 10:35 AM
So to create a ambient occlusion pass is it a shader applied to the models or is it something done with the lights in the scene?

Since you said it meant to be used to make you fill lights give a better impression do you disable you key light (or not apply it to your key) when rendering? I'm just trying now to get my head around the workflow associated with creating a ambient occlusion pass. I understand it will be different depending on the software, I'm just trying to get an idea.

And when you say "an ambient occlusion pass can be multiplied with your fill light to create an impression of soft shadows in your scene" is this something normally done or is it situational depending on what look your going for?

Another little question is are abient occlusion passes normally done all/most of the time? Or are they only used when the occasion calls for it?

Thanks for all the info!


That is this way because is what happens in reality. Is even advisable to do it with your indirect "bounce lights" (a refined version of the simple fill light). And is this way, because the ambient occlusion effect are in fact the soft shadows provided by the radiance effect (photons that bounce from a surface to other), these shades are as soft and diffuse as the result produced by the radiance effect. If the radiance effect is imperceptible, then the occlusion effect also should be it; ie: a day scene (12pm) in the middle of desert, you will notice how in a scene like this, the illumination can end up being very contrasted, so that the occlusión effect is very limited (and surprisingly, the radiance effect too). The consequent idea of using multiplied mode for AO pass with bounce lights or fill light is so that the AO pass acquires the same tonalities (once again, as happens in reality) :)



Gerardo

lazzhar
08-14-2005, 07:49 PM
. Almost any GI or single-bounce GI-type solution basically will look like AO if you illuminate a big white dome around your scene. Except - often AO sets a falloff distance (only looking for a certain number of units away from the surface) so even in areas where the sky is already blocked, AO creates shading based on the proximity of other objects within the falloff distance.

-jeremy

The problem is that we're not able to get sharp details that AO is rendering quickly unless we use very high FG Rays with low Min Radius wich increase the render time dramaticly.
With the latest MR coming with Maya 7 there is an AO shader based in FG, did anyone try it?

francescaluce
08-14-2005, 10:19 PM
With the latest MR coming with Maya 7 there is an AO shader based in FG, did anyone try it?
you were able to do it also before ...
from mr3.3 infact fg returns the average of all alphas from
finalgather rays allowing ambient occlusion; technically
you use the build-in fg mechanism as qmc sampler, the
function that calculates irradiance will return earlier not
with the irradiance value for the point being shaded..
that means it has to call the shaders of the objs it has
probed, but instead only with the fg alpha for that point.
the way to use it is in a pass, no lights, nothing else
than a fg_occlusion shader as a global material override
for the pass, enable finalgather and use the fg falloffs
to ctrl the clipping occlusion. compared to classic
occlusion it is a bit slower, but has the advantage that
you can reuse the fg.map as an occlusion cache for
presampled points so tends to be of great impact in
production animations. another advantage of using
the build-in fg as sampler is that it pass through
transparent multiple objects with no charge at all
because transparency is handled 'internally' and does
not require shader calls, just plug a mib_transparency
to the objs you need to be not fully opaque.

http://img116.echo.cx/img116/6499/ctrlocclusion0027si.jpg
it took 6.15 (2x3ghz). it uses ctrl_irradiance but you should get exactly the same result.
freezing the fg.map, it takes 2.58; appending 4.32. classic occlusion is around 5mins.


ciao
francesca

lazzhar
08-15-2005, 09:40 AM
Wouah !! Right Frans !
Now I remember having your shader for oldest versions of Maya lost within my folders :rolleyes:

CGTalk Moderation
08-15-2005, 09:40 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.