- Home /
How do I create a light that emits darkness?
Kinda strange I know and I have been searching for a couple days trying to find not only an answer but a better way of asking the question. Basically I want to be able to take a harshly lit environment and stick a point light into it but instead of adding light to the are I want the new light to add darkness. I tried looking for answers under the topic of inverted light sources and shadows etc and even tried to implement a projector but it is just not the effect I am looking for. I remember some time ago having the ability to move the brightness setting on a light into the negative range and it produced an effect similar to what I am looking for but that ability no longer exists (and may have been a glitch when I did it). Any help or direction would be greatly appreciated.
I am not sure, but perhaps you can use a light and set its color to black. Tell me if that works :D
Black means no light contribution, since it's additive and black is complete zero. He must use negative color for this purpose. This only works from code and only in Deferred.
Dr. Evil : "I will create a light that emits... DAR$$anonymous$$NESS!" (pinky-finger to corner of mouth) "$$anonymous$$uahahaha."
This sounds like a trick question... I must have missed something in high school
Dubstep, tried a "black light" first but all that does is negate the brightness level of the light it seems. and highpockets, I dont think you missed anything in highschool but the additive nature of the unity lighting environment seems to indicate that I cannot create a "light suck" to remove light, but emiting darkness I think might be doable
You need a custom CG shader; that's the long and the short of it. I can't help you writing that shader, but you can find examples of shader code that simulates a point light when there is no real light in the scene, once you have that working it shouldn't be too hard to make it do the opposite.
Answer by petersvp · Oct 23, 2016 at 02:53 PM
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.
#if UNITY_EDITOR
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;
}
}
#endif
Wouldent it be better to set the new light at startup and not in update?
I've altered the original script to #ifdef it completely. Since it's indeed an editor script, you want it to work in Update. Editor scripts does not execute all over the time, like in-game scripts. And since this script alters Light's color be Light Reference, removing it keeps the light's color as set up
This looks like it's exactly what I was looking for. Thank you
Answer by Stratosphere_Studios · Mar 08, 2014 at 07:28 PM
If you want a dark scene, like one in Slender, then I suggest going into Edit > Render Settings and tick fog, change the density to a higher value, change it's colours to almost pitch black and then remove any light sources in the scene. By doing that you can get a dark looking scene. For a light that emits darkness, it's impossible as far as I know.