4/25/2008

Ambient Occlusion without compositing

i don't know if someone could be interested. maybe this could be useful for the newbies in ambient occlusion or for quick render test in mental ray without final gather support.
i made this material some months ago in vray during the model of the castle. when i made render tests i didn't want to composite ambient occlusion for every frame, i just wanted a detail enhancement directly in the render test without made an ambient occlusion pass and composite all in photoshop. i made that with the vraydirt shader. in mental ray i thought that it's the same, but applying an ambient occlusion shader, faster then the vraydirt. i don't use the arch&design material that has a built in ambient occlusion option; i don't have the full control as a traditional ambient occlusion pass. this trick is also useful for quick render test without using any final gather or global illumination support, just 3 light setup; it's just fake global illumination, not rocket science.

here is the scene set


and a simple shaded and wire view of the model for the test

a render with a standard material with grey color in diffuse

for this test i assigned the same material both to the model and the ground

the mental ray ambient occlusion pass. make the tune of the ambient occlusion as usual


generally i have to composite the last 2 renders together in photoshop in multiply blend mode, but if i want blend it directly in max frame buffer without photoshop i just make a material blend with 2 materials , the grey mat and a standard black mat, and using the ambient occlusion as the blend mask.

the 2 materials used for the previous renders


the contruction of the blend material. i used the previous grey material and i added a black material to simulate occluded parts of the model and the ambient occlusion shader as the blend mask that tells where is the occluded part (black meterial) and the unoccluded part (grey material).


put the 2 materials and the mask and make a render test. if something going wrong like this

just swap the gray and black material.

here is the final render with the material correctly applied.


i can adjust the intensity of the ambient occlusion changing the upper and lower values in the mixing curve of the blend material. for the final render i use 1 for the upper value and 0 for the lower. 0 on both values is like the simple grey material without the support of the ambient occlusion, vice versa, 1 in both values will make the whole image black.

this trick avoid the use of the final gather for the global illumination, this just fake it. this is useful to avoid the photoshop composite pass.
it could be also done with a mix map in the diffuse channel of the material; there's a lot of ways to achieve the same results.
this is not like to put a simple color, or texture, in the unoccluded map slot of the ambient occlusion shader beacause that will not consider the lights influences like direct illumination and shadows. you can make a reflective, textured material as usual and at the same time give ambient occlusion on refractive and reflective surfaces.
sometimes i find it useful and quick during modeling or materials setup, but for final renders i always separate the beauty render and the ambient occlusion pass and i composite it in photoshop.

here are a quick reflective material test.
without ambient occlusion support (mixing curve: upper and lower values both set on 0)


with the ambient occlusion support (mixing curve: upper value sets on 1 and lower value sets on 0)

No comments: