Pages

Showing posts with label hlsl. Show all posts
Showing posts with label hlsl. Show all posts

October 27, 2011

Getting close . . .

My new shader ‘lcShader’ is almost feature complete.  It’s a very close approximation to the Mental Ray mia_material, but in real-time.  In testing I’m able to get very realistic looking materials using a standard texture workflow (diffuse, spec, gloss, cubemap).  Again, HLSL and CGFX versions will be identical, running the same exact code.  Lights react much nicer than previous shaders and have realistic fall-off.  And baked shadow maps too.

My shadow map baking script is also nearing completion, it will automatically link raytrace-baked shadow maps to the shader for linked lights and supports transparency in both the shader surface and the shadow cast.

Here is a quick screen grab, HLSL on the left, CGFX on the right.  They don’t have the exact same shader settings so some slight differences

September 17, 2011

New Shader Tools Update

I did some proof of concept work on the new shader and everything looks very positive.  In order to broaden compatibility support I’m co-developing a CGFX and HLSL shader.  They share most of their code by using #include files and are visually identical.  This way people with AMD cards etc. wont be complete out of luck, although Shader Model 3.0 support will always be required.

Here is a quick screen grab, on the left is HLSL on the right CGFX.

lcShader_wip_pinecone_01

Still a long way to go before the shader is feature complete, and the new pyMel UI is another matter. 

This is a great time for Feature Requests, I have a ton of things planned, but I’m always open to suggestions.

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]

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

March 12, 2010

lcRTShaderTools.mel v1.2

This script makes it easier to interact with HLSL and CGFX shaders in Maya.  It performs shader naming, creation/sourcing, light linking, and other helpful tasks.

This update adds light rig scaling – depending on how a hlsl or cgfx shader is coded, scaling your lights can result in incorrect lighting.  The ‘Light Rig Scale’ attribute moves the lights and scales their locator handles to give the visual impression of a ‘scale’ operation.  (you can Ctrl+MiddleClick and horizontal drag this box to interactively scale).

Known Issues:
CGFX and HLSL shaders will only work with this script if their light position/direction and light color attributes are named properly in the shader file.
Convention: light attribute names should be as follows - 'light1Dir' or 'light1Pos' and 'light1Color'
ambient color/light attribute on the shader should be – 'ambientColor'

Download:
lcRTShaderTools.zip (includes shelf icon)

lcRTShaderTools

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.

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

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.