Skip to content
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

depthTestAgainstTerrain default? #2160

Open
pjcozzi opened this issue Sep 27, 2014 · 22 comments
Open

depthTestAgainstTerrain default? #2160

pjcozzi opened this issue Sep 27, 2014 · 22 comments

Comments

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 27, 2014

No description provided.

@pjcozzi pjcozzi changed the title depthTestAgainstTerrain default depthTestAgainstTerrain default? Sep 27, 2014
@pjcozzi
Copy link
Contributor Author

pjcozzi commented Sep 27, 2014

From https://groups.google.com/forum/#!topic/cesium-dev/C0xeURmz_ss

Are we sure we want to expose this instead of just setting it based on the terrain provider? What is the use case? Work around artifacts in a particular app we built? Or perhaps we set this based on the terrain provider and an optional user override.

@kring
Copy link
Member

kring commented Sep 29, 2014

Once Cesium has good support for vector features on terrain, we can get rid of this. It will always be on, even for EllipsoidTerrainProvider. Until then, we need it. I'm ok with defaulting it to true though,

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Sep 29, 2014

Are you sure you want it to always default to true? That is not going to work for the ellipsoid, which needs the depth plane, right?

I'm basically suggesting:

if (!this.depthTestAgainstTerrain || ((whatever.terrainProvider instanceof EllipsoidTerrainProvider))) {
    commandList.push(this._clearDepthCommand);
    if (mode === SceneMode.SCENE3D) {
        commandList.push(this._depthCommand);
    }
}

@kring
Copy link
Member

kring commented Sep 29, 2014

Why is the ellipsoid any different from terrain? It's just a different representation of the surface, right? I know STK has this thing where, say, a sphere centered on the ellipsoid surface will be completely visible, but a sphere centered on the terrain surface will be occluded by the surface, but I can't think of any reason that's desirable.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Sep 30, 2014

