Saturday, 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.
http://developer.nvidia.com/object/texture_tools.html
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:
http://code.google.com/p/nvidia-texture-tools/wiki/CommandLineTools

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.

Saturday, February 20, 2010

lcRTShaderTools.mel

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)

Download:

lcRTShaderTools.zip

lcRTShaderTools

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.

Saturday, January 30, 2010

lcNextGenShader_1.3.fx

Download: lcNextGenShader_1.3.fx

Minor update addressing some order of operations issues to fix the way ambient color and ambient environment are applied and tweaks to default UI values.

Saturday, December 5, 2009

lcNextGenShader_1.2.fx

Download: lcNextGenShader_1.2.fx

Update includes the following changes/additions:

A skin style SSS approximation for soft skin rendering, and a gloss map input for changing the size/shape of the specular highlight, also the cube map reflections can be blurred based on specular glossiness. Extra – you can now choose to use Valve’s half lambert diffuse style instead of the standard lambert mode.

useHalfLambert – use Valve’s half lambert diffuse shading model – wraps light around forms more for a softer look, useful for backlighting situations

sssWeight - the overall intensity of the SSS effect

sssBack - Color of the SSS edge bleed effect

sssRadius - how far across the surface the SSS effect will bleed

useGlossMap - use a gloss map texture yes/no

glossBlurWeight - the overall amount of blurring to the env cube map reflections - 0 turns off the blurring effect

glossBlurMax - the specular glossiness value after which no blurring will happen - usefull for tweaking the blur amount based on your spec glossiness value

glossMap - the gloss map texture (darker values dont work very well here - black turn off specularity)

Thanks goes to Joel Styles – inspiration for the sss function - reading over your hlsl code makes for good learning

Wednesday, December 2, 2009

CG Bootcamp

Interested in Tutorials? I contribute many of the tutorials at www.cgbootcamp.com – we cover all kinds of topics in the 3D world – check it out.

Saturday, November 21, 2009

lcNextGenShader_1.15.fx

Download: lcNextGenShader_1.15.fx

Update to the shader includes:

Fresnel attributes (fresnel no longer hard coded and now affects both cubemap reflections and specularity)

frBias – changes how far across the surface the effect occurs

frETA – bumps up the intensity in the ‘center’ area

frPower – Power/intensity multiplier on the entire effect

Monday, November 16, 2009

lcNextGenShader.fx and lcHLSLTools.mel

Real-time HLSL Shader for Maya’s Viewport and HLSL helper Mel script.

lcNextGenShader_1.1.fx

Download: lcNextGenShader_1.1.fx

Sample Cube Map: default_env_map.dds

lcNextGenShader_example[1]

lcNextGenShader_interface

Techniques:

NextGen_SM3 – full shading (requires shader model 3 capable graphics card)

Diffuse_Texture_Only – only the diffuse texture or color, without any other effects

Normal_Map_As_Color – only the normal map color values (helps to find seams)

Specular_Only_SM3 – only the specular effects, light and specular map contributions (requires shader model 3 capable graphics)

Parameters:

backFaceLighting – for single sided polygon objects, the back sides will be lit correctly

ambientColor – a color ‘added’ on top of the final effect

diffuseColor – the Lambert diffuse shading color

specularColor – the Phong specular shading color

glossiness – controls the size of the Phong specular highlight

useDiffuseTexture – use the diffuse texture from ‘diffuseMap’ instead of diffuseColor

transparencyInDiffuse – use the diffuseMap’s alpha channel for transparency

specularInDiffuse – use the diffuseMap’s alpha channel for specular masking

diffuseMap – a diffuse texture

useNormalTexture – use a tangent space normal map texture

specularInNormal – use the normalMap’s alpha channel for specular masking

normalPower – intensity of the normal map effect, 0=no effect

flipGreen – invert the green channel of the normal map (default = true)

normalMap – a tangent space normal map texture

useSpecularMap – use a specularMap for specular coloring and masking

specularMap – a specular texture for highlight coloring and masking

useAmbEnv – use cubeEnvMap for ambient environment lighting – cube map is forced down in mip levels – make sure to use a cube map processed by ATI CubeMapGen for proper filtering

ambPower – intensity of the ambient environment lighting – also multiplied with the ambientColor

useReflEnv - use cubeEnvMap for environment reflections

reflPower – intensity of the environment reflections (has a slight hardcoded Fresnel effect)

cubeEnvMap – a cube map – preferably one processed by ATI CubeMapGen for proper filtering

useGlowTexture – use glowMap for self illumination effects

glowPower – the intensity of the self illumination effect

glowMap – a texture that is ‘added’ on top of the final shader result – self illumination/incandescence

useLightFalloff – use falloff on the point lights

decayScale – scale of the light falloff for the point lights

Note: There are some issues with overlapping transparency planes in Maya’s viewport when using realtime shaders – unfortunately this seems to be a problem with Maya and not the HLSL code itself – so there is no fix available.

Textures in TGA or DDS formats provide the best compatibly with the DirectX environment.

lcHLSLTools.mel

Download: lcHLSLTools.mel

Run with command – lcHLSLTools;

This makes it easier to work with my HLSL shaders – lets you name, create, and assign them – then make the lights and link them to the shader – you can adjust light color across all HLSL shaders – lastly you can reload all the HLSL shaders and File Texture Nodes

Any objects you have selected will be assigned the new shader when you press ‘Make New HLSL Shader’

lcHLSLTools

Note: This tool was designed to work specifically with my own HLSL shaders, and wont work with other .fx shaders because the light names and attributes have been hard coded.