-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two overlapping polygons at the same height causes z-fighting #4878
Comments
Thanks for including the code example @ketulm. The reason the problem only happens when you specify We unfortunately currently don't have great support for z-ordering, but it's a frequently requested feature and is on our roadmap. |
It appears that I can specify the height in the hierarchy instead as a workaround. However, I do see another related issue where there is z-fighting at the meridian which is seen through the globe when rotating but not seen in the view where the polygon is visible. This artifact goes away if you set I was able to recreate this on Sandcastle (note that there is only one polygon that crosses meridian):
|
@ketulm the artifact you're seeing is a known issue #4746 And setting the height in hierarchy isn't actually having an effect on your polygon. Positions are scaled to the ground by default unless you specify |
For a workaround, if you need a height for your polygons you could turn order independent translucency off and give your polygons an alpha very close to 1 var viewer = new Cesium.Viewer('cesiumContainer', {
orderIndependentTranslucency: false
});
var entities = viewer.entities;
entities.add({
polygon: {
hierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray([
-58.0, 10.0,
-50.0, 27.0,
-50.0, 32.0,
-58.0, 30.0
])),
material : Cesium.Color.fromRandom({alpha : 0.99}),
height: 4000
}
});
entities.add({
polygon: {
hierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray([
-59.0, 10.0,
-51.0, 18.0,
-51.0, 40.0,
-59.0, 41.0
])),
material : Cesium.Color.fromRandom({alpha : 0.99}),
height: 4000
}
});
viewer.zoomTo(viewer.entities); If you don't need a height, i would recommend just leaving height undefined. The polygons will be drawn on the ground in this case. |
@hpinkos I didn't know about having to specify |
|
z-fighting will always occur for opaque polygons with the same explicit height (the same is true for any opaque geometry occupying the same "physical" space, i.e. overlapping ellipsoids, extruded polygons with shared walls, etc..). There's no way around it in the general case, it's just the nature of describing the world in 3D. Using very slightly translucent geometry is probably the best you can do (or as @hpinkos suggested, just leave off height). For the specific case of geometry on the ground, we can already order them (though that's something the Entity API itself doesn't allow for yet). I recommend we close this issue since it will never actually be addressed in a way that makes the original example code work as desired. |
Note that if you remove the height attribute, then polygons are rendered fine with no artifacts (note that this used to cause z-fighting in the old version, e.g. 1.11).
Here's a simple sandcastle example:
http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=f4873be79823131e312c1f0b92f3c179
The text was updated successfully, but these errors were encountered: