- Home /
Any way to adjust vertical/horizontal fog density independently? (Unity 5)
Hello, I'm trying to create a forest scene with fog, but I want the vertical fog to be thicker than the horizontal fog, so that you can see some distance along the ground but when looking up the tops of the trees are obscured.
Is there any way to adjust the default fog (exponential squared in this case) so that the vertical density is higher than the horizontal density?
If not, can anyone recommend a way to add additional fog that gets thicker the further away it is from the ground?
Thanks.
Answer by 3danimation.pro · Aug 04, 2015 at 04:13 AM
attach this script to the camera it increases density when camera looks up , adjust the amplitude by Amplitude variable set minimum fog density by Min Amount variable
using UnityEngine;
using System.Collections;
public class fogcontrol : MonoBehaviour {
public float amplitude = 0.00001f;
public float minAmount = 0.001f;
// Update is called once per frame
void Update () {
if (transform.localRotation.eulerAngles.x > 90f ) {
RenderSettings.fogDensity = (-transform.localRotation.eulerAngles.x + 360) * amplitude + minAmount;
} else
{
RenderSettings.fogDensity = minAmount;
}
}
}
Your answer

Follow this Question
Related Questions
Reversing height fog 0 Answers
Change objects using script 1 Answer
animations controlling 1 Answer
AudioSource.PlayClipAtPoint creating unlimited AudioOneShot 1 Answer