Skip to content

Softimage Domemaster3D Screen Space Weightmaps

Andrew Hazelden edited this page Nov 26, 2016 · 4 revisions

Introduction

XSI Weightmap

A Domemaster3D for Softimage user asked about the possibility of using paintable weight maps to control the Domemaster3D shader's screen space texture maps. This wiki page explains the technique to write weightmap data to a file texture node and then render it as a screen space texture.

This technique is interesting because it allows an artist to use the weightmap paint tools to do things like sculpting a "camera separation map" that would render the Softimage scene with more or less stereo separation based upon an interactive weight map.

This wiki article could be useful to anyone who wants to save Softimage weightmap data to a file texture.

How is the Weightmap Data Converted?

Here are two images that show the essential steps for converting weightmap data into a screen space texture map.

Weightmap to File Texture

Rendering in Screen Space

Initial Scene Setup

Start by opening the existing weightmap_test.scn file that has a weight map applied to a polygon plane.

The current render tree has the following nodes:

Map_lookup_color.out > Constant.Color > Material.Surface

The Map_lookup_color node has the Map property set to "Weight_Map (Weight Map)".

Color Sampler Node

Creating the Weightmap Writer Shading Network

We can use a Color Sampler node to write the current weight map to an EXR file. This will allow us save the weight map to disk, and then use it as a screen space file texture.

Select the Lightmap category in the Render Tree and drag a "Color Sampler" node to the work area. Wire the Constant.out connection to the .input attribute on the Color Sampler node.

Then double click on the Color Sampler and click the "New" button and select the "Unique UVs (polymesh)" option so the Color Sampler will read the weight map value from the polygon mesh in the scene. This will write the text "Texture_Projection (Explicit UVWs)" into the map field.

Set Color Sampler to Unique UVs

Let's add a new image clip to the Render Tree. From the "User Tools" menu in the Render Tree window select "Create SSS Lightmap".

Usertools Create SSS Lightmap

This will create a new file texture clip in the Render tree that has the File Output: Enabled checkbox turned on. This is VERY important if you want the flile texture to be saved to disk. If you tried to create the clip manually without using the Create SSS Lightmap menu item you would get a frustrating mental ray render time error "ERROR : RCLM 0.4 16 MB error 131021: attempting to edit a non-writable image".

Open the properties for the "sss_lightmap_clip" and change the file output format from "mental ray MAP (.map)" to "OpenEXR (.exr)".

Change the image output name from ".\Render_Pictures\.sss_lightmap_[Host].#.exr" to ".\Render_Pictures\weightmap_separation_[Host].#.exr".

SSS Lightmap Properties

This will create a weight map with the name of the Host system and the current frame number. If the system had the host name "HP" the output image for frame 1 would be: "weightmap_separation_HP.1.exr".

If you want to use a single weight map image for the output you could use the file naming option ".\Render_Pictures\weightmap_separation_[Host].exr" without the # based frame extension symbol.

Set the Resolution width to 1024 pixels and the height to 1024 pixels.

In the Render Tree work area, connect the output from the "sss_lightmap_clip" file texture to the Color Sampler node's .texture input.

sss_lightmap_clip > Color_Sampler.texture

Finally, we will wire the Color_Sampler.out attribute to the Material node's Lightmap input. This will mean the weight map texture writing will be activated each time the scene is rendered.

Color_Sampler.out > Material.Lightmap

Color Sampler to Lightmap Connection

Weightmap to EXR Texture Shading Network

Now we will test the weight map writing technique by switching the Render pass to "Default_Pass".

Preview Render

Click the Preview button.

If you open the XSI scenes folder and look in the "Render_Pictures" folder you should see a new EXR image.

Weightmap Saved to Disk

The final thing to change is to Normalize the UV texture map space on the Grid plane. Currently the grid's UV space uses only 75% of the 0-1 texture range.

Select the grid mesh in the explorer, and open the Texture Editor window. In the UVs menu, select the Grid Texture Projection item.

Drag a box selection around the grid's UVs in the Texture Editor window. They will all turn a RED color. Now click on the yellow "plane" icon (the Planar Subprojection tool) in the toolbar and select "Best Fit" in the popup menu. This will improve the quality of the output texture map by using all of the available space.

Normalize Plygon Grid Texture Space

Fit to Texture Map UVs

Now when we hit the preview button again the weight map looks great and is rendered to an EXR file texture.

Render Default Pass

If you opened the saved EXR file texture in a program like Photoshop you would see the painted weightmap data. This looks nice.

Note: If you don't see all of the weightmap data you were expecting, you have to keep in mind this whole process only exports the weightmap information that fits in the 0-1 UV space of your UV Layout.

Rendered Weightmap

At this stage we could use the newly output "weightmap_separation_[Host].exr" file texture as a screen space texture map with the help of a Camera_Projection node.

Softimage Example Files

Here are two sample files that use this weight map to texture writing technique:

Applying Screen Space Weightmaps to a Fulldome Mesh

Fulldome Weightmap

Now that we know how to apply a weightmap to a screen space texture, we can apply this to the Domemaster3D system by using a dome shaped mesh with a circular domemaster formatted UV layout.

To get started with this technique, the DomeViewer tool's fulldome mesh model "fulldome_mesh.obj" can be used as the weightmap surface. You can find this mesh in the Domemaster3D Addon's Bitmaps folder:

C:\Users\<User Account>\Autodesk\Softimage_2014_SP2\Addons\domemaster3D\Application\bitmaps\fulldome_mesh.obj

I've create a proof of concept Softimage python script named "domeLoader v12.py" that automates the creation of the fulldome weightmap. The sample script can be downloaded here:

http://www.andrewhazelden.com/projects/domemaster3D/archive/xsi-dome-weight-map.rar

Note: This sample script is designed to be run once and doesn't check for material and object name collisions.

How the domeLoader v12.py Script Works

The python script starts by creating a new scene and then adds a robLookupCamera to the scene. This camera view has its own render pass that lets us render and look at a screen space view of the resulting weight map file.

The script imports a dome shaped "fulldome_mesh.obj" file from the Domemaster3D Addons bitmap folder, names the mesh "domeWeightMesh" and parents it to the robLookupCamera. This mesh has a domemaster based UV layout.

The mesh is subdivided to increase the detail a bit and then a weight map is applied.

A weight map to color_sampler shading network is created and the resulting texture map is saved to the image file ".\Render_Pictures\weightmap_separation_[Host].#.exr". To keep things interactive the image resolution starts at a default value of 256x256px.

Then the "color_sampler" image clip is linked to the screen space texture shading network on the robLookupCamera. This texture connection would be the same thing that would be used to drive the turn and separation maps on the "domeAFL_FOV_Stereo" camera rig.

Clone this wiki locally