- Home /
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?
Answer by Ehren · Feb 12, 2010 at 06:32 PM
Here's one way to create a fogless version of a shader.
Download the source code for the built-in Unity shaders.
Open the .shader file for the shader you want to modify. Copy the contents.
Create a new shader in your project (Assets->Create->Shader). Open it for editing.
Copy the contents of the built-in shader into your new shader file, overwriting the default contents.
Rename the shader. For example, if you are de-fogging the diffuse shader, change the first line from
Shader "Diffuse"
to something likeShader "Diffuse Fogless"
.Find the line which controls the fog. Most likely it will say
Fog { Color [_AddFog] }
. Change it toFog { Mode Off }
.Save your custom .shader file. Now you should be able to select your shader from the drop-down attached to any Material.
Your answer
Follow this Question
Related Questions
Building a Custom Shader 1 Answer
How to enable Fog in vertex bending shader? 2 Answers
Mirror + Shadows shader. 5 Answers
Toon Shader for the iPhone 1 Answer
RimLight Shader 0 Answers