Skip to content

Conversation

j9liu
Copy link
Contributor

@j9liu j9liu commented Sep 5, 2025

Description

This PR adds support for the LINES, LINE_LOOP, and LINE_STRIP primitive modes in glTF.

Apparently the only line mode supported in Unreal is PT_LineList, so the other two have to be converted into line lists with duplicate indices.

image

Author checklist

  • I have done a full self-review of my code.
  • I have updated CHANGES.md with a short summary of my change (for user-facing changes).
  • [ ] I have added or updated unit tests to ensure consistent code coverage as necessary.
  • [ ] I have updated the documentation as necessary.

Remaining Tasks

The normals are off somehow for this model and I haven't figured out why? I added a clause to disable flat normal generation for non-triangle models (since that doesn't make much sense), but there's still some lighting variation among the lines themselves. You can see it when the sun angle is really extreme. 🤔

image

Testing plan

Load this tileset under a georeference with True Origin: MeshPrimitiveModes.zip

Reference screenshot for this sample model here: https://github.com/KhronosGroup/glTF-Sample-Assets/tree/main/Models/MeshPrimitiveModes

@j9liu
Copy link
Contributor Author

j9liu commented Sep 23, 2025

After a closer look, I believe the weird shading results from the ellipsoid-based computation of unlit normals.

The dataset is small and at the center of the Earth, so the "up" direction for those points are at very far-apart angles even within the same primitive. Thus the shading varies greatly even between points on the same line. Similar normals can be seen on the point cloud primitive as well, which relies on the same unlit normal generation. The reason that the triangles don't suffer from this is because we can actually compute flat normals for those meshes.

I did find that some of the points resulted in NaNs, so I tried to add a clause to prevent that. But it doesn't affect the mesh appearance anyways in this case. Then I tried to add some georeferencing to the sample tileset to prove it would look better, but for some reason I couldn't get it to show up after fiddling with transforms. I'd have to hash out more precise values :/

So instead of fighting it, I tried visualizing a 3D Tileset generated from NYC Open Data instead:

image

It even works with metadata styling! Though, this particular dataset wasn't generated with real metadata, so I've arbitrarily colored the roads based on feature ID.

image

There's some z-fighting in the distance, admittedly, but I'm not sure how much that can be helped. At any rate, this is ready for review.

@j9liu j9liu marked this pull request as ready for review September 23, 2025 16:05
@j9liu j9liu added this to the October 2025 Release milestone Sep 23, 2025
@kring
Copy link
Member

kring commented Sep 29, 2025

Thanks @j9liu!

@kring kring merged commit ca73c60 into main Sep 29, 2025
41 of 46 checks passed
@kring kring deleted the gltf-lines branch September 29, 2025 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants