Saturday, January 3, 2009

Texture Baking - Export - Import

Texture Baking
Texture baking is neccessary to store the light and shadow information out of your light simulation in an image file, that can be used inside 3Dpdf as texture map. Therefore we have to bake the Complete Map (for Vray users I suggest Vray Complete Map ) into UV Map Channel 1, because other UV Map Channels than 1 are not supported by 3Dpdf. This means first, that we cannot store the light information separately from the Diffuse Color texture that could be tiled, and second, that we have to define a unique space in UV Space for each polygon on our model. To do so I discuss the following steps on a simple example. A plane with some extruded faces and a teapot attached to one object, as Editable Mesh or Editable poly with Checker Texture, light, shadows and Global Illumination .

Once the model with texturing and lightning is done, you have to assign an Unwrap UVW modifier to your object, and set its UV Map Channel to something else than 1. Beacause UV Map Channel 1 is used by default for Texture Maps such as Diffuse Maps etc., and it is not recommended to bake into the same UV Channel that is already used by texture maps on your object. So lets say you choose UV Map Channel 1 for your texture map(default), and UV Map Channel 3 for baking your textures, so there will be no confusion between the Texture Maps that are going to be baked and the Baked Maps, which are the final image results that we are going to export to 3Dpdf. Inside the Unwrap UVW modifier dialog click on edit, and a new window opens, where you can modify the UV coordinates of your object. Use the selection mode Face and ctrl+A to select all faces.

Now go to Mapping then Flatten Mapping and change the Spacing value to 0.002, and accept with ok. The result should look something like this:

What the Flatten Mapping procedure did, was arranging the Faces without overlapping (hopefully) with the Spacing we defined. A Spacing value of 0.002 is fine in most cases, but if you have lots of triangles you may have to increase that value, to prevent overlapping. Back in the Unwrap UVW dialog save your UV's so you can later load them into UV Map Channel 1. Select the object you want to bake and open the Render To Texture dialog (shortcut: 0), and check the following settings, so the renderer renders the color information into the polygons according their positions :

Under Output click on Add, and select Complete Map (Vray Complete in my case), and set the resolution to 1024x1024.

Click on render, and save your image which is the Baked Texture for example as .jpg

Now create a new Standard Material in the Material Editor and and assign the Baked Map to the Diffuse Map slot, set the Self Illumination to 100%, and assign the new material to your object. Finally change the UV Map Channel inside the Unwrap UVW modifier back to 1 (in older max versions you have to load the stored UV channel 3, which we saved previously, now). You may check if your Baked Map appears correctly in your viewport by pressing the "Checker Box Button" in the material editor.


Export
To export your object use the .rh export module by Right Hemisphere, and export it as .rh file including the Texture Maps.


Import
To import the object to Acrobat 3D, I use V 8.12 for reasons I will discuss later, go to "create from file", and choose the .rh file to import. Now you can play around with the settings to define the appearance pleasing your desires.

Click here to view the result

The bandwidth is kindly offered by: active-servers

3 comments:

  1. Hi Chuck,
    Great tut, It has work great here
    But I got a problem, I'm trying to switch the texture map with a javascript button on the 3d pdf..and the texture (the 3ds UV maping) doesn't show properly.
    I've try the javascript property "use3DSStyleMapping" but I can't figure how it work...
    any clue about this will be very welcome ?
    thanks in advance
    Al

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hi Al,
    Some export formats can cause trouble with uv's, make sure sure to use .rh or .ase (if Acrobat 9 user use the following procedure:http://3dpdf.blogspot.com/2009/01/acrobat-9.html).
    I guess the 3DSMappingStyle determines how the uScale and VScale property is handeled, but I really don't know. I ran a little test here but uScale,vScale and 3DSStyleMapping doesn't seem to have any effect on the scene (like reflectionStrength property and modulate property I might add).

    For changing the texture by script follow the guide by Grayson Lang using diffuseTexture instead of bumpTexture: http://www.graysonlang.com/acrobat3d/attach3dresource/
    I don't think you can access texture resources which are imported with the 3d model, so this seems to be the only way. And keep in mind that those Textures can't be compressed by 3D Toolkit or Deep Exploration, as those resources are included to pdf document, but not to the u3d file inside the pdf.

    Best regards, Chuck

    ReplyDelete