Creating a fogless version of a built-in shader

There are situations (such as simulating a skybox to avoid the six draw calls associated with a real one) where fog needs to be applied to some game objects in a scene but not others. Is there a simple way to disable fog on one of the built-in shaders?

Here's one way to create a fogless version of a shader.

  1. Download the source code for the built-in Unity shaders.

  2. Open the .shader file for the shader you want to modify. Copy the contents.

  3. Create a new shader in your project (Assets->Create->Shader). Open it for editing.

  4. Copy the contents of the built-in shader into your new shader file, overwriting the default contents.

  5. Rename the shader. For example, if you are de-fogging the diffuse shader, change the first line from `Shader "Diffuse"` to something like `Shader "Diffuse Fogless"`.

  6. Find the line which controls the fog. Most likely it will say `Fog { Color [_AddFog] }`. Change it to `Fog { Mode Off }`.

  7. Save your custom .shader file. Now you should be able to select your shader from the drop-down attached to any Material.