August 26, 2010

lcMrBatchBake.mel – Mental Ray for Maya Texture and Vertex Baking

Download - Updated – 08/27/2010
Script: lcMrBatchBake.mel
Icon: icon_lcMrBatchBake lcMrBatchBake.bmp

NOTE: Apparently this script doesn't work on the Mac, I don't have one to test with so you guys are out of luck sorry.'

Now you have the option to bake vertex color as well as texture maps.  This is great for baking ambient occlusion to vertices for game models.  I also consolidated and simplified a lot of the code. Plus now its colorful!

August 21, 2010

lcSkinShader.cgfx – Maya Realtime Skin Shader

Download: lcSkinShader.cgfx (save as)

Another cool shader – inspired by the Siggraph 2010 presentation 'Uncharted 2: Character Lighting and Shading' by John Hable.  Its a great presentation and offers a lot of insight on how to create realistic SSS effects in shader. Unfortunately, the main topic – blurred render targets – is not possible in Maya, but the secondary techniques presented, Bent Normals and Blended Normals, are doable in Maya.

This shader takes the Blended Normals approach and adds some other elements, such as a reddish edge to the diffuse falloff, as well as uses 2 specular highlights.  Also the paper describes how the Blended Normals technique results in a blue/red coloration, and the blue is not as desirable as the red, so I have implemented a very basic cyan suppression as well.

Here is a comparison with Lambert diffuse and my SSS effect (exaggerated for emphasis):

Again, a lot of attributes, but the key SSS ones are:

SSS Blended Normal Intensity – this controls the main effect of the blended normals.

SSS Edge Color – this is the color along the Diffuse Shading edge

SSS Edge Radius – this is the size of the Diffuse Shading edge coloration

SSS Edge Exponent – another tweakable parameter to adjust the reddish edge

Specular Normals Intensity – because the blended normals technique can ‘lessen’ the impact of the normal map, but overdriving the normal map intensity on the diffuse can look bad, this only overdrives the normal map on the specular highlight. Can help bring back detail.

The shadowMap and AO parts are the same as my lcHairShader.cgfx.


August 19, 2010

lcHairShader.cgfx – Maya Realtime Hair Shader

Download: lcHairShader.cgfx (save as)
08/21/2010 – fixed some problems with the shadowMap texture and AO texture and vertex color code.
This one is pretty cool – I’ve been reading some of the papers coming out of Siggraph and one by the Uncharted 2 Team referenced an old 2004 paper called “Practical Real-Time Hair Rendering and Shading” by Thorsten Scheuermann.  Its a really great paper and I decided to make a cgfx implementation of its hair technique for Maya.  The paper is interesting because it offers a single purpose anisotropic highlight function that is specially designed for hair – using no normal maps, the only real required map is a specular map to jitter the highlight and create the ‘strands’ effect.
My Maya shader is much expanded and has a lot of functions from my previous shaders as well as some new things.  Its a very versatile hair shader – although it tends to lend itself more to stylized looks than photorealism.
NOTE: Hair UV shells should all be aligned vertically – highlight orientation is based on the UV shell alignment.
There are a ton of attributes, but some of the more interesting ones are:
Main UV Texture Tiling – tiling is useful on main diffuse and specular textures to sort of set the size of the hair strands – normal map can be excluded from tiling
Hair Color – Multiplied by diffuse map – diffuse map can be B&W or colorized if you set hair color to white.
Spec Edge Sharpness – hardens the specular highlight to make it look shinier/slicker
Specular Highlight Shift – moves the highlight up and down the surface
Specular Noise Map Scale – controls the intensity of the specular jitter effect
AO in vertex color – you can bake AO into the vertex color – multiplies by the Ambient and Diffuse
Shadow Map – r is shadow for light 1, g is shadow for light 2, b is shadow for light 3, a (alpha) is AO
Texture Examples:
hairdiffuse (multiply by hair color) – alpha is hair transparency
 hair_normalmap normal map (for big waves)
specJitterspecular highlight jitter (this is normal map alpha channel)