Question by
CraftyMaelyss · Mar 06, 2017 at 06:03 AM ·
camerarenderfog
How do I make a specific object visible through Fog?
So I've completed 2 guides on how to create a fog script to render fog on and off for separate cameras and creating a separate layer to assign light sources to so they appear over the fog.
Now my problem lies with my moon and stars in the game as they're still hidden by the fog, even with the mentioned methods.
This is he script I used for the fog render:
using UnityEngine; [RequireComponent( typeof( Camera ) )] public class CameraFogSetting : MonoBehaviour { [SerializeField] bool enableFog = true;
bool previousFogState;
void OnPreRender()
{
previousFogState = RenderSettings.fog;
RenderSettings.fog = enableFog;
}
void OnPostRender()
{
RenderSettings.fog = previousFogState;
}
}
And here's the moon:
If I assign it to the second layer, it vanishes all together. Any and all advice is greatly appreciated :)
Due to this being part of an upcoming game, I cannot upload or share any models or parts of the game, sorry :(
6-march-2017fog-moon.png
(288.5 kB)
Comment