UV Tile Discarding

This page could do with some revisions to better explain things. However still serves well as a guide.

UV Tile Discarding, AKA "the best thing that'll ever happen to you" is a method of optimization and a valuable tool for avatar creation at the same time.

It effectively allows you to use a secondary UV to align islands across a grid and discard those parts of the mesh as you please. Still doesn't sound exciting yet? This basically allows you to have extremely customizable avatars with fewer skinned meshes and materials.

The avatar shown in the video below only uses a total of 3 skinned meshes and 3 materials, it has 5 different pieces of clothing that can be mixed and matched at any time. Do I have your attention yet?

image.png

The best part about this method is that this isn't some trick that just tricks performance stats into thinking it's optimized, like using transparency masks instead, which really is not an ideal method for doing this. UV Tile Discarding allows the parts of the mesh that aren't seen to be not rendered, period; This is because the discarding happens before the shader fragmentation stage, which I will spare you the technical details of, just know that this is a good thing and that people much smarter than me can likely explain it better. In short, it means you get to use less skinned meshes and materials, which means less draw calls, less being rendered.

The Meat of This Page

"How do I do it?" you may be asking, don't worry I'm finally at the point of explaining it.

There are some general things you should keep in mind when using UV Discarding:

Blender Setup

Below you can see the outfits of the model, it's all merged into a single mesh and all onto a single texture.

(I could have included the coat on this atlas, but I wanted to preserve my sanity of having to redo the atlas and baking for everything)

image.png

I then use a second UV map as seen on the right in the Properties window to lay out the UVs I want to individually enable/disable. You can change the tile settings in the Overlay dropdown to make this easier to visualize. Keep your UVs within the bounds of each tile or it won't work. You can see how I have mine laid out as well as the overlay settings in the screenshot below.

image.png

In-Unity

Now in Unity, we'll be using Poiyomi 8.1+ for our UV Discarding, be aware that this works on any shader that implements UV Discarding.

In Poiyomi, this feature is located under Special FX, you need to enable it. Change the Discard UV to the tile UV you just made in the previous section. This would typically be UV1 (since in Poi, UV numbering starts at zero) for best results, leave Discard Mode at Vertex, there is basically no reason to use "Pixel" discarding and doing so virtually defeats the best purpose of using this method.

image.png

In Poiyomi, right-click the values of the tiles you're using and enable them to be animated. This allows you to use them for toggles.

Checked = Off (Discarded)

Unchecked = On (Not Discarded)

You then would make animation toggles exactly as you would for any other toggle animation, just now you toggle on and off your UV tile discards. You're basically done now!


Revision #4
Created 2 June 2023 14:57:13 by TrixxedHeart
Updated 29 August 2023 23:52:35 by TrixxedHeart