1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. Unity 2017.1 beta is now available for download.
    Dismiss Notice
  5. Unity 5.6 is now released.
    Dismiss Notice
  6. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  8. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice

Combine Lights and Clamp intesity.

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

  1. IsGreen

    IsGreen

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

    [​IMG]

    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

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    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.