Hello everybody!
I'm working on a game for school right now which is highly dependent on selective lighting, and we have come to the point to where the lighting solution we're using is too expensive, and our levels are suffering for it. I don't have that much experience in the Unity engine, but what we have now is a series of white point lights that spawn from the player's location and ricochet off of the environment, dynamically lighting the scene over time, and eventually fading out.
Frankly, this looks pretty bad, and we're trying to think of alternatives to this (shaders, particles, etc.) that would be more viable. We're also trying to find a way to temporarily highlight objects in a subtle way when they are hit with this light. Do any of you have ideas or have worked with something like this before?
Replies
try to keep the quality of your shadows quite low, take a look at most AAA titles, you'll notice upon closer inspection that their dynamic shadows are actually never that high-quality. Have you baked any static lighting in your scene or is it still running dynamically? remember not to use too many lights at once for dynamic, and for interior, there is very little reason to use dynamic lighting except on characters.
As for detecting when the light contacts. Assuming you have the light parented to a prefab, you could try adding this script to the object you want to highlight (sorry, i'm a javascript guy, if you use cs i'll bet you'll know how to translate it):
//variables for distance checking
var object : GameObject;
var light : GameObject;
var triggerdistance : float = 2;
//variables for material swapping
var material1 : Material;
var material2 : Material;
//check the distance between your objects
function FixedUpdate()
{
if (Vector3.Distance (light.position, object.position) < triggerDistance)
{
//you can do a material swap here on your "object".
//do it however you want
//i do it like this
object.renderer.sharedMaterial = material2;
}
else
{
object.renderer.sharedMaterial = material2;
}
}
//you may like to set up a GUI to check the proximity is working
function OnGUI()
{
var theRect : Rect = Rect(32,32,800,64);
GUI.Label(theRect, "testing distance-check is working. \nInfo: Current Proximity = "+ Vector3.Distance (light.position, object.position) .ToString() +" ( Within range! )" );
}
//I haven't tested this, hope it works for ya