x


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?

more ▼

asked Feb 12 '10 at 06:30 PM

Ehren gravatar image

Ehren
4.2k 34 43 77

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Feb 12 '10 at 06:32 PM

Ehren gravatar image

Ehren
4.2k 34 43 77

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1664
x86
x56

asked: Feb 12 '10 at 06:30 PM

Seen: 2201 times

Last Updated: Feb 12 '10 at 06:30 PM