TUTORIALS ... This tutorial will introduce you to the Render To Texture technique
and will also try to give you ..... an advanced material (MentalRay's,VRay's, …).
AR-media™
TUTORIALS “IMPROVING REALISM – THE BASICS” (June, 2011)
Inglobe Technologies © 2008/2011
AR-media™ Tutorials
Copyright
Copyright © 2008/2011 Inglobe Technologies S.r.l. All rights reserved. No part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval system, or translated into any language or computer language, in any form or by any means, electronic, mechanical, magnetic, optical, chemical, manual or otherwise, without the prior written permission of Inglobe Technologies S.r.l.
Inglobe Technologies © 2008/2011
AR-media™ Tutorials
TUTORIAL - “IMPROVING REALISM – THE BASICS” INTRODUCTION When you want to communicate your ideas, being them either architectural or design elements, visual appearance is one of the most important things to take care of. Content creation programs usually provide several tools and assets to help you increase the realism of your models (photorealistic materials and shaders, advanced rendering engines and lighting models) but usually you get great results only at the expense of speed, in other words such great tools work fine but they are not suitable for real-time rendering. In order to get interactive frame-rates (at least 30 fps) and still preserving a good visual appearance you can use some techniques commonly used by artists and professionals that develop content for real-time applications (like modern 3D videogames for example). This tutorial will introduce you to the Render To Texture technique and will also try to give you some ideas and suggestions that will help you to preserve the realism that you get thanks to your preferred rendering engine and ultimately to get the best from the plugin.
GENERAL CONCEPTS The Problem The first important thing to be aware of is that the plugin basically supports the Standard material type (and some others types derived from it) the second important thing to know is that the plugin does not support advanced materials such as mental ray®, V-Ray® and others1. This usually means that if you setup a scene for photorealistic rendering and you try to view your scene by means of the plugin, you’ll probably get just flat colors with no textures and, in the worst case, a totally black scene. But fortunately, almost any 3D software offers tools that help you to overcome this problem, one of the most powerful and used in the game industry is Render To Texture. The Solution Render To Texture basically allows you to store the result of a rendering in one or more textures, this means that you can setup your scene for photorealistic rendering, add Global Illumination and every other time consuming effect, then use the Render To Texture tool and finally use the textures that are created by the tool instead of your photorealistic shaders/materials. By doing this you won’t need to perform computationally expensive renderings of your scene anymore, because all information is stored once and forever in textures (anyway, you may need to do Render To Texture again if you update your scene by modifying some geometries or by moving some lights). Having all of the photorealistic effects stored in simple textures, has a great benefit: you can use them with Standard materials. By doing so you’ll be able to bring your great photorealistic effects straight to the plugin. Usually the Render To Texture (RTT) procedure is also known as texture baking and, when we apply the technique to specific effects such as Ambient Occlusion or Global Illumination we may use terms like faking Ambient Occlusion or faking Global Illumination respectively.
1
mental ray® and V-Ray® are trademarks of their respective owners. Inglobe Technologies © 2008/2011
AR-media™ Tutorials
RENDER TO TEXTURE Overview Simply put, what Render To Texture really does is one or more renderings of selected objects in the scene (at a specific time) and store the result(s) into one or more textures Basically the process to get photorealistic effects into the plugin, involves the following steps: -
choose your preferred rendering engine setup your scene with your photorealistic materials and shaders do Render To Texture on every object that requires it
Note that it is not mandatory to do Render To Texture for every single object in your scenes, this choice depends on the importance of the object in the scene and/or if it uses advanced materials or lighting effects. Techniques & Strategies When performing Render To Texture, at least two strategies can be applied: 1. fake the overall appearance of your material/shader 2. selectively fake only some of the available visual components from now on, we will refer to these strategies as the first and second strategy respectively. When you choose the first strategy the overall appearance (i.e. diffuse, lighting, reflections, …) of the selected object is rendered into a single texture that is put in just one slot (usually the diffuse slot) of a newly created material, whereas if you go for the second strategy then one or more textures will store different information and the newly created material will use different slots depending on what you choose to fake (for example you may choose to just fake lighting and this information will be usually put in the selfillumination slot). In order to choose which strategy better suits your needs, you must consider that each texture created by means of Render To Texture will occupy memory and that the bigger it is, the more memory it will use. That said, you must also consider that complex geometry, in order to maintain a visually acceptable detail, must often use big textures and ,on the other hand, that different kinds of visual components (diffuse, lighting, …) demand different textures sizes to effectively conceive their information (for example a texture used for a diffuse slot should have lot of detail and so it should be big enough, whereas a texture used just for lighting information or ambient occlusion could be quite small compared to a diffuse texture). Another factor to consider when choosing a Render To Texture strategy is related to the need to later modify a slot individually: if you fake the overall appearance into just one single texture then, for example, you won’t be able to modify individually the diffuse component while maintaining the lighting information as is, on the other hand, if you decide to fake individually the diffuse and lighting information then you may later modify one without affecting the other, this is one of the main advantages of the second strategy over the first. Another major advantage of the second strategy is that each texture can be of different size (for example you can use a big size for the diffuse texture and a small size for the lighting one). Limitations Before going on with some practical examples, we must warn about some limitations of the Render To Texture technique.
Inglobe Technologies © 2008/2011
AR-media™ Tutorials Dynamic Scenes: first of all, it can be used for practically static scenes, since Render To Texture take a snapshot of the visual appearance of your scene you must carefully choose ‘when’ to apply it. For example if you have a scene where at the beginning of the timeline some objects are not lit, while later on they are well lit, you may consider to move the current frame to the point when those objects have their best appearance and do a Render To Texture at that frame. You may also choose to temporary hide some other objects that are obstacles for others, if this helps you to improve the appearance of objects you’re doing Render To Texture with. This means that you must carefully decide how and when to apply the technique in order to get a good result Reflections: usually is not a good idea to also fake reflections (either individually or as part of a complete map) because they usually depends on the user’s point of view that, especially in augmented reality applications, changes continuously. if you choose to fake reflections then they probably will look as static textures and lose their real meaning (on the other hand in some cases it is still useful to fake reflections as part of the overall appearance approach). If your model has reflections maps, just follow the second strategy and keep the original reflection map instead of baking it with Render To Texture, also carefully set the amount value that let you choose how much reflection should be visible on the final material. The Procedure Step 1: in order to use the Render To Texture command, select Render To Texture menu item from the Rendering menu and the following window will show up
Inglobe Technologies © 2008/2011
AR-media™ Tutorials
In the General Settings rollout, pay attention to the Output section and in particular to the Path input box: this specifies where the newly created textures will be stored, be sure to select a directory related to the project you’re working on, for example click the … button, navigate to the project’s folder and create a new directory called ‘baked’. Please note that 3ds Max will not change this directory if you do not explicitly change it, this means that if you change project and do not set this option properly then you may overwrite textures related to other projects, so be sure to always set it before starting a Render To Texture command. Step 2: select the object you’d like to bake textures for, the object name will be displayed into the Object To Bake table. You can also add more than one object at the same time if you’re going to use the same strategy and settings for multiple objects, just select your objects in the viewport and they will be automatically added to the list. Step 3: scroll down to the Mapping Coordinates section, just leave settings to their default as shown in the next figure
Inglobe Technologies © 2008/2011
AR-media™ Tutorials
Render to Texture will add an Automatic Flatten UVs modifier to use the new texture with, by default it will use mapping channel 3. Later on you’ll see that in some cases it could be better to manually flatten UVs in order to get better results or to avoid visual artifacts, in those cases you won’t set the Use Automatic Unwrap option but will choose Use Existing Channel instead, for now you can just keep defaults. Step 4: keep scrolling down to the Output rollout
Inglobe Technologies © 2008/2011
AR-media™ Tutorials
The Output rollout is where you choose the Render To Texture strategy as well as the size of each texture that will be created, the basic idea is that you first add an element to bake and for each element you choose a target, i.e. a slot that will contain the rendered texture. IMPORTANT: the list of available target slots depends on the kind of material that will be used to host the result of the Render To Texture command and this depends on the option that you set in the Baked Material rollout (just below the Output rollout). In general whatever kind of material your objects use, you should go to the Baked Material rollout, select the Save Source (Create Shell) option, then: a) if your original material is a Standard material you can select the Duplicate Source to Baked option (by doing so, every settings of the original material will be copied to the material created by the Render To Texture command)
Inglobe Technologies © 2008/2011
AR-media™ Tutorials
b) If the original material is not a Standard material2 (for example if it is a mental ray® or V-Ray® material) then select the Create New Baked option and leave the default Standard:Blinn (or Standard:Phong) entry as shown here
this is necessary because we need a Standard material in order to use the results with the plugin. NOTE: the result of the Render To Texture command will create a Shell Material whose first material will be the original material of your object and the second material will be the baked material, i.e. the material that will contain the textures that are faking the original material’s appearance. Pay attention not to choose the Output Into Source option otherwise your original material will be overwritten by the result of Render To Texture.
2
If you are getting black looking objects it could be the case that you are experiencing a known issue of the Render To Texture command when used with an advanced rendering engine, please refer to the troubleshooting section later in this guide. Inglobe Technologies © 2008/2011
AR-media™ Tutorials NOTE: in some cases (discussed later on) you may decide to just store the Render To Texture results to disk instead of creating a new Shell Material and then manually manage those result, in those cases you’ll check the Render to Files Only option. Step 5: now we’re ready to choose what effect we want to fake and what strategy to apply, so scroll up again to the Output rollout and click the Add button, a window with the list of elements will show up
The names of each element tell us what effect we’ll be able to store in a texture if we select it (remember that the actual list of elements depends on material type of the currently selected object and may be different from the one shown above). One special attention deserves the CompleteMap element: if you choose this element then the texture will contain every visual effect, in other words you’ll be following the first strategy described earlier, on the other hand if you choose any other element then you’ll be following the second strategy. Once you have chosen the desired elements, click the Add Elements button, they will be added into the Output table and some other information will be filled in automatically in the Selected Element Common Settings. An example of these settings is shown below:
Inglobe Technologies © 2008/2011
AR-media™ Tutorials
in the example, the LightingMap element is selected, pay attention to the File Name and Type input box: you can leave the default name that 3ds Max will give to the texture but be sure to select either the JPG or PNG file format by clicking the … button just beside the File Name and Type input box. Step 6: what you need to choose next is the Target Map Slot: this will determine how the baked texture will be used with the new Standard material that will be created. Just click the dropdown list and select the slot you’d like to use for the current element. NOTE: if more than one element is selected in the output table then you won’t be able to choose a target slot, you must select only one element. IMPORTANT: the available slots depend on the type of material that will e created, for this reason it is important that you’ve previously selected to create a new Standard:Blinn type if the original material was an advanced material (MentalRay’s,VRay’s, …). In the above example we set the Self-Illumination because we wanted to fake the LightingMap, you’ll see an example later on. Finally choose the texture size that you think will be suitable for your object. Finally: repeat the above steps for every object you’d like to bake materials for (or eventually select multiple objects at the same time and do the above steps just once if they are treated in the same way) and finally start the Render To Texture process by clicking the Render button at the bottom of the window. The Inglobe Technologies © 2008/2011
AR-media™ Tutorials process will start (it may be a long process if you selected lots of objects or if your rendering engine’s settings are quite demanding, but it has to be done only once) and 3ds Max will show you each texture that will be created. At the end of the process each object you applied Render To Texture to will have a new Shell material as described earlier. Hints & Suggestions Textures sizes: before deciding how big your textures should be, consider the importance of each individual object in the scene and also how big it will be when viewed in augmented reality: usually small objects can require just one texture for the diffuse slot as big as 64x64 pixels or even smaller than this. Undoing Render To Texture: If you need to remove the effect of the Render To Texture command for some objects, open the Render To Texture window, select them and in the Render To Texture window click the Clear Shell Materials button in the Baked Material rollout (be sure that the Keep Source Materials is selected). This will just restore the original materials for the selected objects, if you want to also remove the Automatic Flatten UVs modifier that was added by the Render To Texture command, then move to the Objects to Bake rollout and in the Mapping Coordinates section click the Clear Unwrappers button. By doing both the above actions your objects will be restored to their original state prior to Render To Texture. Troubleshooting mental ray® and Render To Texture: when 3ds Max stores to disk each texture created by the Render To Texture command and mental ray®engine, they are written as black & white images even though the preview will show you the correct grey-scale or color image. This means that if you try to see those textures with the plugin (or in any other software) you’ll see nothing but black objects, in order to avoid this problem you must manually save those textures to disk by clicking the little disk icon in the left top corner of the Render To Texture output window (this means also that you cannot issue one Render To Texture command for more than one object per time otherwise you won’t be able to manually store the result but for the last object). You may experience this problem even with other rendering engine but this won’t happen if the rendering engine is the default scan line renderer.
CONCLUSION The goal of this tutorial was to introduce you to Render To Texture’s concepts and to its usage in the context of the plugin. Later tutorials will teach you how to leverage on this technique in order to add photorealistic effects (Ambient Occlusion and Global Illumination to mention some) to your augmented reality scenes.
Inglobe Technologies © 2008/2011