MixedReality-GraphicsTools-Unity icon indicating copy to clipboard operation
MixedReality-GraphicsTools-Unity copied to clipboard

Investigate MeshRenderer RectTransform layout that supports traditional batching

Open Cameron-Micka opened this issue 3 years ago • 0 comments

Describe the problem

Investigate if it is possible to write a meshrender/shader pair that would play nice with UnityUI rect transforms. This would allow for rect transform layouts and mesh renderer batching.

Describe the solution you'd like

From @Zee2 -

Is there any way to create a meshrenderer shader that will make a quad/etc obey RectTransforms in the way that a Graphic would?

If we could use RT layout, but traditional meshrenderer-like batching, that would be the ideal.

I feel like for 90% of usecases, we don't care at all about the actual Canvas-y features, we really just care about RT layout

Describe alternatives you've considered

Explore other ways to batch 3D UI efficiently.

Additional context

As Unity UI operates entirely in the transparent queue, any quads that have unbatchable quads overlaid atop them must be drawn before the unbatchable quads, and therefore cannot be batched with other quads placed atop the unbatchable quads.

Consider a case of three quads, A, B, and C. Assume all three quads overlap one another, and also assume quads A and C use the same material while quad B uses a separate material. Quad B therefore cannot be batched with A or C.

If the order in the hierarchy (from top to bottom) is A, B, C then A and C cannot be batched, because B must be drawn atop A and beneath C. However, if B is placed before or after the batchable quads, then the batchable quads can actually be batched – B needs only to be drawn before or after the batched quads and does not interpose them.

Source: https://learn.unity.com/tutorial/optimizing-unity-ui

Cameron-Micka avatar Jun 14 '22 21:06 Cameron-Micka