View Full Version : Normal mapping - Mental Ray
Seven 11-07-2007, 08:56 AM Could someone please tell me how to render a normal map in mental ray? I am using maya 7 and it just doesnt appear to do it.
I have downloaded and tried this:
http://www.headus.com/au/samples/norm-MR/
... but with little success.
Are there any tips, tricks.. anything really : ) that will allow mental ray to render normal maps.
Many Thanks
|
|
kojala
11-07-2007, 10:09 AM
hi
Im using maya 6 and had the same problem.
So I made this mel based on that headus site .mb file.
this mel creates all nodes that it needs to convert the normalmap
just select the file node and camera node that you will be using in
your rendering. and there must be a connection from filenodes outColor to
a materials normalCamera
{
string $file[] = `ls -fl -type file -sl`;
$camera = `ls -fl -type camera -sl`;
if (size($camera) < 1)
{
$camera = `ls -fl -type transform -sl`;
$camera = `listRelatives -type camera $camera`;
}
if (size($camera) < 1)
error "No camera selected.";
if (size($file) < 1)
error "No file selected.";
string $render_camera = $camera[0];
for ($map in $file)
{
string $mat[] = `listConnections -s 0 -d 1 ($map + ".outColor")`;
if (size($mat) < 1)
error "No material connected.";
string $rgb_to_xyz = `shadingNode -n RGB_to_XYZ -asUtility setRange`;
setAttr ($rgb_to_xyz + ".oldMaxX") 1;
setAttr ($rgb_to_xyz + ".oldMaxY") 1;
setAttr ($rgb_to_xyz + ".oldMaxZ") 1;
setAttr ($rgb_to_xyz + ".maxX") 1;
setAttr ($rgb_to_xyz + ".maxY") 1;
setAttr ($rgb_to_xyz + ".maxZ") 1;
setAttr ($rgb_to_xyz + ".minX") -1;
setAttr ($rgb_to_xyz + ".minY") -1;
setAttr ($rgb_to_xyz + ".minZ") -1;
string $sampler = `shadingNode -asUtility samplerInfo`;
string $vector_1 = `shadingNode -asUtility vectorProduct`;
setAttr ($vector_1 + ".operation") 2;
setAttr ($vector_1 + ".normalizeOutput") 1;
string $vector_2 = `shadingNode -asUtility vectorProduct`;
setAttr ($vector_2 + ".operation") 1;
setAttr ($vector_2 + ".normalizeOutput") 0;
string $vector_3 = `shadingNode -asUtility vectorProduct`;
setAttr ($vector_3 + ".operation") 1;
setAttr ($vector_3 + ".normalizeOutput") 0;
string $vector_4 = `shadingNode -asUtility vectorProduct`;
setAttr ($vector_4 + ".operation") 1;
setAttr ($vector_4 + ".normalizeOutput") 0;
string $vector_5 = `shadingNode -n NORMALMAP_output -asUtility vectorProduct`;
setAttr ($vector_5 + ".operation") 3;
setAttr ($vector_5 + ".normalizeOutput") 1;
string $normal_node = $map;
connectAttr -f ($normal_node + ".outColorR") ($rgb_to_xyz + ".valueY");
connectAttr -f ($normal_node + ".outColorG") ($rgb_to_xyz + ".valueX");
connectAttr -f ($normal_node + ".outColorB") ($rgb_to_xyz + ".valueZ");
connectAttr -f ($sampler + ".tangentUCamera") ($vector_1 + ".input1");
connectAttr -f ($sampler + ".normalCamera") ($vector_1 + ".input2");
connectAttr -f ($rgb_to_xyz + ".outValue") ($vector_2 + ".input1");
connectAttr -f ($rgb_to_xyz + ".outValue") ($vector_3 + ".input1");
connectAttr -f ($rgb_to_xyz + ".outValue") ($vector_4 + ".input1");
connectAttr -f ($sampler + ".tangentUx") ($vector_2 + ".input2X");
connectAttr -f ($sampler + ".tangentUy") ($vector_3 + ".input2X");
connectAttr -f ($sampler + ".tangentUz") ($vector_4 + ".input2X");
connectAttr -f ($sampler + ".normalCameraX") ($vector_2 + ".input2Z");
connectAttr -f ($sampler + ".normalCameraY") ($vector_3 + ".input2Z");
connectAttr -f ($sampler + ".normalCameraZ") ($vector_4 + ".input2Z");
connectAttr -f ($vector_1 + ".outputX") ($vector_2 + ".input2Y");
connectAttr -f ($vector_1 + ".outputY") ($vector_3 + ".input2Y");
connectAttr -f ($vector_1 + ".outputZ") ($vector_4 + ".input2Y");
connectAttr -f ($vector_2 + ".outputX") ($vector_5 + ".input1X");
connectAttr -f ($vector_3 + ".outputX") ($vector_5 + ".input1Y");
connectAttr -f ($vector_4 + ".outputX") ($vector_5 + ".input1Z");
connectAttr -f ($render_camera + ".worldMatrix[0]") ($vector_5 + ".matrix");
for ($item in $mat)
connectAttr -f ($vector_5 + ".output") ($item + ".normalCamera");
}
}
Download (http://www.pixero.com/files/JS_Normalmapper1.2.2.zip) JS_Normalmapper. It works great for me. Plus, you can easily combine normal and bump maps with it.
Sphere♥
11-07-2007, 03:42 PM
Actually, it's straightforward, just as with Maya shaders, you simply feed the normal map directly to the normal without going through a bump node, that's it! (with Maya shader it would look like this: [place2dTexture] => [normal_map_file] outColor -> normalCamera [material])
For a normal map in mental ray with mia_material, you could do something like this:
http://img100.imageshack.us/img100/8544/mrmmnmch7.png
Ooops, just realized you're using Maya 7. Download the bumpcombiner (http://mymentalray.com/mymr_shaders/shaders.htm) mental ray shader add-on and you can use the regular Maya method (explained above) with any mental ray shader.
Seven
11-08-2007, 08:22 AM
Excellent, thank you very much everyone! im currently at work but will definatly give those a try tonight.
Very much appreicated.
CGTalk Moderation
11-08-2007, 08:22 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.