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.

Combine Lights and Clamp intesity.

Discussion in 'General Graphics' started by IsGreen, Apr 27, 2015.

  1. IsGreen


    Jan 17, 2014
    The scene has 4 identical spot lights, which produce the following effect:

    As shown in the image, the combination of lights produces areas with different intensity.

    Could limit the intensity?

    I thought about light probes. But work at runtime, can you change position/color, or the light intensity for different groups?.

    I've also thought of using a vertex color shader to create ambient light on the object, and change color, clamp intensity through its vertex color. Is there a shader like this?
    Last edited: Apr 27, 2015
  2. Zicandar


    Feb 10, 2014
    The old (pre Unity5) deferred would in theory have the capability to clamp the intensity of lights after they have been added up. ( I think command buffers might give easy acess to doing this, but if your relying on the standard shader I'm not sure that the result will be worth it due to limiations for the old deferred).
    The current deferred could be used to do a single full-screen pass with all the lights you want to calculate, and that would allow clamping. (Or if you want them to only be clamped within a group you can optimize by combining and sending in bounding objects to limit the amount of pixels you calculate them for.)
    The current deferred could also be used (with command buffers), to write out all your lights to 2 buffers, 1 for spec strength, 1 for diffuse, (both need RGB), then clamp your lights, then multiply with the spec color and the diffuse color when combining it back in, more or less the same as unity's old deferred with the difference of not needing double geometry passes in exchange for a bunch of extra bandwidth/memory needed for 2 floating point buffers! (6 halfs would likely be needed!...)
    The only other way I can think of would require all lights you want to be clamped together to be sent in a single pass.
    (Vertex lit sends 8 lights in 1 pass I belive, in theory that info could be read in a pixel shader).
    Or instead of a single pass a tiled/clusterd approach could work.
    Or extra per-renderer data that is used in the ForwardBase pass.
    There are quite a few options for this in unity 5, none of them obvious.