- Home /
why 3d text not affected by fog
I want my 3d text objects to be affected by the fog bug its not happening.
I've found a work around but I'm not pleased with it. is there a setting I'm missing or some way to make 3d text easily affected by fog (or get dimmer the farther away I get from it?)
Here's the shader I'm using (its custom made):
Shader "GUI/3D Text Shader" {
Properties { _MainTex ("Font Texture", 2D) = "white" {} _Color ("Text Color", Color) = (1,1,1,1) }
SubShader { Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } Lighting Off Cull Off ZWrite On Fog { Mode Off } Blend SrcAlpha OneMinusSrcAlpha Pass { Color [_Color] SetTexture [_MainTex] { combine primary, texture * primary } } } }
Ps I tried to change the "liting off culling off zwrite on fog {mode off}" to "...{mode on}" but that just made it not work at all.
Also, I found this code:
Fog { Color [_AddFog] }
I added it in under Tags and it didn't give an error, but it didn't change anything.
Answer by Eric5h5 · Jan 06, 2011 at 09:06 AM
Use a material with a shader that has fog in it; the default doesn't (obviously).
oh, well I made my own shader (actually copied). I edited my question to put the code in. is there a way I can modify it to have fog affect it?
Just change the fog mode from Off to something else. (On isn't a valid choice; look in the docs: http://unity3d.com/support/documentation/Components/SL-Fog.html)
Answer by 3dDude · Jan 06, 2011 at 07:58 PM
I dont know an shader code but it seems to me that it should be:
Shader "GUI/3D Text Shader" {
Properties { _MainTex ("Font Texture", 2D) = "white" {} _Color ("Text Color", Color) = (1,1,1,1) }
SubShader { Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } Lighting Off Cull Off ZWrite On Fog { Mode On } Blend SrcAlpha OneMinusSrcAlpha Pass { Color [_Color] SetTexture [_MainTex] { combine primary, texture * primary } } } }
Like I said before I don't really know that much about shaders but you can try that.
I tried it and unfortunately it didn't work at all - made all my 3d text pink and gave me an error. I'm looking through other shaders to see what it might be but I can't find any code that could help
Ok, yeah sorry about that. Like I said, I am not a good shader programer...
Answer by xilliah · Dec 13, 2011 at 09:48 AM
You're telling it to turn off with
Fog { Mode Off }
Tell it
Fog { Mode Global }
Global means it will take the settings from the global render settings described in the Unity editor, so of course you need to turn that on and set it to your liking. You can also override the global settings by entering your own settings inside of these brackets, as described at the link shared earlier.
Your answer
Follow this Question
Related Questions
Represent Land 3D Area End 0 Answers
Fog effect on shader 0 Answers
Unity 5 Fog not working on Standard Shader Objects 3 Answers
How can i get my quad to only render my texture without stretching it? 1 Answer
Fog of war depth-mask technique 0 Answers