I am writing a volumetric fog shader, following the techniques listed below:
- http://http.download.nvidia.com/developer/SDK/Individual_Samples/DEMOS/Direct3D9/src/FogPolygonVolumes3/docs/FogPolygonVolumes3.pdf
- news
I looked at the Unity Replacement Shaders example and wrote a script which renders two depth textures, one for rear and one for front faces of meshes in a certain mask. From here, I have a post-processing shader which renders the fog on top of the image. I have no implemented any of the complex cases yet, only the first thickness calculation. Unfortuantely, my results are throwing me for a loop.
I have two depth textures and am subtracting the front depths from the rear depths and displaying this difference as a fog overlay for the pixel. This seems to give a decent result, so long as I do not move toward/away from the object. Moving towards/away from the object changes the thickness, which is very unexpected. I’ve attached the scene.
1122284–42357–$FogScene.unitypackage (48.4 KB)