Multi Displacement Setup

Multi displacement method can be very handy when setting up various displacement files for your geometry. It will enable you a higher detailed displacement for your render.

Maya
When preparing geometry for export to mudbox, it would be wise to layout the UVs on the positive direction of the U.
Note: when moving a UV shell, make sure it will move to the right spot.
Use this Mel Script: polyEditUV -u 1 -v 0 ;
Where the “1” is the value of the unit the shell is moving to

uv-layout.jpg

This is done to allow better naming convention for the displacement maps.
Mudbox will look at the lowest UV shell on the left side and generate the first displacement map.
For example: “xxx001.tiff”
I will then move to the second shell on the right and so on

Note: If you have placed UV shells on the V direction as well, Mudbox will go through the lowest UV lineup first, then move up and start again from the left.

uv-layoutv.jpg

Mudbox
When extracting the displacement (or normal maps) out of Mudbox, make sure the “Process Multiple Tiles” option is turned ON.
“URange” option means: where the distance of the first UV shell is located. Remember the tiles are in a UV 0-1.
Note: The parameter is named “URange,” hence the reason we have laid out the UVs on the U direction.

mudbox_baker.jpg

Once the operation is completed, you will end up with a number of displacement maps named according to the UV layout.
For example: sphereDisp0001.tif, sphereDisp0002.tif, sphereDisp0003.tif, sphereDisp0004.tif, sphereDisp0005.tif, sphereDisp0006.tif

Maya
Create “x” file nodes (where x is the number of displacement files.)
If you have done everything correctly, you should end up with displacement maps that reflect their associated UV shell.

In the “place2dTexture” Nodes, adjust the following;
Un-check “Wrap U” and “Wrap V”. This will prevent the texture from repeating itself in other tiles.

“Translate Frame” parameter will reflect where this texture node will be located on the UV layout.
File 1: Should be left as is.
File 2: Should be translated ONE unit on the U direction.
File 3: Should be translated TWO units on the U direction, and so on.

place2dtexture.jpg

To combine all of these nodes into one, we will use a “PlusMinusAverage” node.
Connect the “out.Color” of each file to the “plusMinusAverage.input3D”

Note: The default color for the displacement files are set to gray.
Since we have disabled the texture wrap, the empty areas will be filled with this default color. This means unnecessary color information.
To fix this, change the “Default Color” to black for each file node.

While we are on the file node topic, flip the “Filter Type” to OFF.
The ultimate goal is to use Mental Ray. However, Mental Ray has a pre-built filter in the render settings.
This way we don’t have a double filter on our file texture.

filenode.jpg

Since the outcome value of the “plusMinusAverage” node is RGB, luminance is required for the displacement value.
We need to connect the “plusMinusAverage.output3D” to “luminance.value”.
Then, connect the “luminance.outValue” to the “displacementShader.displacment”.
Finally, connect the displacement node to the SG node of your shader.

multi_connection.jpg

Adjust the mental ray approximation node to your liking. Now the render will not show any seams in the UV border edges.

noseam.jpg

note: The same method can be applied to combine multiple color/normal/spec/bump maps.

You can use this mel script that will do everything for you ;)


multi_disp.zip

Note:
Some might question the reason of using “out Color” rather than “out Alpha”It is true that we should use “out Alpha” but, due to few limitations with mental ray for Maya it was “easier” to use out color.Mudbox floating displacement work nicely with this method.However if you wish to use the “alpha gain/ alpha offset” trick. This above method won’t work.
We will need to redo our shading network and “convince” mental ray to respect these changes in the alphaHere is an example of such network

multi_connectionnew.jpg

New Mel is provided ;)

 

newmulti_disp.zip

Recent Entries

5 Responses to “Multi Displacement Setup”

  1. Peter Barati Says:

    The Multi Displacement Setup works awesome, I have a problem though. When I render everyting looks gray and I can only see minimal colors coming through. Do you know what might be the problem? ( I have three UV tiles for my color maps, I I have used tif files?

  2. Ashraf Says:

    Have you tried with TGA for 8 bit and EXR for 32 (rather than using the TIFF)
    you also might want to use the new MEL
    multi_channel

  3. Peter Barati Says:

    Sorry for the late answare. I solved the problem. I was rendering with Mental ray (Maya). I was using the Sun&Sky built in Mental Ray, so everything got washed out, because there is a double gamma correction, so I had to do a gamma correction to the texture to change back gamma. Now everything is perfect.
    Thanks.
    You know I just wonder sometimes, how big companies like Autodesk do not make the user`s life easy.
    On the other hand you have made the Displacement Magic in Maya. That is just a genius thing.

    Peter

  4. Peter Says:

    Hi Ashraf!

    Very handy bit of mel you got going on.
    I’m having issues with displacement and multiple UV sets (not just shells)
    Have you ever used those?

    seems you can’t have displacement and bump on any uv channel other than default 0 (map1). Have you ever run into that problem?
    I have a separate uv layout for normals and displacement and it’s causing a bother.

    P.

  5. Ashraf Says:

    Can you use per-face shader assignment?

Leave a Reply