In the 5.1 preview version, Nanite starts to support masked materials and world position offset (WPO) materials. You can see some beautiful showcases here:
https://twitter.com/tasaki_yota/status/1578686510919872512
You can use Nanite for foliage with masked leaf materials and WPO-based wind animations.
But what did it cost?
In the 5.1 preview, Nanite added a new feature called ‘programmable rasterizer’.
Before we start, let’s look at the basic stages of Nanite:
Instances/Clusters/Triangles → [Rasterizer (HW/SW)]→ Visibility Buffer → [Export Material]→ GBuffer
(Please let me reuse this image from my old blog)
The problem is, in the old Nanite versions, the rasterizer transforms the triangles directly and writes the pixels to the visibility buffer. It doesn’t care about the ‘materials’ and assumes the triangles are opaque and solid.
‘cares’ means it will not trigger the evaluation of the material graph.
So the masked materials are not supported because the triangles are not totally opaque. Without evaluating the material graph, we don’t know the visible and invisible pixels.
The same thing happens to the WPO materials. The vertices’ positions may change during runtime, we cannot rasterize without evaluating the vertex parts of the material graph.
As a solution, the 5.1 preview version added a new ‘programmable’ path to the Nanite, which allows evaluation during the Nanite visibility buffer’s rasterization stages.
If you want to check by yourself, please search ‘NANITE_VERTEX_PROGRAMMABLE
’ and ‘NANITE_PIXEL_PROGRAMMABLE
’