February 20, 2010


Maya Real Time Shader Tools Mel Script

I've been developing a mel script to make it easier to create/assign/interact with hlsl and cgfx shaders in maya. Linking lights, changing light colors, making sure you have the correct .mll's loaded - providing an easier interface for managing lights.

I made this originally for my fellow production artists at work - so they would actually use the CGFX/HLSL shaders that mimic our game engine - because otherwise its a bit complicated to set them up (artists are picky and fickle I know!)

It should work with any CGFX or HLSL shader as long as certain conditions are met, these are: light attribute names should be as follows - 'light1Dir' or 'light1Pos' and 'light1Color' ambient color/light attribute on the shader should be - 'ambientColor' (why no light intensity? light color value can easily be overdriven to accomplish the same thing)

Works with up to 3 directional or point lights (mix and match)




Sample Shaders for testing:

lcBasicShader.cgfx - this is a testing/stub shader written in CGFX
lcNextGenShader_1.3.fx - more interesting shader written in HLSL

I've done as much testing as I can reasonable stand on this script - I don't make any promises but myself and my fellow artists have found it helpful.

Eventualy I'll get around to translating my HLSL shaders to CGFX and adding fancy features. If you like writing mel scripts please feel free to use this script as a starting point or inspiration.

No comments:

Post a Comment