Currently working on a mobile (Gear VR) app. I’m looking for suggestions as to how I might reduce the total Draw Calls in this control panel object. Comes to 15 draw calls which doubles to 30 in VR mode.
Currently the green ‘console’ object is one mesh and each rectangular button is a (quad) mesh with its own material and Collider. Colliders are used for raycasting - the player looks at each button with head tracking to select it. Each button needs to be able to change appearance and/or color independent of the others.
Correct me if I’m wrong, but I don’t think a Texture Atlas would help in this scenario since I need to be able to change each button image at will.
Maybe I don’t quite understand how texture atlas works. I could set up each quad with the proper UV to display the proper section of the Atlas, but how could I then switch images on each quad when needed? A new mesh object with different UV mapping?
I think I will give the new Unity UI a try. Don’t know why I didn’t try that first, actually. I guess I decided no to use it because I was using the raycast setup for selecting each button, but I could still use it to display the images.
I would bake UV data into vertex colors, and offset each button UV (vertex colors in this case) via script, to match the desired icon on a texture atlas. It should give 1 draw call in total I think.
Any UV offset in code, or manipulation of render materials via scripting increases the draw calls. You do, however, get Vertex colours for free, provided that you use a fixed function shader what will display vertex colors
Thanks for the texture packing tips, this is something I haven’t tried before. I guess I can’t use the Unity Sprite Packer because I am in an Android project and don’t have the Android pro license. I’ll give that Texture Packer app a look-see.
Yeah, I agree, any material change will create another material instance in runtime. what I meant, is instead of changing the UV offset in code, it’s better to change the vertex colors values.
I’ve already done something similar in this project, the whole environment is built with 4 materials (1 master material 90% of the meshes(with Lut textures, and uvs baked into vertex colors), 1 for decals, 1 for glass, and 1 for small props) and everything seems to batch properly.
yeah, I like the sound of the UV offset and whatnot, but it is a little over my head.
And - I already switched the images to use the Unity UI along with a sprite sheet. The 14 draw calls from the images are now 1 draw call! So I’m really saving 26 draw calls in VR mode since everything is doubled.
Thanks so much for your help and suggestions everyone. I learned a lot this evening and my project is much more efficient. Also, that Texture Packer app is very quick and easy to use.