Search Unity

Looking for a way to add ambient lighting based on worldposition

Discussion in 'Shaders' started by PhilippG, Apr 30, 2017.

  1. PhilippG

    PhilippG

    Joined:
    Jan 7, 2014
    Posts:
    257
    Hello!
    So I'm working on my spare time project and keep running into this problem:
    Basically I have rooms, and some of them should be lit, while others should be pitch black dark. For simplicity the rooms width, depth, height is perfectly aligned to the units grid.

    So what I am looking for is a way to have control over the rate any rendered pixel is affected by ambient lighting based on its world position - Area based ambient lighting

    I'm absolutely no shader person, but I hope someone can help me out. My best guess how to do this would be something like so:
    - Disable standard ambient lighting.
    - Add sort of screen space ambient lighting to the camera

    Now in the render pipeline:
    - grab the output before shadows are applied
    - I can supply a generated greyscale 3D-Texture (resolution would be one pixel per cubic unit)
    - bring both together to generate the "areal" ambient lighting
    - add the result to he output after shadows where applied.

    Is this even possible?
    This would really help me with my project :)

    Thank you :)
     
  2. UziMonkey

    UziMonkey

    Joined:
    Nov 7, 2012
    Posts:
    206
    Can't you just use light probes for this?
     
  3. PhilippG

    PhilippG

    Joined:
    Jan 7, 2014
    Posts:
    257
    I'd like to. However, levels would be procedurally generated, so I'm not sure its possible