May 2006 Archives

Maya Ramp Shader

| 2 Comments

Maya Ramp Shader

I've been playing a bit with the relatively new Maya Ramp Shader. It looks promising, but (if I'm using it correctly) not entirely bug-free. (What is that white transitional color?)

It takes as its solution the idea of using light to modify the surface color of an object. Nothing wrong with that; I did it myself here.

I'd like to suggest that Maya consider adding similar functionality into the light itself, as I did here.

It's hard to light highly saturated colored objects in a sophisticated manner, even when (and one might say especially when) using saturated light.

Suppose I have a bright red flag. Further suppose I wish its shaded areas to fall into a rich dark purple.

Easier said than done.

render1_2.jpg

My first attempt might entail filling the dark areas of my waving red flag with a saturated purple light. As you can see from the images above, saturated purple light has no effect on a saturated red object because saturated red (1 0 0) times dark purple (.5 0 .5) only equals dark red (.5 0 0)

What I need to do is use the lighting of the flag as a matte into another texture map - a purple one.

twoFlags.jpg

First a create a second texture map in a deep rich purple.

shaderNetwork_v1.jpg

Next I use surface luminance to control a blend between the red and purple flag textures.

render3.jpg

It's not a bad idea. The only problem is Maya continues to LIGHT the flag. See how dark the shaded area still is? I don't want that effect.

shaderNetwork_v2.jpg

I compensate for the lighting by DIVIDING the object's color by its own luminance. This effectively turns the Lambert lighting into a surface shader.

render4.jpg

Ah, that's more like it! See how nice and purple the shaded region is? It's not just a darker version of the red flag; it's a whole other hue. Very painterly. Not at all CG-ish.

UPDATE 5/29/2006

If this line of thinking interests you, be sure to explore Maya's Ramp Shader, which addresses the issue of hue falloff in CG lighting.

pureYellowBall.jpg

Here's a pure yellow ball sitting on a white table in Maya. Since the table is white, it takes on the color of the light shining upon it, so in this image, the light is also white.

Here's a question for you:
What would happen to the yellow ball if I change the light color to pure blue?

pureBlueBall.jpg

Depending on what you think happens to colored objects under colored light you might guess that the ball would become green. You might also guess that the ball would become white.

You probably would not guess that the ball would become black, but that's exactly what happens. Maya multiplies the light color by the object's diffuse color. (1 1 0) times (0 0 1) equals (0 0 0).

unsatBlueBall.jpg

If you desaturate the blue light so that there is some green in it - then you will get a nice green ball.

It's very hard to light highly saturated objects.

It's very hard to light with highly saturated light.

In the real world, colors are usually not so pure.

Maya Double-Sided Shader

| 1 Comment

doubleSidedShader.jpg

The samplerInfo node has a flag called flippedNormal that returns either a 0 or a 1 depending on which side of a single-sided surface you are seeing.

Many people use this to drive a Maya conditional node and so create something called a double-sided shader - a single surface with one texture on one side and another texture on the other side.

The syntax for the conditional node can be confusing to some Maya users. If you'd like an easier to remember alternative, consider using the flippedNormal flag to drive a blendColors node instead.

Faking Simple Volumetric Fog

| 2 Comments

redMistPlane.jpg

Here's an old school way of faking volumetric fog. I'm not sure who invented the idea, but we used to do it this way back in the Eighties.

noFogPlaneRGB.jpg

Set up a scene.

noFogZ16.jpg

Use a camera-based grad to fake a Z-depth render. Let gray represent distance from camera - the further, the brighter. Render in 16 bits.

FogPlaneRGB.jpg

Slam in a ground plane. This will represent the height of the top of your ground mist.

FogZ16.jpg

Render out another 16-bit Z-depth image with your elevated ground plane in place.

fogSubtraction.jpg

Subtract one 16-bit Z-depth image from the other. This will give you an image of fog ray traversal lengths - exactly as if you ray-marched through the volumteric fog.

processedMask.jpg

You can tweak the contrast if you wish.

fogLayerMask.jpg

Use this volumetric ray-marched mask as a key mix between your rendered scene and an image of pure fog color. (I chose pure red for my full fog image)

redMistPlane.jpg

Here are the results again. You can adjust fog density to taste by adjusting the density of the Z-depth difference mask.

This technique is pretty old-school. For it to work you have to stay out of the fog.

About this Archive

This page is an archive of entries from May 2006 listed from newest to oldest.

April 2006 is the previous archive.

June 2006 is the next archive.

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