March 12, 2010

lcUberShader_1.2.cgfx

Goals:
1. Create a useful Maya viewport shader with many interesting functions and techniques to showcase a wide range of surfaces.
2. Write a Shader with a compartmentalized structure that is easy to read and dissect for people learning the basics of shader code.

This shader is quite large and complex and because of the decision to compartmentalize much of the code into distinct functions it is not performace optimized.

You must link 1-3 directional lights into the light slots at the bottom of the attribute list – I would recommend you use my lcRTShaderTools.mel to interact with the shader.

Download:
lcUberShader_1.2.cgfx
lcBasicShaderComponents.cgfx (this is a basic stub shader for people learing cgfx and wanting something simpler to start out)
BasicTextures.zip
(some basic textures for use with the lcUberShader – don’t quite remember where they all came from – thank you to the original creators)

Known Issues:
* Although I provide 8-bit alpha support, Maya has transparency sorting issues when in this mode.
* Because there are so many attributes the Maya Attribute Editor can sometimes momentarily stall when updating/opening or switching techniques
* Only 1 input is available for an environment cubemap (this serves for both reflections and ambient color) – the shader assumes this cubemap is a properly filtered cubemap made with ATI’s CubeMapGen tool and that it has mipmaps
* When you are in Toon or LitSphere Techinques the shading color will be multiplyed by the Diffuse Texture, you can scale the contribution of the Diffuse Texture with the Diffuse Color Attr – but you cannot tint it.
* Cubemap and Hemispherical ambient color is multiplied by the Ambient Color Attr, it must be something other than black for those effects to show up.

Examples of the Shading Techniques and Options (click for full res)
lcUberShader_sphereLineup 
(click for full res)
lcUberShader_attributes

Please use this as inspiration for writing your own shaders, the code is very easy to take apart, rearrange and unfold. I have tried to comment the code in key places of interest. I also included a more basic shader with the same coding structure as a starting point for people interested in learing.

2 comments:

  1. Hey LEO Awesome!! WoW!! Huge list of Attributes..
    I'm learning RSL....But,This shader will help me to learn CGFX too...Thanks a lot for sharing.

    ReplyDelete
  2. Thanks a bunch for releasing code!

    ReplyDelete