
This site is hosted with IXWebhosting:
:: Post Date: 2007-08-05 21:00:18 [Post Comment] [Post Articles]
|
Baking Ambient Occlusion Using Mental Ray in MayaApplication Used: Autodesk MayaAuthor: Bogdan AmidzicContact:santobranko@yahoo.co.ukAuthor Website:http://www.cavz.com/IntroductionAmbient occlusion can be very useful for adding details to shadows of your images. But also it can be extremely expensive to calculate for every frame of your animation. If you have scene that is very static (camera flying trough environment), you can render ambient occlusion to texture and assign that texture to the ambient attribute of your shaders. That way, the scene will render very fast. Before entering this tutorial I recommend you to read my tutorial for making lava shader, to get basic knowledge about hypershade and texturing in Maya. ![]() In our example I modeled a simple terrain using a poly plane and one bridge going across. I also added one directional light (sunlight). ![]() For texturing I used Photoshop. Here's one very useful tip if you are going to use Photoshop for texturing. Assign lambert to plane (ground plane) and go to hypershade. Select the plane and lambert shader you just assigned it to. Then in hypershade menu go to edit/convert to file texture (Maya software). Set bake shading group lighting. This will bake illumination to texture. Also a surface shader is created and assigned to the object. Delete that surface shader, and assign the lambert to the plane. The baked texture is located within the sourceimages subfolder of your project. ![]() That baked texture should look like this ![]() Then I used it in Photoshop, as reference. When I was done with the texture for the plane - it looked like this. ![]() Assign that texture to the shader of the ground surface. ![]() I also textured the bridge. There I used some UV mapping tools such as Cylindrical mapping and Planar mapping. ![]() Sunlight is cranked up a bit (1.5), with 2k resolution depth map shadows and filter size of 2. ![]() Now, to start preparation for Ambient Occlusion. First we need to create one UV set for all objects that will use Ambient Occlusion. So all objects in the scene will use a single AO texture. To generate that UV set, we will use automatic mapping. Select geometry and go to create UVs /automatic mapping option box (Maya 8 menus). Set planes to 6, and spacing to 1024. Also enable create new UV set, and set name to BakeSet. This will generate new UVs in the new UV set. By default all textures use default UV set (map1). ![]() If you look at the UVs you will get something like this. If you want you can keep UVs for the ground plane, and just copy them from map1 set to BakeSet. Notice that the UVs overlap. This is bad. ![]() To fix this, select all UVs and go to layout UVs set non overlapping. This will arrange all UVs in 0 to 1 UV space. ![]() ![]() Notice that those UVs stand in new UV set called BakeSet. We'll use that set for the AO texture. ![]() For baking we'll use mental ray, so make sure that MR is loaded. You can do that in window/settings preferences/plug-in manger. Scroll down to Mayatomr.mll, enable it if disabled. ![]() Now if you hold right mouse button on any geometry in scene, in the bottom of the menu you can see the baking submenu. In that menu choose assign new bake set / texture. This will create a set of parameters for baking that relates to that object. Name the set AmbOCC, and set mode to Occlusion. Set rays to 64 or more, I used 256 and baking took hours. The higher this number, the smaller amount of noise you'll get, and greater the render time. Set resolution to 1k - 2k. These maps should be very big, since they will be applied to all objects. Baking to one map means that all objects will use same map. In the bottom enable override mesh UV assignments, and enter BakeSet for UV set name. The AO will be rendered to a 2k image using BakeSet UVs . ![]() Assign that set to all geometry in the scene. You can use multiple sets, to optimize calculation for different parts of your scene. I used only one set. Select all geometry. Then go to rendering menu set and go to lighting/shading / batch bake (Mental Ray) options box. Skip objects in initialBakeSet means that objects that are not in any bake set you created will not be rendered. If you uncheck keep original shading network, surface shader will be assigned to the objects. You don't want that. So hit convert and close. This may take hours, so be patient. The AO map is rendered in the renderData/MentalRay/Lightmap subfolder of your project folder. ![]() The map should look like this. ![]() Then create file node and connect it to the ambient color of the materials. ![]() If you hit render now, you will get something like this. AO texture is using the wrong UV set. It's using map1 (default UV set) instead of BakeSet. This is normal, since every texture uses this set unless you specify differently. ![]() Select the ground surface and go to window/relationship editors/UV linking/Texture-Centric ![]() On the left side is your Material and on the right is the surface. You can notice that file4 (AO texture) is linked to map1. Just click to BakeSet, and the texture will use this set for that surface. ![]() Repeat this step for Bridge. ![]() In hypershade you can see the new node called uvChooser1. Picture below shows the network for one concrete material for the bridge. ![]() And second concrete. ![]() If you hit render, you can see that the Ambient occlusion works. ![]() I also multiplied AO texture with sky blue ramp to get tint. ![]() ![]() ![]() Alas, the shading network for all materials share one single MultiplyDivide node ![]() Now the image looks a little better. ![]() * mental ray ambient occlusion is very slow even on simple scenes like this. You can use the power of your GPU to calculate AO. There's a program called Faogen that uses GPU to render AO. To use it create a copy of your scene, and copy UVs from BakeSet to map1 set, and export the scene to OBJ. ![]() |
| gooooooooooooood!!!!!!!!!!!!!!!! |
| woot woot |
| super texturing iam very much interested in maya i would like to study maya lighting and rendering biju 3dvisualizer+civilengineer ksbiju2006@gmail.com |
| woow boos |
| great! |