Nanite pixel programmable visualization

Hi,

I have a question regarding the nanite pixel programmable visualization mode (r.nanite.visualize pixelprogrammable). When using it to profile our nanite performances, I was surprised to see that none of the materials using two sided or WPO were flagged by the visualization (ie appearing red). When checking the shader code, here’s what it looks like:

		else if (VisualizeMode == NANITE_VISUALIZE_PIXEL_PROGRAMMABLE_RASTER)
		{
			bool bHighlight = false;
			switch (GetPixelProgrammableVisMode())
			{
			case NANITE_PIXEL_PROG_VIS_MODE_DEFAULT:
				bHighlight = MaterialFlags.bPixelDiscard || MaterialFlags.bPixelDepthOffset;
				break;
			case NANITE_PIXEL_PROG_VIS_MODE_MASKED_ONLY:
				bHighlight = MaterialFlags.bPixelDiscard;
				break;
			case NANITE_PIXEL_PROG_VIS_MODE_PDO_ONLY:
				bHighlight = MaterialFlags.bPixelDepthOffset;
				break;
			default:
				break;
			}

			if (bFallbackRaster &&
				(PrimitiveData.PixelProgrammableDistanceSquared > 0.0f ||
				 PrimitiveData.MaterialDisplacementFadeOutSize > 0.0f))
			{
				// We've disabled pixel programmable for this cluster
				bHighlight = false;
			}

			Result = select(bHighlight, float3(1, 0, 0), float3(0.1, 0, 0.3));
		}

From that code we are only checking for masked materials and pixel depth offset and ignoring flags like bDisplacement, bTwoSided and bWorldPositionOffset which as far as I understood would trigger the pixel programmable pipeline.

Is there any reason why the pixelprogrammable visualization is only checking those two flags?

Thanks.

Hi Lucas,

I cannot give you an exact reason why the pixel programmable options you mentioned are not included in that particular path of the Nanite debug visualization shader. However, from what I can tell, the WPO and Displacement visualization modes are present through different options that you can feed to the Nanite debug visualization. For WPO, you should use r.Nanite.Visualize EvaluateWPO to view primitives that have a WPO-enabled material applied. The code path that checks for this is actually right above the one you posted in NaniteVisualize.usf around line 581. Displacement is also visualized in a separate visualization via r.Nanite.Visualize DisplacementScale.

As for two-sided materials, it is a bit trickier to surface debug information, since there is no dedicated debug visualization available for it. If you feel up to it, you could also modify the visualization shader to include a mode for two-sided materials, which should not be an invasive change.

I hope this helps you get started, and please don’t hesitate to let me know if you have any further questions.