x


Optimizing framerate on lots of billboards

I have a scene with lots of billboards (10.000+). There is occlusion- and per-layer culling going on. When most of the billboards are in view frustum the frame rate is about 30FPS. I am wondering why the frame rate remains low when the cam isn´t moving. What would be an appropiate method to let the scripts fall asleep if the cam is not turned?

Currently I am using LateUpdate() and if (renderer.isVisible). Here the code:


using UnityEngine; using System.Collections;

public class CameraFacingBillboard_up : MonoBehaviour { public Camera m_Camera;

void LateUpdate()
{
    if (renderer.isVisible)
    transform.LookAt(transform.position + m_Camera.transform.rotation * Vector3.back,
    m_Camera.transform.rotation * Vector3.up);
}

}

Any other hints? Thx heaps

more ▼

asked Dec 21 '11 at 06:20 AM

KK gravatar image

KK
78 9 9 12

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

How many draw calls are being made when you are seeing the 30FPS? (You can see them by turning on the Stats in the Game window of the editor)

My guess is that your low frame rate isn't related to script processing but rather GUI processing. One way to improve that performance is to reduce the number of draw calls being made by combining meshes and combining materials. Using static batching may be an option if your billboards are repeating a lot of the same static textures.

I'm far from an expert on this aspect of Unity, but this will hopefully help as a starting point. :)

more ▼

answered Dec 21 '11 at 05:01 PM

Aleron gravatar image

Aleron
166 5 7 8

You wouldn't be able to use static batching for billboards; the point of static batching is that the objects don't move.

Dec 21 '11 at 06:19 PM Eric5h5

Thanks Aleron for the reply. Of course I have a huge amount of Draw Calls (5000+ @ 30FPS) but the profiler points out an issue with the scripts... @Eric, thats what I have been wondering about as well. I will comment your answer beneath.

Dec 22 '11 at 12:17 PM KK
(comments are locked)
10|3000 characters needed characters left

Having 10K LateUpdate calls on 10K objects is a massive amount of overhead. You should use something more specific to this sort of thing like a particle system.

more ▼

answered Dec 21 '11 at 06:18 PM

Eric5h5 gravatar image

Eric5h5
81.5k 42 133 529

Mmh... A particle system? My billboards are widely spread over a big area. They get culled by frustum and occlusion but there are still a lot visible at any point. I thought about to static batch them in distance and when you move closer they get individual. Could that work?

Dec 22 '11 at 12:22 PM KK

No, as I mentioned in the other answer, static batching only works on objects that don't move (rotating to face the camera is movement). What you're talking about sounds similar to the tree system, which isn't done with individual objects. It's not a particle system, but it's somewhat similar in concept.

Dec 22 '11 at 12:40 PM Eric5h5

I highly recomend SpriteManager or similar which combines billboards/sprites with their textures (merged into one texture atlas) to one object. Thx for the pointers! reg

Jan 19 '12 at 02:21 PM KK

@Jango do you know of any examples that demonstrate how to achieve this? Cheers for the tips!

Feb 26 '12 at 05:52 PM numberkruncher
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x491
x185
x11

asked: Dec 21 '11 at 06:20 AM

Seen: 1073 times

Last Updated: Feb 26 '12 at 05:52 PM