View Single Post
# 14 13-04-2007 , 02:08 PM
jsprogg's Avatar
Lifetime Member
Join Date: Feb 2004
Location: Chicago
Posts: 1,712
ok I must be insane but heres how to create a custom double sided shader in RenderMan ..

go to the control panel on Windows and double click on System.
select the advanced tab in system properties window then click on
Environment variables.
Create a new variable
Variable name: RMANTREE
Variable value: c:\Program Files\Pixar\RenderManForMaya7.0-1.0\rmantree

(your path to rmantree might not be the same on your machine)

next below in the system variables window you should now see a variable called Path
double click on that and then in the variable value window we need to modify the path.
If it doesn't end in a semi colon add one then in windows explorer browse to your renderman folder
and select the bin folder then copy the address at the top which will be something like
c:\Program Files\Pixar\RenderManForMaya7.0-1.0\bin
and paste this after the semi colon in the variable path then click ok.
This will now allow you to compile custom shaders for renderman.

Open notepad
you need to comment so at a later date you or whoever knows what this shader is.
to comment in renderman you use /* (forward slash and astrix)
to close a comment you use */ (astrx and forward slash)
Anything between those two comment will be ignored by renderman but you can read if you open the shader.
lets create a basic shader and compile it and connect it in Maya.
copy the following script into notepad and it's very important that you get the cases correct
so capital O but small i,capital C but small s
----------------------------------------------------------------------------------------------------

ok so comment /* this a double sided shader*/


surface myDtextureShader (string image_file1= ""; string image_file2= ""; ) {

color imageToUse;

color imageFront = texture(image_file1);

color imageBack = texture(image_file2);


/*check the normals and see if they are facing the camera*/

normal n = normalize (N);

normal Nf = faceforward (n,I);

if (n == Nf ) {

/* if this is true then the normal did not get flipped */

imageToUse = imageFront;

} else {
/* if this is false then the normal did get flipped */

imageToUse = imageBack;

}

Oi = Os;
Ci = Cs * imageToUse * Oi * diffuse(Nf);


}

-----------------------------------------------------------------------------------------------------
ok this is the basic shader so save this with a .sl extension

for now create a folder called shaders on one of your drives and save it as myDtextureShader.sl in that.
Now you need to complie the shader as maya will not take this .sl file
so open up the command prompt start/all programs/Accessories/command prompt
type in the drive letter you created the shaders folder on and then a colon and hit enter.
for example if the shaders folder is in D then you would type this
c:\Documents and Settings\ your name >d:

next type cd shaders (D:\>cd shaders)
you will see this D:\shaders>

next type myDtextureShader.sl (D:\shaders>myDtextureShader.sl) hit enter and it will compile

you should now have a complied shader with a .slo extension in your shaders folder.

Leave the command prompt open for now.

Ok assuming you got no errors it time to move to Maya.

In Maya open the hypershade and then with the renderman plugin loaded
right at the top of the create menu click on Render Man Shader

click ctrl+A and in the attribute editor click the little folder next to shader at the top
and browse to the myDtextureShader.slo file.

now comes the awkward part because you can't load an image into this shader without converting it
a .tx file.

Move the two texture files you want into the shader folder you created.

In the command prompt type txmake then the name of the first file and then frontImage.tx

(so it will look something like this D:\shaders>txmake xxxx.jpg frontImage.tx) hit enter.

type again txmake and the name of the second file and then backImage.tx

you should now have the two files converted to .tx which renderman can read.

back in Maya attribute editor under RenderMan Shader Parameters

image_file1 using forward slashes type the path to the frontcolorM.tx file

image_file2 using forward slashes type the path to the backcolorM.tx file

example D:/shaders/frontcolorM.tx

ok all that remains is to MMB drag the renderman shader from the hypershade to your object.

test render and relax.


Last edited by jsprogg; 13-04-2007 at 02:31 PM.