Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Is black light possible in unity?

Discussion in 'Editor & General Support' started by 2dfxman, Jun 8, 2011.

  1. 2dfxman

    2dfxman

    Joined:
    Oct 1, 2010
    Posts:
    178
    In some rendering engines you can change light intensity to negative value and what this does is instead of producing light, it sucks light in.
    For example you have a scene lit with lights but then you put one negative light and it will create a dark spot without having to toggle or change intensity of other lights. This effect can create some very interesting gameplay.
    I don't have unity on me right now so I can't test it and just wanted to ask if such light could be possible in unity?

    Thanks
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    thats not possible with inbuilt lights but you could use a projector and project black for example.

    alternatively you could try to create own lights but that would either require that you work with vertex lights (available in pro and free) or that you potentially go with deferred and fullscreen render effects to do it efficientely (Pro only)
     
  3. 2dfxman

    2dfxman

    Joined:
    Oct 1, 2010
    Posts:
    178
    I am already usig deferred and pixel lights, so that's not a problem.
    But why would I need a fullscreen render effect for this?
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Well you would not need it.
    But what you will need to write are own lights, the inbuilt ones have no negative light and unless you want to change the lighting equation calcs on all your shaders the way that > 128 = additive and < 128 = negative I doubt the inbuilt lights are going to work as a base to start off from
     
  5. KAKE

    KAKE

    Joined:
    Apr 5, 2005
    Posts:
    57
    2dfxman, where you able to get this working? I need to create a similar effect and I've never written my own light code before.
     
  6. Selenthe

    Selenthe

    Joined:
    Dec 31, 2013
    Posts:
    1
    One when I was making an animation for a light, I accidentally dragged the intensity into the negatives and it became a really good 'anti-light' but I haven't been able to reproduce the effect since.
     
  7. petersvp

    petersvp

    Joined:
    Dec 20, 2013
    Posts:
    63
    In Deferred Lighting mode, you can hack the light's color to be negative. Since the built-in color selector is clamped to normalized colors, you cannot use it. You can set negative colors from code, like, `l.color = new Color(-0.4f, -0.4f, -0.4f, 1);` or just use the following script and attach it to a light, then hack as you like.

    Code (CSharp):
    1.     using UnityEngine;
    2.  
    3.     [ExecuteInEditMode]
    4.     [RequireComponent(typeof(Light))]
    5.     public class HackedLight : MonoBehaviour {
    6.  
    7.         public Vector4 hackColor;
    8.         public float multiplier = 1;
    9.  
    10.        void Update ()
    11.         {
    12.             var light = GetComponent<Light>();
    13.             light.color = new Color(hackColor.x, hackColor.y, hackColor.z, hackColor.w) * multiplier;
    14.         }
    15.     }


     
  8. yoshav

    yoshav

    Joined:
    Mar 16, 2017
    Posts:
    1
    I've come across this post in multiple threads and tried to apply it but I didn't get it to work. Is it still possible in the current version of the engine? (I put my main camera on Deferred, applied the script to my light and set negative color values for it).

    Edit: It does work to achieve higher brightness however.
     
    Last edited: Mar 16, 2017