PDA

View Full Version : OCCLUSION PASS guide


zman
04-07-2006, 09:08 PM
sup everyone, I've decided to write up a little tutorial to share a technique that I find very usefull.
Its about occlusion passes.
In this tutorial I will try to cover everything you need to know about occlusion pass in 3 simplified parts.
The first part is explains what an occlusion pass is and what its good for.
The second part is all the technical info on how to make an occlusion pass.
the third part explains how to use it.

zman
04-07-2006, 09:09 PM
WHat is occlusion ?
To simplify the explanation, just think of a situation when all your objects have a simple white color and your scene is lit equally from all directions by a white light. Basically this should result in a blank white image, but what happens when some objects block a certain amount of rays that should have gotten to other objects ? those rays don't reach the other object and as a result, the parts where the rays were blocked will become darker. The more rays blocked, the darker the surface will be. So basically what we get is a white image with dark areas where geometry intersects with itself.

WHy using it ? The resulting occlusion pass gives very accurate and smooth shadows that resemble the result of global illumination. Compositing these shadows over your final render can significantly improve your image in many ways,it can mainly improve your shadows, give more depth to your scene and really helps to better show all the details of your models.

where can I make it ? in any major 3d package that has mental ray (or other rendering engines that support it) basically.

WHen to use it ? After you decide you are finished with your scene and have rendered your image.

zman
04-07-2006, 09:11 PM
There are two simple ways to get an occlusion pass.
Both ways will usually give a similar result, the AO shader method can often be faster and gives much more control but the shader is not included by default in the early versions of some packages. experiment with both so you could decide which works best for you.
Note that these steps are demonstrated with max but they are similar in every major 3d package that has mental ray.


