Fog shader for 3ds Max
After some silent months, I decided to pack up and release some of my 3ds max scripts and plugins. This is the first of the upcoming series of scripts. With this plugin, you can get a cool shading effect on your models to be able to see dents in smooth surfaces better. This is done by this fog shader. I’ve seen this functionality in a modelling tutorial in (I think) XSI softimage. This was actually stunned by this way of visualizing the model while modelling. It’s quite a clever way of seeing what’s going on from back to front. It’s hard to explain this without some kind of picture, so here’s a screenshot of the shader in use:
I made it really easy to install this plugin. I’ve made a self-installing script that can just be dropped in the viewport from a folder. To download it, click this link. Now the only thing you need to do is drag it in the viewport or run it through the ‘run script’ menu item. I only tested this script with max 2010, but it should work from 2008 up. If you notice any errors or odd behavior, please let me know, I’ll try to fix it.
How it works
This plugin works by applying a simple depth shader that shows the far point as white and the near point as black. I’m constantly updating the clipping ranges to sensible values based on the bounding box of the object that it is on. I didn’t want to make the values more precise, since that will have an impact on the speed of the viewport, which I particularly wanted to avoid.
The shader that’s applied will store the material that was assigned, so when the object is deselected, the proper material will be applied again.
The plugin installs the directx depth shader, a macroscript that will apply the effect, a script that runs on the background that will update the shader when it needs to be updated (no effect on speed of viewport if the effect is not in use) and there’s a script that will re-apply the old material when the object is deselected, which is usefull, you don’t have to worry about it at all, it will try to re-apply the material that was previously in use.
EDIT: Word of warning, it doesn’t go well with the new Nitrous renderer in 3ds max 2012