Search Unity

Ambient Lighting volume

Discussion in 'General Graphics' started by pointcache, Feb 27, 2019.

  1. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    579
    Such a simple thing.
    Overrides lighting of a box area, so that you can control it indoors.
    Did it really never occurred to anyone?
     
    joaobsneto likes this.
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,634
    Fog areas would be nice too. That's something I would like.

    These things would be fairly easy to program, though. The Render settings are exposed in the API:
    https://docs.unity3d.com/ScriptReference/RenderSettings.html
    You could make some sort of object (Scriptable Object, maybe?) called RenderSettingsProfile that has all of these fields duplicated and use it to store or set the RenderSettings values when ever the player enters a trigger collider.

    It would be cool if the RenderSettingsProfile was an official thing though, similar to what they did with the post processing stack, and then you could also save and load settings as assets in to the lighting window.
     
  3. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    579
    That should be done on shader level with blending. Imagine walking into a building and looking outside where everything is suddenly dark.
     
  4. joaobsneto

    joaobsneto

    Joined:
    Dec 10, 2009
    Posts:
    152
    I would like to know if it's possible too.
     
  5. joaobsneto

    joaobsneto

    Joined:
    Dec 10, 2009
    Posts:
    152
    Maybe use the exposure in post processing volume?
     
  6. archo5dev

    archo5dev

    Joined:
    Oct 25, 2018
    Posts:
    2
  7. Moe_Baker

    Moe_Baker

    Joined:
    Oct 22, 2017
    Posts:
    36
    Sorry for reviving an old post, but it's one of the only results when searching about this feature.
    I needed this feature but couldn't find any resources, so I implemented it myself in URP and would like to share it with anyone in need.

    [Effect Preview]

    The effect is implemented via a custom shader named the "Cardinal" shader. it's all implemented using Shadergraph via sub-graphs and an HLSL file so it will be fairly easy to copy to your custom shaders should you need to.
    The effect modifies the fragment process, working on individual pixels, so it gives decent results, enough for me for sure.
    It uses structured buffers so it requires shader model 4.5 / ES 3.1.
    The volumes are all boxes, my game is based on box-like rooms so it fits my needs well, but you can implement spheres and other shapes relatively quickly if needed.

    I'm not very familiar with shader/graphic code so if you spot any optimizations or tips please let me know.

    Cheers.
     

    Attached Files: