Spline support in NaniteVisualize.usf

Hi,

I’m trying to add a new Nanite visualization mode for UV-density to NaniteVisualize.usf. It works great except for splines because I couldn’t find out how to get the UV coordinate for splines. Can you give me a hint?

Thank you,

Georg

`else if (VisualizeMode >= NANITE_VISUALIZE_UV0_DENSITY && VisualizeMode <= NANITE_VISUALIZE_UV3_DENSITY)
{
float4 Color;
BRANCH
if ((PrimitiveData.Flags & PRIMITIVE_SCENE_DATA_FLAG_SPLINE_MESH) != 0 &&
(InstanceData.Flags & INSTANCE_SCENE_DATA_FLAG_HAS_PAYLOAD_EXTENSION) != 0)
{
// const FSplineMeshShaderParams SplineMeshParams = SplineMeshLoadParamsFromInstancePayload(InstanceData);
// const float SplineDist = SplineMeshCalcSplineDistance(SplineMeshParams, PointLocal0);
// float2 UV = SplineMeshParams.TextureCoord + float2(SplineDist, 0.0f);
// Color = UVDensityTexture.SampleLevel(View.SharedBilinearWrappedSampler, UV, 0);
Color = 0;
}
else
{
const int UVSet = VisualizeMode - NANITE_VISUALIZE_UV0_DENSITY;
TDual UV = GetTexCoord(Cluster, TriIndices, Barycentrics, UVSet);
Color = UVDensityTexture.SampleGrad(View.SharedBilinearWrappedSampler, UV.Value, UV.Value_dx, UV.Value_dy);
}

Result = LinearToPostTonemapSpace(Color.rgb);
}`

Steps to Reproduce

Hi,

thanks for reaching out. Would you be able to provide a minimal project which runs the code snippet you provided? Some variables (like NANITE_VISUALIZE_UV0_DENSITY and UVDensityTexture) seem to be currently missing to run the code as-is.

Thanks,

Sam

Hi,

many thanks for providing the repro project and the easy repro steps. I have not been able to find a workaround for the UV-coordinate issue for Nanite splines, but I will file a bug report for the issue you have observed with mesh painting. A link to the bug report will be posted here once it becomes available on the public issue tracker, so its progress can be tracked (please note that this may take a few weeks, as Epic Games will close its offices during the next two weeks for the summer break).

I’m not sure if the issue can be worked around before a fix is available, but please let us know if you would like someone with more experience in this matter have a look at the usf shader.

Thanks,

Sam

Hi Sam,

I’ve attached a minimal project. I realized that I can even demonstrate the problem with the built-in mesh painting feature:

  • Open the project
  • Switch to Mesh Paint Mode
  • Select the right cylinder
  • Select the Textures tab
  • Select Paint mode
  • Select Color View Mode: RGB Channels
  • Note that the UV coordinates for the right cylinder are correct
  • Select the left cylinder
  • Note that the UV coordinates for the left cylinder are wrong

This will run the code in the NANITE_VISUALIZE_MESH_PAINT_TEXTURE section in NaniteVisualize.usf which is very similar to mine.

[Image Removed] [Image Removed]Please let me know if there are questions.

Hi Sam,

that’s alright, it’s just a small issue. We can live with it not working on splines. Thanks for giving it a try and filing a bug report.

Regards,

Georg

PS: I’m also on a summer break for 2 weeks, so no issue at all.

Hi,

Once the bug report has been reflected publicly it will be available here: Unreal Engine Issues and Bug Tracker (UE\-301980)

As Sam mentioned earlier, that will likely be after Epic have returned from Summer break in a couple of weeks.

Thanks,

Hayden