WWDC Unity Metal Tessellation Demo
This year, in the “What’s New in Metal” session at WWDC, Apple showed our Unity demo of adaptive tessellation written using Metal. The demo shows a low polygon sphere being tessellated with many more triangles as we shift between materials using displacement mapping, providing beautiful detail of each material.
For this proof of concept, we added Metal Tessellation support to Unity, along with Metal Compute and native Metal shading language support. We can’t wait to ship support for these in future versions of Unity.
Metal Tessellation allows Unity to enable pre-existing tessellation shaders for Metal, yet opens up new possibilities by decoupling the generation of tessellation factors from draw calls. You can either pre-generate them or write a custom compute shader to do it efficiently per draw or as a separate pass. Regardless of how you choose to generate tessellation factors, the rendering pipeline for each draw remains the same,with just a vertex and fragment shader, while accounting for newly generated patches emitted by the tessellator.
For the demo, we wrote a custom per draw “patch kernel” in a native Metal compute shader to calculate a tessellation factor buffer. We then cycled through a bunch of material properties set up in the Unity editor and displaced the triangles emitted by the tessellator in the “post tessellation vertex shader” (also written as a native Metal shader in Unity). The fragment shader is the same physically based Unitystandard shader currently existing in Unity, but with more triangles it really brings out the details in the material.
Tessellation can be used to implement level of detail, efficiently adapt between materials (as in our demo), or for various other effects — limited only by your imagination! While tessellation has been around for a while, we’re excited to see it come to iOS as it can help produce extremely detailed meshes without storing/streaming large meshes on disk.
This is only one of the many features Apple announced for Metal. Some of the others such as Metal Resource Heaps and Memoryless Render Targets, offer potential for performance and memory usage improvements so we are also excited to see what we can do with them. Meanwhile, we look forward to seeing you use Metal Tessellation in your projects, and welcome your feedback!