So I have a Tower Defense that has been utilizing tiles with a script that has a single bool and a collider. There is one tile for every spot that can have a tower and the rest is just from the background. The tiles also have a texture with partial transparency applied to them.
This worked plenty fine for me up until recently when I started stress testing my engine. With roughly 50 enemies on screen and 10 towers shooting 8 bullets each shot (shotgun type tower), I get some gnarly camera.render lag (17-20 ms).
Now I am using spheres as the placeholder enemies when they should be just boxes, but I’m wondering if me having roughly 90 separate tiles is also causing some lag. I currently have 115 draw calls and 81 are batched. I know that’s high, but I thought the batching might bring it back to a reasonable level. Am I wrong to assume this?
Is there a better way of doing this that doesn’t require me having to write a tile generator? I did it the current way because it took me like 20 minutes to get the tiles working properly. Thanks for your help! =)
90 separate tiles would be fine in general. Are those batched at all? Try to use a single material for the tiles so that they get batched, if they are not. Are they high-poly? Are you using some expensive shaders on them?
I am not using any shaders (no shaders at all actually) or anything on them. There are probably 6-ish different textures for the tiles since they have a bolded border which didn’t work as a single texture (wouldn’t want the border on part of the inside lines).
I have all the tiles using static batching, and like I said I have 115 draw calls and 81 are batched. The tiles are using the standard model for planes, which I think are overly high poly. I am also using the spheres for the enemies, which are by default super high poly. Do you think I’m the poly-count could be affecting me that much? With no enemies on screen, I’m at 27k tris, 16k verts, which probably doubles when a bunch of units get on screen. These numbers will drastically go down when I use a lower poly plane and stop using spheres for placeholder enemies, so if that’s the problem, then that would make me very happy lol.
Android/iPhone/Mac/PC (really only Mac/PC for easy testing purposes, but main platforms are the mobile ones). I am even getting the framerate drops on my laptop though, which means it’ll be even worse on the mobile phones.
Yeah sorry, I was thinking he was asking me if I had a shader script. I’m using Transparency → Diffuse for my tiles.
I can’t really change that though. My game’s style is similar to that of Vector TD or geoDefense. The transparency is a necessity, otherwise the tiles look super ugly.
I will go and change out all of my placeholder enemies and planes with a quad and see if that was the culprit. I’m hoping so, because not having transparency isn’t going to work for my style =/.
As far as content goes, transparency isn’t horrible if you know there’s nothing behind it. So try and keep anything using transparency far away and anything opaque closer. Theres still a penalty but it should be far less if you can keep complexity down.
Your current vertex count is high, the recomended for ios ipod 2g and lower is below 10k. You will see the most performance gain by getting your vertex count down. It’s not always a case of optimizing the triangles but if for example your using no smoothing ( facet ) for each face that can be a big hit because the vertices cannot be shared. Generally you want to avoid sharp edge normals, using them only in places its absolutely necessary. Like you mentioned, you probably should not be using the standard plane.
Unless you’ve got a lot of lighting effects ( which can slow stuff down as well ) use a unlit transparent shader instead of the diffuse.