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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Ideas for reducing lighting and GI when going "Deeper" into fog.

Discussion in 'General Graphics' started by hoesterey, Sep 11, 2015.

  1. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Hi,
    I'm using a combination of particles and "Global Fog" to achieve flying into the gases of a gas planet effect. Any techniques for reducing the lighting effects as you go deeper into the fog people could think to use? I'm using a directional light when above the fog but need it to "fall off" as you go down (but not for objects above the fog as they should still be light brightly).

    Basically I need fog to reduce the effects of lighting and global illumination.

    Any way people can think to approach this problem?

    Thanks!
     
  2. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Another way to think about the problem I'm trying to solve would be to think of an underwater scene. I'm trying to get the sun light to effect objects less the deeper they are. (but still effect objects higher up at more intensity.) I'm not sure how to reduce the effects of a single light on an object without reducing the effects of all lights (e.g. a shader)

    Thanks,
    -Matt
     
  3. MattGen

    MattGen

    Joined:
    May 12, 2015
    Posts:
    63
    Create a script that changes your directionnal light settings when you're going away from a specific gamobject's transform.

    I'm not a dev so I can't write an exact code for that purpose, but it should be something like :


    You're welcome,
    -Matt :)
     
    Last edited: Sep 13, 2015
  4. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Heya Matt,
    Thanks for replying.

    Your solution is my backup plan but the thing is I'm trying to find a solution that does not involve changing the light intensity. The problem with changing the light settings is that objects above the cloud layer are also effected.

    E.g.
    Ship 1 - still above the clouds - lighting should stay the same
    Ship 2 - moving lower below the clouds - lighting on this ship should be getting darker.

    With the above if I change the light intensity going into the clouds would cause the things above the clouds to get lit different as well. Its sort of like being underwater but being able to still see out. The player and other characters that are going underwater should be getting darker but the objects outside of the water should be lit the same.

    I really need something like a directional light with falloff on just the y axis. Sort of a conundrum
     
  5. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    I may have found a solution that I originally tried but couldn't get working. Having a series of planes with semi-transparency so as objects pass through them they get darker.

    This didn't work originally though increasing the Shadow distance in the quality settings fixed that... I have no idea why as the camera distance should not be an issue in this case...the object get shadows just fine when they are being case from smaller objects (rather then huge planes)

    Shadow Distance The maximum distance from camera at which shadows will be visible. Shadows that fall beyond this distance will not be rendered.


    I have a feeling the above setting isn't' doing exactly what it says.
     
  6. NLongchamps

    NLongchamps

    Joined:
    Sep 9, 2014
    Posts:
    10
    It depends on how you're rendering the fog. And are you using a deferred or forward pipeline?
     
  7. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    I'm using deferred. Fog is a modification of the "Global Fog" standard asset.
     
  8. NLongchamps

    NLongchamps

    Joined:
    Sep 9, 2014
    Posts:
    10
    have you thought about using a command buffer to modify the lighting GBuffer?
     
  9. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    I had not. I've never used command buffers but will do some research on them. Thanks.