Saturday, June 9, 2012

Radial Anisotropy w/ mia_material

Anisotropic Brushed Metal Material

Here's how to create a cool, radially anisotropic metal type shader with the mia_material in Mental Ray/Maya.

(PS, For a  general introduction to anisotropic materials in CG, I recommend this great article by Neil Blevins at his CG Education website).

Jumping straight in- first, let's create a simple object in which to apply our shader to. For convenience sake- let's just use a poly disk, which you can find (yes, Maya has a poly disk!) by holding shift and right clicking in the viewport, then selecting 'Poly Disk'. Then create a new mia_material (or mia_material x) in the hypershade and apply it to the new object.

We're not going to worry about any of the other parameters apart from anisotropy for now; just scroll down through the mia_material until you reach the Anisotropy tab and click on it to extend it's parameters.

In the Anisotropy section of the mia_material there are three main parameters to consider. An 'anisotropy' parameter set to the default of 1 actually produces no anisotropic specularity, instead we get a normal, run of the mill isotropic (same in all directions) or rounded highlight. By moving the slider past or below one, we are able to stretch the highlight out. I find that turning the slider all the way down to .1 works fine. You'll notice that as soon as you adjust the Anisotropy parameter, the other two parameters- Rotation and Channel, become unlocked.

Next, we will need a texture in order to define the direction of our anisotropy. Click on the checker icon to the right of the Rotation parameter and select Ramp. In the ramp node, alter the Type to 'Radial Ramp', and make a two colour gradient that runs from black at the top to white on the bottom. Your sample swatch should look just like the one below. It's important to not get the colours reversed as that will not produce the desired result.

Make sure your ramp is set up correctly

At this stage you may want to do a quick test render. Turning on Mental Ray's IPR renderer can be useful when searching for a decent angle which will pick up the highlight. Rotate the camera around your object with IPR turned on and see how things are looking. Most probably you will observe a strange bending present in the highlight. This is where the 'Channel' parameter in the Anisotropy tab comes in. Default is -1. Set the channel to -2 and you should be now getting nice, straight, fanning anisotropic highlights (alternatively you can rotate the uv's of the disk 90 degrees).

Channel set to -1 on left, -2 on right

As far creating basic radial anisotropy with the mia_material, that's pretty much it.

For a more metallic look, try dialing down the diffuse colour/weight in the shader and give your material something to reflect... ideally some nice image based lighting. It's also a good idea to break up the highlight a little by putting something like a constrasted circular brushed metal texture into the colour slot of the reflection tab. Play around with the glossiness and glossy samples also.

You now have the unbridled power to create the bottoms of pots and pans and stereo knobs. :)

Click to Enlarge

Final example shader (in motion)

Thursday, May 31, 2012

Procedural Dents 'n' Dirt / Downward Drips (Part 3)

AO based weathering featuring DDD (Dents, Dirt, Drips)

Lately I've been working on trying to get some directionality into an AO weathering type shader. A problem with my previous shader was that the streaks weren't just dripping down from surfaces, but also dripping up. The current solution is to pipe the Out Colour of a Maya snow texture into both the bright and dark inputs of an AO node. Adjusting the 'depth decay' of the snow as well as the 'threshold' seem to be the main tweakable parameters here, along with AO spread.

I'm attaching an .ma scene file + shader if anyone would like to experiment (12 mb)

Just the DDD shader

Monday, April 2, 2012

Maya 2013 - New Node Editor

A new look for Maya's next gen Node Editor

Originally introduced as part of the Maya 2012 SAP (Subscription Advantage Pack), it appears that a new Softimage style node editor will be included with the upcoming release of Maya 2013, replacing the Hypershade/Hypergraph/Dependency Graph of previous versions. On first impression, I have to say I like the look of this new editor. Being able to quickly expand a node to get a better visual sense of input and output connections seems very useful. With this one new feature, the old secondary Connection Editor becomes redundant and everything is nicely unified within a single editor. Pretty nice.

Another welcome addition which will save time is the new TAB field - allowing for a more convenient way to quickly search for and generate nodes, ala Nuke.

Press TAB to quickly search/create nodes

Check out the video below for a quick demo of the new Node Editor in action...

Thursday, March 15, 2012

jjj_gammaTools 2.0.1

Gamma Correcting for every texture or colour swatch in a large shader network can be a chore

I've recently begun the search in earnest for useful maya scripts that can help cut down on repetitive tasks. One such gem I've stumbled across is a very helpful 'gammaCorrect' node generating utility, which becomes extremely useful when working within a linear workflow in Maya. This tool automates the process of inserting gammaCorrect nodes wherever required in a shader network- specifically on colour swatches and 8 bit textures, in order to remove the encoded gamma of 2.2 and allowing them to render correctly in linear space.

(If you're unfamiliar with linear workflow, I'd highly recommend becoming aquainted with the subject. It's super important...)*

Here is the MEL script...

(requires registration with the Creative Crash site)

Wednesday, March 7, 2012

Light Based Ambient Occlusion

Ambient occlusion based on luminance 

Here's a quick shader which will improve the look of your ambient occlusion pass by integrating it more closely with the directional lighting in your scene.

Sunday, February 26, 2012

Fake Parallax

Offsetting texture UVs via the camera normal

A good example of this shader is to imagine a building with a window cut into it, allowing the viewer to see through into the room beyond. Instead of modeling out the interior (which can be prohibitive in computer game environments where this trick is often applied) we can use a texture of the room instead, aligned roughly to the outside wall, with an offset to give the viewer a parallax cue in order to make it appear as though the room has some sort of three dimensional depth.

This is easier to understand when we can see things in motion - here's a quick setup scene to help illustrate.

Obviously this technique has some limitations, but when used in mid to background elements in shots where the camera motion isn't too extreme, it may be just the thing needed to help add some quick depth to a 3D scene, cutting down on the time spent modeling, texturing and lighting an interior.

So let's look at how we can go about setting up a shader which can recreate this parallax effect in Maya...