Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 13-04-2007, 06:52 AM   #1
JamesP
Subscriber
 
Join Date: Dec 2006
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
JamesP is offline   Reply With Quote
Old 13-04-2007, 07:03 AM   #2
jsprogg
Lifetime Member
 
jsprogg's Avatar
 
Join Date: Feb 2004
Location: Chicago
Posts: 1,706
Thanks: 0
Thanked 85 Times in 77 Posts
Default

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 07:59 AM.
jsprogg is offline   Reply With Quote
Old 13-04-2007, 08:09 AM   #3
jsprogg
Lifetime Member
 
jsprogg's Avatar
 
Join Date: Feb 2004
Location: Chicago
Posts: 1,706
Thanks: 0
Thanked 85 Times in 77 Posts
Default

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, 34 views)

Last edited by jsprogg : 13-04-2007 at 08:11 AM.
jsprogg is offline   Reply With Quote
Old 13-04-2007, 08:29 AM   #4
JamesP
Subscriber
 
Join Date: Dec 2006
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
JamesP is offline   Reply With Quote
Old 13-04-2007, 08:31 AM   #5
jsprogg
Lifetime Member
 
jsprogg's Avatar
 
Join Date: Feb 2004
Location: Chicago
Posts: 1,706
Thanks: 0
Thanked 85 Times in 77 Posts
Default

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.
jsprogg is offline   Reply With Quote
Old 13-04-2007, 08:35 AM   #6
JamesP
Subscriber
 
Join Date: Dec 2006
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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...
JamesP is offline   Reply With Quote
Old 13-04-2007, 08:37 AM   #7
jsprogg
Lifetime Member
 
jsprogg's Avatar
 
Join Date: Feb 2004
Location: Chicago
Posts: 1,706
Thanks: 0
Thanked 85 Times in 77 Posts
Default

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 08:40 AM.
jsprogg is offline   Reply With Quote
Old 13-04-2007, 09:17 AM   #8
JamesP
Subscriber
 
Join Date: Dec 2006
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

not as far as I know...

www.metalrobot.co.uk/trapped/box.zip if you want to take a look...
JamesP is offline   Reply With Quote
Old 13-04-2007, 11:06 AM   #9
jsprogg
Lifetime Member
 
jsprogg's Avatar
 
Join Date: Feb 2004
Location: Chicago
Posts: 1,706
Thanks: 0
Thanked 85 Times in 77 Posts
Default

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.
jsprogg is offline   Reply With Quote
Old 13-04-2007, 11:08 AM   #10
JamesP
Subscriber
 
Join Date: Dec 2006
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

oh dear.

I should be able to work that out..

I hope

thanks for looking thou
JamesP is offline   Reply With Quote
Old 13-04-2007, 11:13 AM   #11
jsprogg
Lifetime Member
 
jsprogg's Avatar
 
Join Date: Feb 2004
Location: Chicago
Posts: 1,706
Thanks: 0
Thanked 85 Times in 77 Posts
Default

can you not use Mentalray ? this shader will work with Mentalray or maya software.
jsprogg is offline   Reply With Quote
Old 13-04-2007, 11:18 AM   #12
JamesP
Subscriber
 
Join Date: Dec 2006
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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...
JamesP is offline   Reply With Quote
Old 13-04-2007, 12:42 PM   #13
jsprogg
Lifetime Member
 
jsprogg's Avatar
 
Join Date: Feb 2004
Location: Chicago
Posts: 1,706
Thanks: 0
Thanked 85 Times in 77 Posts
Default

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.
jsprogg is offline   Reply With Quote
Old 13-04-2007, 03:08 PM   #14
jsprogg
Lifetime Member
 
jsprogg's Avatar
 
Join Date: Feb 2004
Location: Chicago
Posts: 1,706
Thanks: 0
Thanked 85 Times in 77 Posts
Default

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 03:31 PM.
jsprogg is offline   Reply With Quote
Old 13-04-2007, 03:53 PM   #15
JamesP
Subscriber
 
Join Date: Dec 2006
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
JamesP is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.