Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Maya Basics & Newbie Lounge (https://simplymaya.com/forum/forumdisplay.php?f=31)
-   -   Texture question (https://simplymaya.com/forum/showthread.php?t=25874)

JamesP 13-04-2007 05:52 AM

Texture question
 
1 Attachment(s)
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

jsprogg 13-04-2007 06:03 AM

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.

jsprogg 13-04-2007 07:09 AM

1 Attachment(s)
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.

JamesP 13-04-2007 07:29 AM

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

jsprogg 13-04-2007 07:31 AM

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.

JamesP 13-04-2007 07:35 AM

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...

jsprogg 13-04-2007 07:37 AM

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.

JamesP 13-04-2007 08:17 AM

not as far as I know...

www.metalrobot.co.uk/trapped/box.zip if you want to take a look...

jsprogg 13-04-2007 10:06 AM

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.

JamesP 13-04-2007 10:08 AM

oh dear.

I should be able to work that out..

I hope

thanks for looking thou

jsprogg 13-04-2007 10:13 AM

can you not use Mentalray ? this shader will work with Mentalray or maya software.

JamesP 13-04-2007 10:18 AM

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...

jsprogg 13-04-2007 11:42 AM

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 13-04-2007 02:08 PM

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.

JamesP 13-04-2007 02:53 PM

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


All times are GMT. The time now is 09:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018