Beer glass scene creation
This course contains a little bit of everything with modeling, UVing, texturing and dynamics in Maya, as well as compositing multilayered EXR's in Photoshop.
# 1 13-04-2007 , 05:52 AM
Subscriber
Join Date: Dec 2006
Posts: 72

Texture question

I've made a box out of planes, not a c cube, because I wanted the box to collapse and open it's lid etc.

The sides of the box are all textured the same, although on the top there's two textures, so it reads "DO NOT OPEN"

However, when it's opened, you can see the texture in reverse. Is there anyway to have the reverse of the plane show another texture?

James

Attached Thumbnails
# 2 13-04-2007 , 06:03 AM
jsprogg's Avatar
Lifetime Member
Join Date: Feb 2004
Location: Chicago
Posts: 1,712
What you need to do is create a double sided shader that applies one material to one side and another to the opposite side. You can do this in Maya by creating a condition that samples an
object’s normal direction and uses it as material switcher.
You need to uv map the box lid as a seperate object and add a lambert material to it.

Open the Hypergraph and, selecting your object (box lid) , select Graph > Graph Materials On Selected Objects.
You should see your Lambert material in the
Hypergraph. Create a condition node and a samplerInfo node.
MMB-click and drag the samplerInfo node to the condition.
Select Other as the connection to open the Connection Editor.

In the Connection Editor, connect the flipped normal
attribute of the samplerInfo node to the condition
node’s second term. now select the condition node in the hypergraph and in the connection editor reload left,the select the Lambert in the hypergraph and reload right.
Connect condition1. outColor to the Lambert Material incandescence. Now double-click on condition1 to open the Attribute Editor. Under Conditon Attributes set its operation to Not Equal to distinguish one object face from its opposite side. Render a frame; the lid now has a white and a black side. In the Hypergraph create two more materials (Lambert, blinn whatever you need): one red, one green. Connect the red material’s outColor to condition1.colorIfTrue by MMB draging the red material to the condition node and selecting colorIfTrue and the green’s outColor to condition1.colorIfFalse by doing the same with the green and selecting colorIfFalse.
Rename the green material to ‘Front’ and the red one to ‘Back’.
You can now treat these as two normal shaders on one
object. Add front and back texture maps to each materials' colours as you would normally, and there you have it.


Last edited by jsprogg; 13-04-2007 at 06:59 AM.
# 3 13-04-2007 , 07:09 AM
jsprogg's Avatar
Lifetime Member
Join Date: Feb 2004
Location: Chicago
Posts: 1,712
Here I made it for you , just go to the Hypershade and import it then select the green front material HIT CTRL + A and put your front texture on the colour and the red back material and put the back texture onthat simularly. Then MMB drag the doublesidedshaderM onto your UV mapped lid.

Attached Files
File Type: ma doublesided_shader.ma (2.4 KB, 296 views)

Last edited by jsprogg; 13-04-2007 at 07:11 AM.
# 4 13-04-2007 , 07:29 AM
Subscriber
Join Date: Dec 2006
Posts: 72
Firstly, thanks for writing that for me, I appreciate it alot.

Secondly, I get the following error when I go to test it:

// Warning: rman Warning: S05001 Shadeop error: argument types clash in op _assign at pc 850 in "C:/Documents and Settings/James/My Documents/maya/projects/Trapped/renderman/box/shaders/doublesided_shader_doublesidedM_".
Shader "C:/Documents and Settings/James/My Documents/maya/projects/Trapped/renderman/box/shaders/doublesided_shader_doublesidedM_", Geometry "lidShape1". //

And it just renders the default grey.

However, when I tried it on a plane in an untitled file, it worked OK. Any ideas?

James

# 5 13-04-2007 , 07:31 AM
jsprogg's Avatar
Lifetime Member
Join Date: Feb 2004
Location: Chicago
Posts: 1,712
did you seperate the lid into a seperate object ?
I don't think it would work very well if you have more than one shader on the object with this.

# 6 13-04-2007 , 07:35 AM
Subscriber
Join Date: Dec 2006
Posts: 72
er....it's not a poly cube, it's a number of planes rotated into the shape of a cube, then it's transformations frozen.

I'm only applying that texture to that plane...

# 7 13-04-2007 , 07:37 AM
jsprogg's Avatar
Lifetime Member
Join Date: Feb 2004
Location: Chicago
Posts: 1,712
hmm.. if if worked on a new plane I can't see why it wouldn't work on this plane, have you done anything to the plane ?
Simply answer is to replace this plane with a new one with no subdivions.


Last edited by jsprogg; 13-04-2007 at 07:40 AM.
# 8 13-04-2007 , 08:17 AM
Subscriber
Join Date: Dec 2006
Posts: 72

# 9 13-04-2007 , 10:06 AM
jsprogg's Avatar
Lifetime Member
Join Date: Feb 2004
Location: Chicago
Posts: 1,712
I see the problem ..you never mentioned you wanted to render with renderman.
You need to create a rederman custom shader, this is quite involved and needs enviroment variables to be added so you can access the rendermantree and would take me while to write.

# 10 13-04-2007 , 10:08 AM
Subscriber
Join Date: Dec 2006
Posts: 72
oh dear.

I should be able to work that out..

I hope

thanks for looking thou

# 11 13-04-2007 , 10:13 AM
jsprogg's Avatar
Lifetime Member
Join Date: Feb 2004
Location: Chicago
Posts: 1,712
can you not use Mentalray ? this shader will work with Mentalray or maya software.

# 12 13-04-2007 , 10:18 AM
Subscriber
Join Date: Dec 2006
Posts: 72
I may, it's just I've been redndering with RMfM and results between the two renderers are fairly staggering...

Thanks again for all your help...

# 13 13-04-2007 , 11:42 AM
jsprogg's Avatar
Lifetime Member
Join Date: Feb 2004
Location: Chicago
Posts: 1,712
james I am writing you instructions but it will take a while because it's a lot of steps and not easy to explain simply.

# 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.
# 15 13-04-2007 , 02:53 PM
Subscriber
Join Date: Dec 2006
Posts: 72
Wow!!!

You went to town there, thank you sooooo much.

I'll give it a bash tonight/early hours of tomorrow morning. I know I'm going to be up late.

Thanks once again!!

James

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads