Weight Maps Rendered as a Screen Space Texture?

Discussions about rendering in SOFTIMAGE©
Post Reply
AndrewHazelden
Posts: 12
Joined: 04 Mar 2014, 14:40
Location: West Dover, Nova Scotia, Canada
Contact:

Weight Maps Rendered as a Screen Space Texture?

Post by AndrewHazelden » 06 Mar 2014, 16:53

Hi. I'm working on a Softimage based angular fisheye rendering tool called the Domemaster3D shader.

I'm trying to develop a technique to apply a painted weight map as a screen space texture map. This would allow an artist to use the paint tools to sculpt a "camera separation map" that would render the Softimage scene with more or less stereo separation based upon an interactive weight map.

I have the first part working where I create a polygon grid shape and apply a weight map.

Part 1 - Create the Weight Map

Image

I then use the Map Paint > Paint tool to customize the data in the weight map.

Next I add a constant material to the grid surface.

In the Constant material properties window I apply a "Color Map Lookup" node to the constant material's color attribute.

In the "map_lookup_color" window I set the Map attribute popup menu to use the "Weight_Map (Weight Map)" as the source map.

When I render the scene at this point the Weight Map is applied correctly as a texture on the grid.

Image

Part 2 - Applying the texture in Screen Space

The weight map to screen space texture conversion part is the bit where I'm stuck. :-s

I'll go over the screen space conversion parts I've tried already. I've started by practicing the screen space conversion using three different approaches to map a 2D texture or a procedural to a camera using a lens shader.

* * *

The Camera_Projection Node Technique

The simplest way to convert a regular 2D texture to screen space is with the Camera_Projection node. I can apply a 2D file texture to the Camera_Projection.tex node input and the node's output is connected directly to a Camera's Lens Shaders "item" input.

Image

* * *

The Texture_Space_Generator Node Technique

I've tried using a Texture_Space_Generator to output screen space coordinates to 2D procedural textures like the Checkerboard node. This works fine on a regular procedural texture when I set the Space Transformation attribute set to "Screen" and map the Texture_Space_Generator.out data to the cherckerboard.coord input. Then I run this screen space data into a lens shader that renders the screen space texture map on the camera.

Image

* * *

The mib_texture_vector Node Technique

Finally, I've also tried using the classical mental ray node approach with a mib_texture_vector node hooked into a mib_texture_remap node, that feeds into a mib_texture_filter lookup node. With this setup I have the mib_texture_vector node set to use a select space aka. selspace value of 4 which generates screen space coordinates. Then I run this screen space data into a lens shader that renders the screen space texture map on the camera.

Image

What I can't seem to do is get the weight map converted into screen space with either of the three texture space conversion systems listed above. For that matter I also failed to get a gradient node to work in screen space coordinates either.

Sample Scene File

Would anyone have suggestions that could help me achieve this task?

In the attached Softimage .scn file there is a weight map, and two passes. I can't seem to figure out how to merge the two elements.

The Default_Pass shows the weight map applied as a constant shaded texture map on the grid surface. The Screen_Space_pass shows a camera named "lookup_background_camera" that has a noIcon_Pic texture applied in screen space coordinates using the Camera_Projection node.

Thanks for your time,
Andrew Hazelden
Attachments
weightmap_test.scn.zip
(108.96 KiB) Downloaded 78 times

AndrewHazelden
Posts: 12
Joined: 04 Mar 2014, 14:40
Location: West Dover, Nova Scotia, Canada
Contact:

Re: Weight Maps Rendered as a Screen Space Texture?

Post by AndrewHazelden » 18 May 2014, 14:46

Hi. I thought I would post a follow-up and share my solution to rendering weight maps in screen space using the "Create SSS Lightmap" tool along with a "Color_Sampler" node.

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

Image

Image


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)".

Image


Creating the Weight map 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.

Image

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.

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".

Image

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".

Image

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


Image

Image

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

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.

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.

Image

Image

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

Image

Image

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:
weightmap-to-filetexture.scn

weightmap-to-filetexture-screen-space.scn

User avatar
Hirazi Blue
Administrator
Posts: 5107
Joined: 04 Jun 2009, 12:15

Re: Weight Maps Rendered as a Screen Space Texture?

Post by Hirazi Blue » 18 May 2014, 16:52

That looks interesting indeed. Thanks!
Stay safe, sane & healthy!

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests