This tutorial will show you how you can…
Due to the considerable improvement and upgrades on the Flash Platform, now we have the enough power and tools to create advanced experiences, using diverse new technologies like Stage3D.
In this example I’m going to create a simple application for iPhone 4S, optimized to get a solid performance using classic techniques like Texture Baking and Low-Poly Modelling. Also, I will show you a few tips/tricks to get useful camera information using Prefab2, and later tween the camera between fixed positions using TweenMax. I will use Away3D 4.1 beta but this tutorial works fine with Away3D 4.0 too.
Preparing Maya to export OBJ files
The example model was created in Maya 2013, then I used Mental Ray to get Baked Textures for each element in the scene, and finally I exported the model to an OBJ file.
By default, the OBJ Exporter Plug-in is disabled, so we need to enable it in: Window > Settings/Preferences > Plug-in Manager.
Then search for “objExport.bundle” and check both boxes (Loaded / Auto load). Now we are ready to export OBJ files to use later in Prefab2.
About Texture Baking
In simple terms, the GPU of any iDevice (iPhone 3GS+) have the enough power to move complex 3d environments, but realtime lighting is very expensive, and depending of the device the performance may be poor. If we are planning to make an application that traverse from the 3GS generation to the newest iDevices, Texture Baking is your friend to achieve a balanced performance.
Like says RenderMan [Link to RenderMan] from Pixar, Texture baking is the process of taking information from the scene, such as color or lighting, and baking it into an object’s UV space. With baked textures, we can reuse expensive calculations by looking up a texture, avoiding the need to recompute the lighting and surface shading.
Depending of the scenario, some engines uses a combination of Baking for the Lighting and Realtime Shadows to resolve Dynamic objects in the scene like the main Actor of the Game.
In this tutorial, specifically in the example 3D model, we got this Baked Texture:
[Final Model Texture!]
Preparing Maya for Texture Baking with Mental Ray
When you have done your 3D Scene (or use the example scene from the sources), we can export a single baked texture for the entire model (useful in simple scenarios, when the quality of any specific object doesn’t matter), but in this case we will export a Texture for each object, to conserve the quality control on every element.
Before the Texture Baking we need to assure that every object in the scene have a correct UV-Mapping. In my case, I’m just using “Automatic UV Mapping” in each object under: Create UVs > Automatic Mapping, in the “Polygons” menu Toolset.
Then select all the objects to be baked, select the “Rendering” Toolset and go to: Lighting/Shading > Batch Bake (mental ray). Here we have a few options but we will config like the image below:
If you want to know more about each option available here, check this official description guide from Autodesk. Then press “Convert” and depending of the complexity of your scene, this process will take a few minutes.
Using the model in Prefab2
Prefab3D is an Application that helps you to convert and streamline your assets. In this case we will use Prefab2 to export an AWD file to use later with Away3D. AWD is a binary file format for 3D scenes, objects and related data. Is designed to be light-weight, fast and easy to parse. We just need to import our previously exported OBJ file from: File > Import 3D File. If it loads correctly we are ready to use it with Away3D.