Custom 3D geometry rendered via MLNCustomStyleLayer or MLNPluginLayer cannot correctly occlude with fill-extrusion buildings. Fill-extrusion and custom objects do not occlude each other correctly — the overlap does not match their actual spatial positions relative to the camera. The custom model appears "embedded" inside surrounding buildings instead of being correctly hidden behind them or visible in front of them depending on the camera angle.
The issue is in the C++ core (src/mbgl/renderer/) and affects both iOS and Android.
To Reproduce
- Create a map style with a fill-extrusion layer (3D buildings)
- Add a MLNCustomStyleLayer that renders a custom .obj building model at a specific coordinate
- Use the shared depth buffer and projectionMatrix from the drawing context
- Tilt the camera and rotate around the scene
- Observe: occlusion between fill-extrusion buildings and the custom building model does not match actual spatial positions
Confirmed on two independent implementations:
Both produce identical artifacts.
Expected behavior
Correct mutual occlusion: the custom 3D model should be visible in front of buildings that are farther from the camera, and hidden behind buildings that are closer — just like fill-extrusion buildings occlude each other.
Screenshots

Platform information:
Operating System: iOS, Android
Platform: MapLibre Native (C++ core, Metal backend on iOS, OpenGL ES on Android)
Version: 6.25.0 (iOS)
We are willing to sponsor the development of this fix. If anyone from the core team or community is interested — please reach out.
Custom 3D geometry rendered via MLNCustomStyleLayer or MLNPluginLayer cannot correctly occlude with fill-extrusion buildings. Fill-extrusion and custom objects do not occlude each other correctly — the overlap does not match their actual spatial positions relative to the camera. The custom model appears "embedded" inside surrounding buildings instead of being correctly hidden behind them or visible in front of them depending on the camera angle.
The issue is in the C++ core (src/mbgl/renderer/) and affects both iOS and Android.
To Reproduce
Confirmed on two independent implementations:
Both produce identical artifacts.
Expected behavior
Correct mutual occlusion: the custom 3D model should be visible in front of buildings that are farther from the camera, and hidden behind buildings that are closer — just like fill-extrusion buildings occlude each other.
Screenshots

Platform information:
Operating System: iOS, Android
Platform: MapLibre Native (C++ core, Metal backend on iOS, OpenGL ES on Android)
Version: 6.25.0 (iOS)
We are willing to sponsor the development of this fix. If anyone from the core team or community is interested — please reach out.