- Home /
Fog Mode Off Functionality
I'm currently a bit flummoxed and am hoping you fine folks can be of some assistance. I've got a small scene setup and have implemented a day/night cycle with a sun and moon. My issue is that the moon is completely dark in the sky, even though it's using a Self-illuminated/Diffuse shader.
Through trial and error, I've discovered that the distant object is being affected by the Fog settings, so I've created an adjusted copy of the shader to include Fog { Mode Off }. Unfortunately, however, the moon is still dark in the sky unless Fog is disabled globally, which is far from an ideal solution.
If any of you can cast some light on why my moon isn't properly illuminating, it would be greatly appreciated. I'm not shader saavy yet, though I am looking into some tutorials, but from the research I've done, I expected the code below to work.
For your consideration, here is the customized shader code:
Shader "Custom/Moon Shader" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
_Illum ("Illumin (A)", 2D) = "white" {}
_EmissionLM ("Emission (Lightmapper)", Float) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Pass { Fog {Mode Off} }
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _Illum;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
float2 uv_Illum;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
fixed4 c = tex * _Color;
o.Albedo = c.rgb;
o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Self-Illumin/Diffuse"
}
Answer by Deadphyre · Apr 18, 2015 at 05:24 PM
try adding nofog to the pragma# line
Thanks Deadphyre, I appreciate that :) I've given it a shot, and the changes appears to be working, however it's difficult to tell for sure. The entire project looks & behaves a bit off-kilter now that I'm using Unity 5.