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

Monday, August 8, 2011

Procedural Dents 'n' Dirt (Part 2)

The terms 'Ambient Occlusion map' (or 'AO map') and 'Dirt map' are often used interchangeably. Vray has a node called 'Vray Dirt', which is actually just an ambient occlusion node. Recently I saw an advert for a 3ds Max plugin that allows users to weather and dirty up their models with a fairly realistic looking procedural grime, complete with nice looking streaks. Ambient occlusion does a pretty good job of simulating the areas where dirt buildup is likely to occur on an object.


A very dirty keyboard

Today we'll go a little bit further in Maya than simply baking out an AO map; we'll use ambient occlusion as the beginnings of a mask for a procedural dirt texture. Then, as an enhancement we'll add some streaks in order to break things up a bit for a more natural look. Once finished, we will have created something that does a similar job to the commercial 3ds Max plugin described above, and we'll have saved $30! In Part 3 we will conclude this tutorial by connecting the 'dirt' shader network to our 'dents' shader network (see Part 1), for a very flexible overall shader that we can use in a variety of projects.

Friday, August 5, 2011

Procedural Dents 'n' Dirt (Part 1)

edit: This post has been updated as of 6/13/2012, to account for a previous missed step in the shading network (insert clamp node).  
Example shader

This is a really great technique for quickly generating some chips and dents along the outside edges of your model, as well as adding a layer of dirt (in part 2) to the more recessed areas. Once you have a handle on this technique you can then customise and apply it to all manner of materials. For this shader we will be utilising two of the Mental Ray nodes- a 'mib_amb_occlusion' node as well as a 'mia_roundcorners' node.

Firstly, let's work on generating some chips and dents for our model...


To get a better sense of what we're aiming for, here are some images which show the effect of edge chipping...

Examples of images of edge chipping on a variety of materials


Alright. Some nice subtle and not so subtle edge chipping. By looking at these shots we can appreciate that many objects in the real world show signs of this kind of wear and tear. What this means when it comes to our models and textures is that often times it is not enough to just simply apply a bevel to our object- but we should also think about introducing some variation into the bevel itself for added realism. We want to break up the bevel. How much will depend on our object, it's age and the material we are trying to represent.


So let's start... In the hypershade, bring two new 'mia_roundcorners' nodes into the work area. We also need to bring in an additional node- one of the Maya utility nodes- called 'Vector Product'.

Double click on the Vector Product node to bring up it's attributes window. Then, with mouse pointer over one of the roundcorners nodes in the hypershade, middle click and drag over to the 'input 1' slot in the Vector Product attributes. Release the middle button and the two nodes should now be connected. Do the same for the other roundcorners node but this time connect it to the 'input 2' of the vector product.

Two roundcorners_bump nodes connected to input 1 and input 2 of a Vector Product node

So far, so good.


Thursday, August 4, 2011

Welcome :)

Welcome to Materialism, a blog primarily about shading networks and materials. Hopefully over time this site will start to serve as a repository of neat shader tricks and information that people may be able to find useful in their own projects. The focus will be on Mental Ray for Maya in the beginning, with a possible expansion into other rendering engines and 3d packages as time goes on. Whenever I can personally learn something new and interesting which I feel has not been posted ad infinitum elsewhere on the web- I'll aim to make a post on it.

I'll likely be experimenting with basic design and functionality of the site over the next few weeks.

Hope you enjoy :)