Skylight method
1. Save your scene as a new file to avoid losing any data.
2. Set your renderer to mental ray.
3. Set the background color to white and the global light to 1.0 (software's default ).
4. Select all the objects and give them a standard material, set it's color to white.
5.In the rendering options, turn final gather on (more samples for higher quality).
6. delete all the lights in your scene and add a sky light, set it's color to white.
7. render.

tip - instead of using a white diffuse color, you can also use the AO shader in the diffuse color slot for more fine tuning.

Ambient occlusion shader method
1. Save your scene as a new file to avoid losing any data.
2. Set your renderer to mental ray.
3. Set the background color to white and the global light to zero (everything is black).
4. select all the objects and give them a standard material, set it's color to white.
5. place an ambient/occlusion map in the self-ilumination slot (more samples for higher quality).
6. delete all the lights in your scene (they are unnecessary for this)
7. render.

quick info on the shader parameters:
samples - depending on the quality you want and the time you have, 128 is usually enough to get and high quality result.
dark / bright - its usually best just to leave it as is.
spread - Higher values soften the shadows between the geometry by expanding them further.
max distance - when set on 0 it works like the skylight, any other value makes it calculate the occlusion "locally". this parameter determines the distance of the local calculation. this is a must for indoor scenes.


Optional tips for improvement
Bump maps - If you wanna go extra with the occlusion pass, you can include the bump mapping of your objects to emphasize it more. Just make a copy of the material and put back the bump map in it's slot for each object.

Adding / hiding geometry - sometimes you might wanna try adding some geometry outside the frame just so it would cast more shadows in desired areas. In other cases, some important areas get too shadowed because of certain geometry blocking too much of the light to it. It might help sometimes to exclude, hide or delete part of the geometry when making an occlusion pass.

Rendering more than one pass - this goes mainly for large scenes, you might wanna get different occlusion passes with different settings and different geometry (as mentioned above) so you could later on decide which pass works best with each local detail.



A few examples -

http://zivcg.com/images/occtut/occ_samples.jpg

zman
04-07-2006, 09:12 PM
(In this example I chose to start with a quick light setup for the first render which is quite flat and with very little contrast because I knew I'm going to go massive with the editing)
Take your render and your occlusion pass(es) to Photoshop and get to work.
The quick way to use the occlusion pass would be to slap it over the render, change the blending mode to overlay or multiply and adjust the layer's opacity to the point it doesn't get burned. But if you want to make the most of the details of your geometry, this can be taken one step further. the main idea behind it is to use it with as many different situations as you can think of (different occlusion settings, different blending modes, adjusting different colors and contrast and so on) and create masks to keep only the parts that improved on each layer. In this example I really took the occlusion usage to the extreme just for the demonstration (usually I don't get more than a couple of quick layers). One thing you should always keep in mind is not to over do it, applying the occlusion passes quickly raises the contrast level of your image so make sure you don't get stuff burned too much.

http://zivcg.com/images/occtut/final%20composittion.jpg

francescaluce
04-07-2006, 10:17 PM
Skylight method
1. Save your scene as a new file to avoid losing any data.
2. Set your renderer to mental ray.
3. Set the background color to white and the global light to 1.0 (software's default ).
4. Select all the objects and give them a standard material, set it's color to white.
5.In the rendering options, turn final gather on (more samples for higher quality).
6. delete all the lights in your scene and add a sky light, set it's color to white.
7. render.

tip - instead of using a white diffuse color, you can also use the AO shader in the diffuse color slot for more fine tuning.
take care that the most important thing here is to set the fg falloff in the same
manner you set the min and max distance clip. if not your render time will baffle this
tecnique. then you can use also finer fg settings without having to resort to another
occlusion pass to get details. then, I don't know what you intend by skylight but
you don't need it because if you set a low falloff to get correct occlusion any
skylight will never reach the objects. you should also mention that this tecnique
support transparent objects.



Ambient occlusion shader method
1. Save your scene as a new file to avoid losing any data.
2. Set your renderer to mental ray.
3. Set the background color to white and the global light to zero (everything is black).
4. select all the objects and give them a standard material, set it's color to white.
5. place an ambient/occlusion map in the self-ilumination slot (more samples for higher quality).
6. delete all the lights in your scene (they are unnecessary for this)
7. render.
man, just plug directly your occlusion shader to the material slot.
as in both the cases your not doing correct 'ambient' occlusion.
as the occlusion map should be plugged in the ambient slot of your
diffusive material. that's also why your rendered imgs are a bit too
dark and contrasted. and generally avoid to get most of the shadows
relying only on occlusion.

ciao
francesca

zman
04-07-2006, 10:30 PM
" ... without having to resort to another occlusion pass to get details ... "
You must have gotten me wrong, I WANT to get a separate pass for the occlusion because I think it gives extra control to show the details that way. Btw, I only talked about the skylight method because max6 and some other packages dont have the AO shader by default.

" ... just plug directly your occlusion shader to the material slot ... "
I didnt understant what you meant by that, are you talking about another way to get an occlusion PASS ? or a way to add oclusion to the render ?

francescaluce
04-07-2006, 10:44 PM
ehy zman. if you're using mentalray from v3.3 or 3.2 I don't
remember the 'skylight' method is a valid substitute for occ
passes. infact under certain condition mr will return really
occlusion instead of full finalgather. that most of the time
is even faster than standard occlusion. not only it supports
transparent objects and by using the fg map you can
drammatically speed up your occlusion passes. (if you're a
little used to .mi files and a like I can pass you a shader
that do both standard occlusion and advanced fg occ.
I would really love to see it in your hands to give it a try
with 3dsmax. so we could add some more bits to this occ
guide).

ciao
francesca

zman
04-07-2006, 10:52 PM
I didnt know there was an official valid way to get an occlusion pass.
I will gladly try it your way.
I'm using max7, can you explain to me step by step how to set it up in your way to get an occlusion pass ? I'm really curius to see the difference.

francescaluce
04-07-2006, 11:10 PM
max7 comes with mr3.3 or higher, right ?
you need this shader to get that occlusion pass.
if you use standard max materials.. you'll need also
a skylight but doing so you'll cannot ctrl finely the falloff.

http://img376.imageshack.us/img376/5940/ctrlocclusionm79sj.gif
the near and far clip as in a standard occlusion shaders ctrl the
distance until occlusion will be computed but tecnically it overrides
the fg falloff settings so that over the max distance no fg is
computed speeding up the whole thing and allowing finer details
as with a standard montecarlo occlusion probing.

http://img116.imageshack.us/img116/6499/ctrlocclusion0027si.jpg
you see that fg occlusion can work on transparent objects.
also once you computed the full occlusion on the first frame
in an animation you can set the fg settings to 'append' or
whatever is called in 3dsmax (append, freeze or recompute fg
map) so that the next frames have not to recompute the whole
occlusion.


I can send it to you if you know of someone that will port it on max environment.
it is currently available for softimage|xsi as maya (and mentalray standalone) comes
with its own set of occlusion shaders but technically they do together what ctrl.occlusion
does in a single shader.


ciao
francesca

HeinoEisner
04-08-2006, 02:27 PM
Uh nice trick francescaluce
can you post the mr shader here ?

TJKrumm
04-10-2006, 06:19 AM
Thanks a lot for the info.... much appreciated.

madhatfx
05-14-2006, 03:25 PM
Thanks a lot dude, good thing you done here very helpful mind explaining what use are photon maps and irradiance maps while rendering and how they work .

daddyo
05-19-2006, 05:28 PM
ummm... What did you use to get the occlusion on that sweet 2CV car? You did that in 1 pass? This kicks way more ace than what I'm used to doing, namely using the ao shader packaged with MR...

I'm a little lost. Is there a place I can go to learn to do this?

francescaluce
05-21-2006, 07:18 PM
What did you use to get the occlusion on that sweet 2CV car ?
maya::
http://forums.cgsociety.org/showthread.php?t=356606

xsi::
http://forums.cgsociety.org/showthread.php?t=358296

max::
http://forums.cgsociety.org/showthread.php?t=104578
(ask here and you'll find sure someone will port it on max)


ciao
francesca

CGTalk Moderation
05-21-2006, 07:18 PM
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.