Sample a Maya File Texture

| 3 Comments

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

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

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

uvRender1.jpg
The results are as you would expect.

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

visualizeUVs2.jpg
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)

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

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

3 Comments

Very nice tut.

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"

I think I figured out the crash..... when I combine the two expressions into one, it seems to work.... at least so far.....

Leave a comment

About this Entry

This page contains a single entry by published on January 14, 2005 8:09 PM.

Jittered Tiles was the previous entry in this blog.

Varied Line Weight in Illustrator is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.