Lights in Scene reduce farms per Second(FPS)
Hi Everyone
I am working on a project(game) in which police cars are involved therefore I have created car models and for a realistic effect I have used blue and red area(baked only) lights but my scene involve about 30 cars with mean 60 these type of lights are going to be used but when I only used 6 cars which mean 12 lights and my FPS dropped to 3. I am using this area light because other lights make batches high and FPS low. I am using Realistic car control kit and Smart AI kit in this game. I am using one script that is activating red and blue light Randomly.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BuleLightRoatatingScript : MonoBehaviour {
public GameObject buleLight;
public GameObject RedLight;
public int rendomNum;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
rendomNum = Random.Range(0, 2);
if(rendomNum == 0)
{
buleLight.SetActive(true);
RedLight.SetActive(false);
}else if(rendomNum == 1)
{
buleLight.SetActive(false);
RedLight.SetActive(true);
}
// transform.Rotate(0, -300 * Time.deltaTime, 0);
}
}
now is there any way that I can use 60 lights in one scene without FPS drop and for android FPS has to be 30 to 40 and if not that how many max lights can I used in one scene
thanks in Advance
if your lights are need only you shouldn't have any problems. but since you're toggling them you're probably using them realtime. lights are expensive, if you must use a lot mark them all not important which makes them vertex lights, not pixel lights. use layers to only illu$$anonymous$$ate what's relevant. since you're on android you're probably using forward rendering mode which means every object effected by light gets a draw cell per light. there's no way in telling how many lights your scene can handle since it depends on light ranges, object counts, vertex or pixel lights
You're right. He/she shouldn't use Realtime lighting. Use baked or mixed lighting.
Sorry, but I don't know. The only possible way for me to help is if I had a closer look at your project.
Thanks for this early reply @hexagonius and @Coleclaw199 but I am using baked only light mean area baked only light but still facing FPS issue when I have 5 cars in my scene which mean 10 lights so FPS are 10-15 but when 6th car is enabled fps dropped :( don't know what to do??
Answer by AurimasBlazulionis · Mar 24, 2017 at 10:28 AM
1) You can not use area lights on moving objects.
2) Lower pixel light count in the quality settings
3) Make sure shadow casting is disabled on these lights.
4) Switch to emissive materials if the above is not the case.
5) If you really need lights force deferred shading. This will increase CPU usage, though.