- Home /
Negative Lights
This question has been asked occasionally over the years but no real solution given. Is it possible for lights to have a negative value and be used to darken areas? Even if it's just for the purpose of lightmapping it would be useful...Thanks!
Answer by petersvp · Oct 23, 2016 at 02:54 PM
if Deferred Lighting mode only, 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.
using UnityEngine;
[ExecuteInEditMode]
[RequireComponent(typeof(Light))]
public class HackedLight : MonoBehaviour {
public Vector4 hackColor;
public float multiplier = 1;
void Update ()
{
var light = GetComponent<Light>();
light.color = new Color(hackColor.x, hackColor.y, hackColor.z, hackColor.w) * multiplier;
}
}
is this technique going to work in the latest Unity 5.4 or 5.5 beta? I tried it but it doesn't seem to work. Even though I put negative values to the color, the light has no effect at all.
$$anonymous$$ake sure you are using Deferred Lighting mode in your $$anonymous$$ain camera.
Well, if you've only got a single point light in the scene, it's not going to have an effect. You can't subtract light when there's no other light source giving light from which to take away...
I have directional light in the scene too. I even created a bunch of extra lights just in case to see if that would be a problem, but nope, that's not it.
Answer by gkepets · Feb 22, 2015 at 03:06 PM
make a light and the color of the light black, or a dark color.
This is not how it works. A black light is the exact same thing as no light.
Black light means no light. The light color must be negative.