Right now if we depth test vector data on the ellipsoid directly with the ellipsoid, instead of the depth plane, we will get z-fighting (well, it's not actually z-fighting, but you get it) so that is why I suggest depthTestAgainstTerrain default to true for terrain but not the ellipsoid provider until we have vector data on ground/ellipsoid solved (could be soon).

@emackey
Copy link
Contributor

emackey commented Sep 30, 2014

@kring Labels at the surface, on the left side of the screen, sink into the globe and fail the depth test. There will always be cases, even with terrain enabled, where the user will want to turn off the depth test once the camera gets far enough from the globe to have this happen.

@kring
Copy link
Member

kring commented Sep 30, 2014

Right now if we depth test vector data on the ellipsoid directly with the ellipsoid, instead of the depth plane, we will get z-fighting (well, it's not actually z-fighting, but you get it)

We get that with terrain too, no?

Labels at the surface, on the left side of the screen, sink into the globe and fail the depth test.

IMO this needs to be fixed. I know it's hard.

@kring
Copy link
Member

kring commented Sep 30, 2014

Let me try to summarize my thoughts on this:

  • Vector data near the surface is currently looks totally broken in Cesium when depthTestAgainstTerrain is on. This is true whether you're using the ellipsoid or terrain.
  • Because of this, many applications (National Map for one) set depthTestAgainstTerrain to false even when using terrain. Being able to see features through hills is less objectionable than them disappearing randomly.
  • The above needs to be fixed, but it's hard to do. A good start would be to depth test billboards based on their center point only. But even if we did that, points on the surface would appear/disappear as the terrain (or ellipsoid) refines. The brute force solution to this is to change feature height as terrain refines, but maybe there's a better way. Polygons and polylines will need some work too.
  • Until we fix this, we need this setting. If we never fix this, we'll always need this setting. But we can change the default if we think the one bad option is slightly better than the other bad option.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Sep 30, 2014

I'm suggesting to change the default, but to only account for it when terrain is used (which kinda makes sense giving the flags name.

Let's do this or do nothing until we support vector data on the ground across the board.

@kring
Copy link
Member

kring commented Oct 1, 2014

We use the term "terrain" to refer to the ellipsoid surface as well, e.g. EllipsoidTerrainProvider. But if you want to default it to false when using the ellipsoid and to true when using real terrain, I'm ok with that. I think it's important that the user be able to toggle it in either case, though.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Oct 2, 2014

This temporary solution is good with me.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Dec 20, 2014

@pjcozzi pjcozzi mentioned this issue Jul 28, 2015
2 tasks
@hpinkos
Copy link
Contributor

hpinkos commented Dec 7, 2016

@pjcozzi can we close this?

@pjcozzi pjcozzi added the 2.0 label Dec 7, 2016
@pjcozzi
Copy link
Contributor Author

pjcozzi commented Dec 7, 2016

Not yet, I'll labeled this 2.0 so we can review when we aim to have terrain on by default.

@ohadmanor
Copy link

Hi,

any news with that?

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Feb 6, 2017

@ohadmanor no update yet.

@ohadmanor
Copy link

Patrick Hi,

In the following example (Sandcastle) I can't see the 'closeTop' from above is it related to that problem or is it a new one

tnx

var viewer = new Cesium.Viewer('cesiumContainer');
var terrainProvider = new Cesium.CesiumTerrainProvider({
url : '//assets.agi.com/stk-terrain/world'
});
viewer.terrainProvider = terrainProvider;
viewer.scene.globe.depthTestAgainstTerrain = true;

 var entities = viewer.entities;
        entities.add({
            polygon: {
                hierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights([
                                                                                            35.4058198550, 31.5346436876, -410.079987,
                                                                                            35.4045995466, 31.5345641023, -410.079987,
                                                                                            35.4048117741, 31.5340600619, -410.079987,
                                                                                            35.4055280421, 31.5341396472, -410.079987,
                                                                                            35.4051301154, 31.5333703224, -410.079987,
                                                                                            35.4060055541, 31.5330254526, -410.079987,
                                                                                            35.4066422367, 31.5334764361, -410.079987,
                                                                                            35.4064034807, 31.5340335334, -410.079987,
                                                                                            35.4068014074, 31.5345906307, -410.079987,
                ])),
                extrudedHeight: -382.0,
                perPositionHeight: true,
                material: Cesium.Color.RED,
                closeTop: true,
                closeBottom : true,
                outline: true,
                outlineColor : Cesium.Color.RED,
            }
        });


        entities.add({
            polygon: {
                hierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights([
                                                                                            35.3832736260, 31.5392242655, 253.550781,
                                                                                            35.3827941489, 31.5390906407, 257.705597,
                                                                                            35.3827627078, 31.5386033034, 257.994263,
                                                                                            35.3831400012, 31.5384460978, 257.494843,
                                                                                            35.3830142368, 31.5387919501, 257.194519,
                ])),
                extrudedHeight: 279.0,
                perPositionHeight: true,
                material: Cesium.Color.BLUE,
                closeTop: true,
                closeBottom: true,
                outline: true,
                outlineColor : Cesium.Color.Blue,
            }
        });

viewer.zoomTo(viewer.entities);

@hpinkos
Copy link
Contributor

hpinkos commented Feb 13, 2017

@ohadmanor this is happening because your extrudedHeight is higher up than the heights of the positions. This is causing the polygons to be drawn inside out. Right now we expect the extrudedHeight to always be less than the per position heights. We have an issue written up to fix that here: #2924

@ohadmanor
Copy link

Thanks,

Usually extrude is from bottom to up . . . :-)

I have two questions if you can answer:

  1. it will be possible to do both sides (up and down)? is it in the road map?
  2. is it possible to use cross terrain for that, like enableCollisionDetection or something else?

Once again thanks!

@hpinkos
Copy link
Contributor

hpinkos commented Feb 13, 2017

No problem @ohadmanor! I did have a note in that issue to be able to specify heights for both the top and bottom of the extruded polygon. And we would eventually like to add clamp to ground support for extruded polygons. However, I don't think we'll be able to address either of these issues in the immediate future. We're pretty busy with fixing other things and finishing up the 3D tiles implementation right now.

If you'd like to take a stab at fixing this, we would gladly take a pull request! You can see instructions for downloading and building the code base in our build guide
Comment in #2924 if you're interested and I can give you some pointers for where code needs to be changed.

@ohadmanor
Copy link

I'm new in cesium, but I want to.

before that I want to be able to play around with cesium and than to join in . . .

I'm worldwind old school . . . (the C# version) . . .

@hpinkos
Copy link
Contributor

hpinkos commented Feb 13, 2017

Oh cool! Well when you're ready to start contributing, we have a beginner label with a bunch of issues perfect for someone new to Cesium https://github.com/AnalyticalGraphicsInc/cesium/issues?q=is%3Aopen+is%3Aissue+label%3Abeginner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants