Pages

February 28, 2011

lcUberShader_2.7.cgfx

Download

Seems that I had uploaded the incorrect version, this is now fixed.  2.7 uses gp4vp and gp4fp profiles.

February 24, 2011

Updated lcShaders to gp4vp / gp4fp

lcUberShader, lcSkinShader
version 2.7 – Download Page

I have updated my lcUberShader and lcSkinShader to run on the gp4vp and gp4fp profiles instead of vp40 and fp40 as this removes some restrictions on the number of temporary registers available and allows for more complicated, math intensive shaders.  The lcUberShader suffers only a minor performance penalty but the lcSkinShader seems to run at 1/2 to 1/4 the speed compared to the old profile.  I’ll have to investigate the issue but I’m not focused on speed with these shaders.

On the plus side they both now have 3 directional lights and 3 point lights and I’ll expand the features in the near future to include baked shadow map functionality for the point lights as well.

I’ve only done preliminary testing so let me know if you run into issues.

February 23, 2011

lcUbershader Point Lights

version 2.6 – Download Page

I’ve added 3 point lights in addition to the 3 directional lights to the lcUbershader.  These point lights also have an attenuation property, so as they move away from an object their intensity decreases, there is a multiplier to adjust this effect.

I’m not quite sure what will happen with the baked shadows, currently only active for the directional lights, I will probably add the option for the point lights at a future time.

I haven’t had the time to test this change extensively so let me know if something is not working right.

I’m working on adding the point lights to the lcSkinShader also, but I hit the registers limit (32) for the fp40 profile so I’ll have to break things up into more passes or remove some features.

January 9, 2011

Updated Uber and Skin Maya Shaders

versions 2.3 – available here: Download Page

Added 2 new texture inputs
a mask to remove rimlighting from unwanted areas
a mask for the cubemap reflection, for example to isolate metal bits

I changed the way back face shading is done – instead of using the faceforward() function to invert the normals (as this causes some shading errors along the silhouette), I am now doing a 2 pass method.  A pass is rendered for the back faces and a second pass for the front faces is layered on top.  This is much more expensive as the geometry is rendered twice but you get perfect results.

Thanks to Richard Smith for the feedback leading to these updates.

September 7, 2010

Maya Realtime Shaders – Big Update

Up to date downloads are available here: Download Page
I’ve been reading alot of technical papers and was inspired to rewrite and double check all my shaders.  First, some things were broken for example, ambient color was not doing what its supposed to do.  Second, I finally understood the whole linear-lighting thing and all my rgb inputs have been appropriately gamma corrected.  With linear lighting, tonemapping and exposure become much more useful, so I implemented a simplified version of the Uncharted 2 “film-tonemap curve”.  Third, I wanted to make it easier to do rewrites and maintain the code, so i switched the way I was working with multiple lights and inspired by rsl illuminace loop am now doing my lighting through a loop.  This means I can change the code without having to worry about the number of lights or keeping track of their variables and passing them to all needed functions.  I only have to initialize an array to hold that information.
lcUberShader.cgfx and lcNextGenShader.fx are now visually the same although slight differences in the languages are apparent in the code.  I still recommend using cgfx over hlsl for Maya.
lcSkinShader.cgfx and lcHairShader have few changes beyond linear math option and code style changes.  Some attributes have been removed or rearranged - especially with the lcSkinShader, old posts with attribute descriptions may no longer apply.
lcLitSphere.cgfx is an implementation of matcap/lit sphere shading – just for fun and in case anyone is interested.
Pictures: (click for larger)
shaderCompare_A[1]

hairShaderComparison[1]
litSphereImage[1]

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

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):
ssscompare

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.

skinShaderAttr

August 19, 2010

lcHairShader.cgfx – Maya Realtime Hair Shader

Download: lcHairShader.cgfx (save as)
Updated:
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.
hairShader
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
lcHairShader
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)

July 30, 2010

Maya - Create a Cubemap

This is inspired from my participation on a recent Polycount thread.

Its pretty straight forward to make your own cubemaps from Maya, you just need 6 cameras rotated around a shared point. The cameras each render out a square image representing one of each side of the cube. You can easily stitch these images together using an interactive program like ATI's CubeMapGen for realtime use, or build out a cube-cross in Photoshop. You just have to take care as to the placement and rotation of the images in the stitch.

There is one trick to this in Maya; although its pretty intuitive to set the Angle of View of the cameras to 90 degrees, you also have to set the Camera Aperture x and y to 1.0.

You are not restricted to staying in the cubemap format either, just run the result through HDRShop and you can convert to a variety of other formats like latlong and angular probe.

Here is a test image from CubeMapGen showing that the cubemap is seamless (some minor blurring in the reflection of the sphere is actually due to the realtime shader in the viewport and not sampling issues in the textures).

cubemapgen

Download Test Scene (Z axis are inverted compared to Maya because thats what CubeMapGen expects)

July 8, 2010

lcNextGenShader_1.4.5.fx – Maya HLSL realtime shader

Note: Even with this update I still recommend my lcUberShader.cgfx over this; cgfx seems a bit more stable than hlsl in the Maya viewport and cgfx shaders can be rendered through the hardware render buffer too!

I noticed that the old lcNextGenShader_1.2.fx was getting alot of hits even with updated versions and the better cgfx shader available. So i decided to update it and make it easier to maintain.

Pretty much I took the code from my lcUberShader_1.4.cgfx and transplanted it into an HLSL shader. Its missing some things from the cgfx version, lit-sphere shading, toon-ramp shading and the skin shader are removed. They where not working and I don’t think its currently worth the effort to get them working. Everything else is identical to the cgfx version and is a robust general use shader. This OLD post gives some example images from the cgfx version - blog.leocov.com/2010/03/lcubershader12cgfx.html

I’m currently investigating cross compatibility with 3dsMax – so stay tuned Max users.

Download:
lcNextGenShader_1.4.5.fx