Skip to content

TeamWATCH iPad Optimizations

Week 1

TeamWATCH Optimization Explanation:
So I spent a lot of time trying to optimize the team watch project to work better on the ipad. Before, it barely rendered at all (probably less than 1 frame per second). It was running at just above 10 frames per second on the macbook pro.

Sertac mentioned in the meeting that the number of draw calls was too high and he said that it needs to be reduced. I looked up some recommended specs for deploying to the ipad, and they said that a good target was <30 draw calls and <10k polygons. We were rocking over 2000 draw calls and over 100k polys. I was able to get the poly count down to about 30k by switching from Cylinders to Squares. Reducing the number of draw calls was a bit trickier. Normally you can just add them all to a common parent and then add the CombineChildren built in script to automatically combine all the meshes it can. HOWEVER, Unity can only combine the meshes of objects that share the same material (texture). Since a lot of the revision are the same author (and therefore the same color), you would think they would all share the same texture. However, that is not the case! Every revision has its own dynamically generated texture! To test, I removed all assignments of textures to everything. I was able to get it down to 59 draw calls, but I lost all the colors of the revisions. I’ll need to find a way to combine all the colors into a single texture. I might be able to have a single texture with a bunch of 1 pixel colors on it, and just use different texture coordinates for each different author.

I also removed both the lights and all the colliders from the objects (wasn’t sure why colliders were even necessary). I removed the lights because dynamic lighting is a bit on the expensive side. It’s a bit dark now, but that’s OK — I’m doing everything I can to improve performance, will get it playable, then will start re-adding things as necessary. It might be possible to disable lighting entirely.

The performance still isn’t perfect, but it is at least possible to use the controls to a limited degree now. I can’t figure out how to show the fps on the iPad, but I would estimate it is somewhere between 3 and 5 FPS.

Is it really necessary to display ALL revisions for ALL files by default? I think it would be safe to combine a lot of the older revisions into one larger gray bar, then show all the revision information when that file is selected. I feel like this would make it look a lot less “busy”, and allow the user to focus on the information that matters most — the most recent revisions.

Investigate self-illumination shader


Week 2

I got the program working on the iPad 2, and it runs MARGINALLY better. Still pretty bad, though. Will definitely have to figure out how to cut down on the number of revisions visualized. The first order of business is going to be trying to re-enable the colors while still batching to reduce the number of draw calls. I tried just setting the prefab to static like Sertac suggested, but that didn’t work. I did some research and as far as I can tell, there are a few reasons for this:

1.) Static prefabs still only combine meshes that share the same material
2.) Static prefabs will only combine IF THEY EXIST AT RUNTIME. The reason for this is because this lets unity compute the combined mesh offline (ie, when the project is built). This is advantageous because combining the meshes is an initially expensive operation (takes a long time at startup, then greatly speeds up execution after this). That is the only distinction from the combine mesh utility.

This gives us several challenging problems to overcome:
1.) Make sure each mesh shares the same material.
— I THINK this can be accomplished by dynamically creating a single texture with one pixel of each color that we need, then assigning each mesh to only use the part of the texture corresponding to the color corresponding to the author of that revision. I’ve read a few things on the internet explaining how to make “texture sheets”, but it looks like it will be very time consuming.
2.) Since static prefabs won’t work, we have to assign all of the revision objects as children to a master object, then call the combine mesh script on them.
— I already did this.

I also need to work on combining the older revision data the reduce the polycount. I am going to make this a priority to see if combining old revision data will give a significant enough performance boost to make even supporting iPad viable.