« Jittered Tiles | Main | Varied Line Weight in Illustrator »
January 14, 2005
Sample a Maya File Texture

To sample a Maya file texture node at a certain pixel, you need to feed the file node the correct U and V values.

In this example, the middle pixel of the texture map, at the place where U = V = 0.5, is a rusty brown color.
I've created a ramp with the color (0.5, 0.5, 0.5) and mapped the R and G output values of the ramp to the U and V input values of the file texture node. The result? The very brown color you'd expect.
Let's try something a little more interesting...

Here's the texture UV-mapped in the usual way onto two NURBS patches, a torus and a plane.

The results are as you would expect.

By connecting the UV channels of the object to the surface shader red and green colors, we can visualize the natural UV coordinates of the NURBS surfaces.

Suppose instead of accepting the natural "default" UV values that come "baked" into the NURBS surfaces, we supply our own. Since the objects have been conveniently modeled small and near the world origin they happen (because I planned it this way) to sit in the cubical region of world space with corners at (0,0,0) and (1,1,1)

Instead of letting the file texture node get the usual UV values, lets pass world space X to U and world space Y to V.

We have just mathematically modelled an XY planar projection without using a Maya projection node.
If you know the math, you can make all kinds of projectors and other fun textural things for yourself.
Caveat
If you try to do this any Maya 4.5 and later, you may need to implement a workaround: if you try to REPLACE 2dplacement uv info with your own exotic math, Maya detects this as a missing placement node and ignores user-supplied uv info, going into a default behavior instead. If however you KEEP the placement node, but multiply its data by zero, you can SUM it with your own exotic math, thereby "tricking" Maya into accepting some very slick shader math right in the hypershade.
I could do some very exotic "slit-scan" effects on animated file textures if I could map a unique frame number or frame offset to every pixel, but Maya seems to allow the frame number to be updated once per frame, not once per pixel.
Posted by digital artform at January 14, 2005 08:09 PM
Comments
Very nice tut.
Posted by: Unknown at February 5, 2005 08:15 PM
regarding the combination of these networks and the maya crash that follows... so time I do see a message in the command line that says something like
"invalid expression type IF test condition"
Posted by: charles at October 8, 2005 06:46 PM
I think I figured out the crash..... when I combine the two expressions into one, it seems to work.... at least so far.....
Posted by: charles at October 8, 2005 08:56 PM