UV1 textures become Triplanar when UV0 texture is used as alpha on skinned mesh?

Hi! !

I have encountered a bug in one of my shader, and stripped it down to be as bare bone as possible, here are the details:

SET UP:

  • I have an Unlit shader graph with Alpha clip
  • I use a texture and sample it with UV1 and use it as the base color
  • I use a texture and sample it with UV0 and use the red channel of this texture as alpha
  • I use this material on a skinned mesh renderer and move the bones

ISSUE:

  • When the bone moves the mesh, the basecolor (UV1) is moving as if it was triplanar (or at least looks like it)

Details:

  • This issue does not happen in the editor, but does in the simulator and in the headset
  • It does not happen if no texture are pluged into alpha in the shader OR if the plugged texture is using UV1 as well
  • Tested using Unity 6 release and Unity 2022.3.40 (with their corresponding packages)

Here are a screenshot of my shader, and a recording of the issue in the simulator, please let me know if I am missing informations or if I should open an issue ticket, thanks!


It would be great if you could open a ticket and let us know the incident number (IN-#####) so that we can look into it. This seems like a very strange case!

Done! The incident number is IN-87252, hope it helps!

Would it be possible to include a repro case with the model in question? I was unable to reproduce the effect with another model.


Also, does the model have blend shapes? That affects which path we use.

@kapolka Oh sorry, I tested on 2 meshes and the bug happened both time, so I thought it was consistent, but when testing on one of my skinned character like yours, using the same shader and materials, the bug did not happen.

I have made another report IN-87274, in it you will find a folder with everything needed to reproduce my setup: the mesh, the shaders, the script that moves the branch and a demo scene.

The mesh should not have any blend shapes, and I also tried building with “import blendshapes” unchecked, but unfortunately it did resolve the issue.

Hope the new incident report has everything you need, otherwise please let me know, and thank you for your quick answers!

Perfect; thanks! It seems like your issue is a difference between how Unity and RealityKit handle texture coordinates that are sampled in the shader graph, but not included in the model. In your example, the GEO_Leaves mesh has UV0 data, but not UV1 data:

It seems like Unity is smart enough to fall back on the UV0 data when there’s nothing in UV1, but RealityKit is instead providing the object space positions (flipped in V), which is why it looks like a triplanar projection (though technically just uniplanar). I think we could work around this in the future when we switch to the LowLevelMesh API, which allows using the same data for multiple attributes (UV0, UV1, etc.). However, the current workaround would be either to ensure that your mesh actually has UV1 data or modify the shader graph to use UV0 instead.

Interesting! Thank you so much for providing a workaround, I will try that!

I am guessing that this workaround does not work using the “generare Lightmap UV” option in the mesh import in Unity, since I had issues with a mesh that had this option checked, but only with UV1 set up in the 3D software directly ?

Well, when I tried enabling that option on your model and reimporting it, I ended up with the expected UV1 data present, and those coordinates came through as expected: that is, no “triplanar” effect. AFAIK, there should be no difference in the way we treat the UV1 generated automatically on model import versus UV1 data explicitly included in the original FBX. All that matters is what we read from the Mesh at run time.

Alright, I am still having some issue even with the Lightmap UV generated in Unity, like it is not registering a new UV set, but I will look into it and try to manually add a UV1 and report back on the issue before the end of the week!

1 Like

Update:
Generating UV using the “Generate UV lightmap” option in the mesh importer does not fix the issue, BUT creating UV1 set in Maya/Blender does, thank you for the help!

1 Like