Hi,
we are currently porting our bomberman-style game from Truevision3D to Unity. Our scene consists of tiled objects (blocks, floor tiles, etc) - we build our map at runtime via instantiating prefabs. Unfortunatly the framerate is dropping pretty low (around 16 FPS in the editor, around 70 FPS with a 1920x1200 resolution Windows or Mac Build (both computers with Geforce). We have very few effects (e.g. only 4 lights) as of now and our far more advanced TV3D-Version has no problem reaching more than 300 FPS with the exact same models and same resolution on the same PC.
Are the amount of draw calls causing troubles? This are our stats:
Draw Calls: 1508
Tris: 178.6k
Verts: 250.5k
I 've searched this forum for drawcalls and found that you should try to keep this lower than 200 or something. But I don’t know if there are any good options for us to really cut down our amount of drawcalls because a) we allways have our whole level and therefore all objects visible b) we can’t combine blocks since we need to remove them one by one when the player(s) blasts them.
What is a drawcall exactly? The rendering of a single object? In TV3D we also had the objects rendered one by one because we had to mess around a little with the Z-Order.
Any ideas what we can do for a better performance? The big performance killers - the blast effects are still waiting in the pipeline
Thanks,
Christopher
Look into using the mesh combine script from standard assets to combine tiles into one draw call…
As a team mate of Christopher, I may add that our map consists out of 15 x 11 fields with two game objects each (floor and a block).
Here you can get an idea of what we are trying to port to Unity:
http://www.bronxstudios.de/phpbb/viewtopic.php?t=10
Another problem we stumbled across: The edges of our floor tiles are flickering, they’re not rendered seamless. Any idea how to solve this? Is combining them to one big mesh at runtime the one and only solution?
Thanks and best regards!
Would it be possible to undo that combining because we would need to remove blocks one by one at runtime (see above). Another problem is, that some blocks are animated so I’m afraid the combining approach wouldn’t work at all for us.
if you have several objects in a scene that all have the exact same material and textures, and are using a simple material with only diffuse and night textures, they can all be ripped out in a row without a single material switch = 1 draw call. So try to build with that in mind… the more shaders/materials etc that you have in each mesh will generate more and more Drawcalls, as the post above, try combining. Also check your camera is not rendering things you dont need to (one easy fix sometimes is to lower your far clip plane
On the flickering, maybe you are getting z-buffer issues (two polys overlapping, or better said, two faces trying to occupy the same space ) Go back to your 3D app and check for this, no need to have one mesh, you can have it tiled and it will still look seamless, just check for overlapping faces…
The large number of draw calls is definitely the cause of the performance problem. You can use the mesh scripting interface to make combined meshes and remove parts of those meshes on the fly. It’s more involved than just using independent objects, but it’s not that hard once you get a handle on it, and the performance will dramatically increase. Having animation might be problematic, but it depends on the kind of animation. You can directly manipulate the vertices within a mesh and get excellent speed.
Another thing I’d ask is if you really need 4 lights, and if so, do you really need pixel shaders? With pixel shaders, every light will add to the number of draw calls–a single pixel-shaded object with 4 lights will have 5 draw calls. Using vertex shading will drop that down to 1 draw call.
–Eric
Thanks for your reply. I don’t really understand what you mean. I try, though: Right now we have one prefab for the floor tiles and four prefabs for the blocks. The prefabs include mesh and materials. When we instantiate the prefab does this mean all this gets duplicated? And there is a better way that the meshes could share the same material?
We’ll post a screenshot tomorow to clarify our flicker problem.
Concerning the far clip it’s not relevant for optimization right now because you always see everything.
@Eric5h5: Good hint! We’ll have a look what kind of shading we use in unity and what kind we used in TV3D. Maybe there are different light settings causing different framerates. We do need multiple lights for additional fx because we don’t think we can use a lightmap with our dynamic map - though in the final game we would make the extra lights optional.
So, we need to combine all non-special-animated-blocks (>80%) and remove blocks by manipulating the vertices - there is no other option that is easier to handle, right?