Nanite masked materials appear not to batch

It appears that these materials (see repro) are not batched together in Nanite: we are seeing multiple draw calls in PIX - corresponding to an individual draw event for each masked nanite material.

When using non-masked materials, these seem to batch draws as expected. Is it expected that changing only the texture on a masked material with the same parent would create a new nanite draw event?

Steps to Reproduce
I have a simple masked material that has a texture parameter. I have a parent material instance with two children, each changing that texture. These are each assigned to a nanite static mesh component.

Hi, yes, by having separate input textures for your masked material, we will need to evaluate the material per permutation, which is costly since masked materials have to run through the pixel programmable rasterization path rather than the regular fixed-function rasterizer. For this reason, you should try to use masked materials sparingly. If you have any further questions, please let me know.

Thanks [mention removed]​ ,

Just to clarify our understanding, could you let us know what you mean by ‘per permutation’ in the reply above? Specifically if the material only changes texture but no other parameters does that mean that nanite can’t merge the draw calls and has to issue separate dispatches for each?

To explain our test case, we have 3 material instances, 2 have the same parent and completely identical parameters (including their mask texture). The 3rd has the same parent and changes only the texture parameter. When looking at this in PIX with 3 objects mapped to each material, we see 3 draw calls for the Nanite::VisBuffer, and 3 dispatches in the nanite BasePass. Is this expected and nanite can’t merge any of the 3 materials even though 2 of them share all parameters?

Thanks in advance.

Hi Mike,

To clarify, I meant shader permutation, but that might not apply here given the new information. I assume you would see only 2 draw calls (one for the two identical MIs and one for the material with the different texture parameter) if you are using material instance constants to share between the two materials with identical parameters. Still, it would be good if you could share a repro project to test that everything is set up correctly. Would that be possible?