Skip to content

Conversation

danielzhong
Copy link

@danielzhong danielzhong commented Aug 30, 2025

Description

This PR implements the proposed GLTF extension EXT_mesh_primitive_edge_visibility, enabling edge rendering for glTF mesh primitives. It adds multi-pass rendering to avoid z-fighting, and implements decoding, creation, and rendering of both hard and silhouette edges:

  • Parsing and handling mesh primitive data of visibility (edge type: HIDDEN, SILHOUETTE, HARD, REPEATED) and silhouette normal.
  • Hard edge & silhouette edge rendering.
  • Multi-pass rendering path (CESIUM_3D_TILE_EDGES) to draw edges before surfaces (CESIUM_3D_TILE).
  • Feature ID/Depth integration to ensure edges display correctly without Z fighting and overlapping.

More details: Edge Visibility

Example
(green edge = hard edge; red edge = silhouette edge):
image

Issue number and link

#12765

Testing plan

How to Run:

  1. Download the file and host: http-server ./ --cors=X-Correlation-Id
  2. Open sandcastle and paste:
const viewer = new Cesium.Viewer("cesiumContainer", {
 
  infoBox: false,
 
  selectionIndicator: false,
 
  shadows: true,
 
  shouldAnimate: true,
 
});
const tileset = await Cesium.Cesium3DTileset.fromUrl(
 
  "http://172.20.20.20:8081/tileset.json"
 
);
 
viewer.scene.primitives.add(tileset);
 
await viewer.zoomTo(tileset);

Make sure change your local host address in the code!

((green edge = hard edge; red edge = silhouette edge):)
image

🔍Review Notes

  • The glTF extension’s material support is not included in this PR. I'm planning to set all edges default to black.
  • Updated getWebGLStub.js to support MRT in coverage tests.
  • This PR is ready to review!

Bug Fix Summary

  • Edge rendering was incorrect because GL_LINES and edge primitives shared the same VAO. Fixed by creating a separate VAO for edge rendering.
  • Added an edge-rendering pipeline stage in modelFS.glsl. The model runtime primitive couldn’t detect the render tag (it runs too early), so I introduced a uniform flag to detect when the pipeline stage is active.
  • MRT couldn’t clear buffers/color attachments. Fixed by using clearCommand in EdgeFramebuffer.js.
  • MRT was failing unit tests. Fixed by updating getWebGLStub.js to support MRT in coverage tests.
  • Silhouette edges bug: in top-down views, the silhouette normal calculation wasn’t accurate enough.

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

Copy link

Thank you for the pull request, @danielzhong!

✅ We can confirm we have a CLA on file for you.

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.

1 participant