Search Unity

Fog clipping?

Discussion in 'Scripting' started by yaakovyitzchakbenmoshe, Jun 18, 2021.

  1. yaakovyitzchakbenmoshe

    yaakovyitzchakbenmoshe

    Joined:
    Feb 9, 2018
    Posts:
    21
    B"H
    This would seem rather simple but I'm trying to do fog in unity to cut out the distance items, and



    Settings (from Javascript but same idea, left commented out portions for context, Achdus is part of the library, main point is the clipping plane)


    Code (JavaScript):
    1. UnityEngine.RenderSettings.fog = true
    2. //UnityEngine.RenderSettings.fogMode = UnityEngine.FogMode.Linear
    3. UnityEngine.RenderSettings.fogColor = new UnityEngine.Color(0.2,0.2,0.2)
    4. UnityEngine.RenderSettings.fogMode = UnityEngine.FogMode.ExponentialSquared
    5. //UnityEngine.RenderSettings.fogMode = UnityEngine.FogMode.Exponential
    6. UnityEngine.RenderSettings.fogStartDistance = 40
    7. UnityEngine.RenderSettings.fogEndDistance = 79
    8. UnityEngine.RenderSettings.fogDensity = .05
    9. UnityEngine.Camera.main.farClipPlane =
    10. Achdus.Yaakov.mainCoby.shneeuh.farClipPlan = 120

    It would seem like it should be a simple feature to cut out the fog in the distance?
    Tried using kinofog
    but I got these errors (after applying cubemap texture to camera)




    How can I clip out distant objects such that the clipping isn't so sharp, and the intensity of the fog isn't cutting it out?