Are there any other ways of disabling fog from a specific object using scripts? I tried using Fog {Mode Off} for my shader but with no luck and since I’m using a decent amount of shaders I would rather just script it if possible. Does anyone know if there’s another way to do this?
A workaround could be to render this object with a new camera, this new camera only render this object which is based on a specific layer. Then you can disable fog on this camera with OnPreRender and OnPostRender functions: http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnPreRender.html
Actually I am using a second camera to display 3d objects on the Gui. I did try this but with no luck. I’m guessing because the first camera still displays fog that the object will not ignore the fog. I’m guessing the objects might need to be set to a specific layer so that both Cameras know to ignore the fog for a specific object?
Maybe you can try this:
- Main camera (change Culling Mask to don’t render this object on this camera)
- New camera (change Culling Mask to only render this object and set Clear Flags to Depth Only)
- Put a higher Depth value on new camera
This is how I had my system setup. I did mess with some masking and layers but still no luck
AFAIK fog is controlled via the shader (there is a tag for it). So you could duplicate whatever shader you’re using and turn off fog and apply it to only those objects.
Is there a wiki for the current unity shaders? Not sure if you’re able to access them. Also I have tried with my own shaders to use Fog {Mode Off} but it just isn’t working for some reason.
http://unity3d.com/unity/download/archive
It certainly works if done right. http://answers.unity3d.com/questions/25025/excluding-objects-from-fog.html
–Eric