- Home /
Fog effect on shader
Hello !
I was wondering if it was possible to add fog to texture rendering shaders? This example of a shader which I want it to be affected by fog (enabled in Lighting Settings).
I do know how to add fog in classical vertex color shader (v2f) adding the following lines : - #pragma multi_compile_fog - UNITY_FOG_COORDS(1) - UNITY_TRANSFER_FOG(o,o.pos); - UNITY_APPLY_FOG(i.fogCoord, i.color);
But I don't know if these lines can be used in shaders like this one :
Shader "Alpha" { Properties { _MainTex ("Main Texture", 2D) = "white" {} _Mask ("Mask Texture", 2D) = "white" {} _ColorMult ("Color Multiplier", Color) = (1, 1, 1, 1) }
SubShader
{
Tags { "RenderType" = "Opaque" "Queue" = "Geometry" }
Pass {
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform sampler2D _Mask;
uniform float4 _ColorMult;
half4 frag(v2f_img i) : COLOR
{
return half4(tex2D(_MainTex,i.uv).rgb, tex2D(_Mask, i.uv).r) * _ColorMult;
}
ENDCG
}
}
Fallback "Diffuse"
}
Is it possible to get this shader affected by the fog light ? v2f_img is needed but not compatible with shader fog lines I wrote... Any tips on how I can get this shader work with fog ? Sorry I'm new with shaderlab.
Thanks, MayIAsk.
Your answer
Follow this Question
Related Questions
How can i get my quad to only render my texture without stretching it? 1 Answer
Unity - Simple Water 3 Answers
Transparent gaseous/foggy sphere 0 Answers
Fade Shader emit background color 0 Answers
How to apply ToonShader? 0 Answers