February 27, 2010

save a .DDS from Photoshop

I am particular to command line tools and Nvidia offers us a nice and simple tool for .DDS compression.
Its super fast and runs on the GPU through CUDA (although that means you need the proper hardware and drivers)

nvcompress.exe is the particular tool I’m looking at here but there are a few other cool utilities included too.

You can get direct and simple access to the tool through Photoshop by running some simple scripts.

Some Examples:
for color > DXT5:  DDS_DXT5_c.js
for normals > DXT5:  DDS_DXT5_n.js

How to Install:
put the *.js files here /Adobe Photoshop CS*/Presets/Scripts
run from File > Scripts menu
(you must have nvcompress.exe’s filepath in your PATH Environment Variable or this wont work out of the box)

How it Works:
It saves a temporary copy of the currently selected Photoshop document to a .tga
It creates temporary .bat script containing the command line arguments for nvcompress.exe
Runs the .bat script on the temporary .tga and spits out a new file into the same folder as your original document (with the ‘filename’_DXT5.dds naming convention)

These scripts are very easy to edit, and can be made to run multiple compressions in sequence.

Documentation and command line arguments are available here:

Take it – run with it.

Special thanks to Fredrik Brännbacka who posted Save As Map.js on CGTalk a few years ago – from which this script is directly based.

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.