 Diffuse Map
 Normal Map
 Specular Reflection
 Diffuse & Specular
 Without Attenuation
 Complete Shader
|
|
LIGHT ATTENUATION SHADER
SPECS:
HARDWARE:
|
DirectX 9 or higher
|
TEXTURES:
|
- Diffuse Texture
- Normal Map Texture
- Specular Mask (diffuse alpha channel)
|
INPUTS:
|
- Ambient Color
- Diffuse Color
- Specular Power (shininess)
- Light Color
- Light Position
- Close Attenuation
- Medium Attenuation
- Far Attenuation
|
PASSES:
|
One
|
UPDATED:
|
11/26/05
|
DOWNLOAD: (right click and choose "save target as...")
Light Attenuation Shader
COMMENTS:
This shader has all of the features of the Normal Map Specular shader plus one additional feature that makes the point light look more convincing. It's called Attenuation.
The implementation of the point light in the Normal Map Specular shader is less realistic because the point light's brightness and intensity stays at 100% regardless of the distance from the light. In the real world, light spreads out and gets scattered as it travels further away from the source. The attenuation feature in this shader simulates this effect by dimming the brightness of the light based on distance.
You can see the results in the images on the left. The image labeled "Without Attenuation" shows that the whole surface is lit the same. The "Complete Shader" has the attentuation applied and you can see the the surface gets dimmer further away from the light source.
You can control the attentuation with three values included with the shader: close attenuation, medium attenuation, and far attenuation. These three numbers control the power of the light at close, medium, and far distances.
Normal Map compression is an option that you can use with this shader. Copy the red channel of your normal map to the alpha channel. Then delete the red and blue channels and save your normal map in DXT5 DDS format. Put your compressed normal map in the DXT5 Normal Map slot for the shader. Then choose "Compressed" as the technique instead of "complete."
Updates (11/26/05):
Vectors in world space to fix Max 8 lighting bug.
Adjusted attenuation so Max lights can use a standard multiplier.
Added option to flip the green channel in the normal map.
INSTRUCTIONS:
For instruction on how to apply this shader to your model in 3DS Max, read my tutorial - HLSL Shaders in 3DS Max.
For instruction on how to create normal maps for this shader, read my tutorial - Creating and Using Normal Maps.
If you'd like to use some of my textures with this shader instead of making your own, you can find them here.
ADDITIONAL:
If you have trouble getting this shader to work correctly in 3DS Max, send me an email. I'll see If I can help. Also, I'm an artist - not a programmer. If you are a programmer or know more about shaders than I do and you find something in this shader that is poorly written, broken, etc, I'd love to hear from you. I've mostly taught myself how these things work so if you have some pointers for me that would be great!!
Return to the list of Shaders
|