Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Fixed fog, regardless of camera angle.

Discussion in 'General Graphics' started by QuigsBigSpecGames, Oct 5, 2023.

  1. QuigsBigSpecGames

    QuigsBigSpecGames

    Joined:
    Apr 20, 2019
    Posts:
    37
    Hi there,

    I would like to ask if I am on the right path here. I have been learning shaders and I have a pretty effective fog shader to use in a render feature using shader graph. I can control the fog start and finish inputs, which is great.

    The problem I am having is that when the camera changes angle, so does the fog and breaks my usage needs. From googling, what I need, I believe, is distance Fog, which does sound logical. Unfortunately, I am a bit stuck on how to set this up in shader graph.

    Currently, I am using the depth texture to lerp between colour and scene colour. I think this is the reason why my fog is stuck to the camera plain. Is it possible to adjust the angle when using the depth texture, or is it completely fixed to the camera view as that is what it is seeing?

    I’m just after a nudge in the right direction as this has stumped me.
     
  2. POOKSHANK

    POOKSHANK

    Joined:
    Feb 8, 2022
    Posts:
    73
    what you want is distance based fog, it will then form a sphere around the camera as opposed to being the distance of clipping planes
     
    QuigsBigSpecGames likes this.
  3. QuigsBigSpecGames

    QuigsBigSpecGames

    Joined:
    Apr 20, 2019
    Posts:
    37
    Hi, thanks for replying. Would this stand up to scrutiny where say a room is 10m?

    Do you know if it's possible to fix the start and endpoint to an xyz coordinates. So no matter where you went in the foom, the back wall would be fogged. I thought maybe custom box volumes?
     
  4. POOKSHANK

    POOKSHANK

    Joined:
    Feb 8, 2022
    Posts:
    73
    if you want that level of static you're either going volumetric or maybe abusing a particle system
     
  5. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    289
    Both suggestions of Pookshank are valid, depending on how your level is setup you might profit from Height fog as well (which is very similar to depth fog but based on world space coordinates). But none of the depth / height / coordinate only / coloring geometry that is already there based effect will be as flexible and convincing as volumes or particles
     
  6. QuigsBigSpecGames

    QuigsBigSpecGames

    Joined:
    Apr 20, 2019
    Posts:
    37
    Again, thanks for the advice. :)