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

Polygons on terrain #2865

Merged
merged 82 commits into from
Aug 21, 2015
Merged

Polygons on terrain #2865

merged 82 commits into from
Aug 21, 2015

Conversation

pjcozzi
Copy link
Contributor

@pjcozzi pjcozzi commented Jul 2, 2015

This is @bagnell's polygon on terrain work-in-progress. Part of #2172.

It is not ready to be reviewed.

We opened this pull request so we can coordinate testing it the algorithm.

TODO:

  • Documentation
  • Tests

Conflicts:
	Source/Renderer/UniformState.js
…command for the volume and to pause the camera for clipping.
…ex shader now properly finds intersections with the near plane.
… another attribute for whether to extrude position or not.
…. There was not enough precision when offseting from the far plane.
Conflicts:
	Source/Scene/Scene.js
@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jul 2, 2015

@bagnell can you add a TODO list to this pull request, e.g., jitter on zoom out, texturing, and other things you are still working?

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jul 2, 2015

Zoomed in, looking straight down, the multifrustum artifact can be minor:

image

Or major:

image

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jul 2, 2015

Here is the viewer is not in the volume, but a near plane intersects it. The artifact in the upper-left slides across the screen as we zoom in:

image

until is appears OK:

image

Zooming in a bit farther creates the artifact you mentioned to me offline, but I don't think the viewer is inside the volume. It looks like it is capturing the terrain skirts (perhaps of the farther frustum?):

image

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jul 2, 2015

Unrelated to polygons on terrain, I get a lot of false collision detection when zooming into Mount St. Helen's that causes the camera to bounce. We could fix it in a separate PR if it is easy or submit a new issue.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jul 2, 2015

RE: inside volume issue:

I think this is only inside the first frustum, that is why we see the skirts of the second frustum. Use the Cesium Inspector to Show globe depth to see what I mean.

example

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jul 2, 2015

Well, maybe it is always the first frustum, but this view has two frustums and they are both wrong:

image

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jul 2, 2015

Set debugVolume to true. Perhaps the vertex shader near plane clamping is wrong as you mentioned offline?

Here is a similar view to the above screenshot but showing the volume:

example

It might be a bit easier to visualize if we could toggle this on/off and optionally depth test it.

@@ -165,6 +165,7 @@ define([
if (!defined(globeDepth._clearColorCommand)) {
globeDepth._clearColorCommand = new ClearCommand({
color : new Color(0.0, 0.0, 0.0, 0.0),
stencil : 0.0,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anywhere else you think we could be missing a stencil clear?

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jul 2, 2015

Another way to track this down is to debug with only a single view frustum. This doesn't have as many artifacts, but still has the same problem when the view is inside the volume and starts to look up.

Try this code:

//Create the viewer.
var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;
scene.terrainProvider = new Cesium.CesiumTerrainProvider({
    url: '//cesiumjs.org/stk-terrain/tilesets/world/tiles',
    requestVertexNormals : true
});
scene.globe.depthTestAgainstTerrain = true;

var positions = [new Cesium.Cartesian3(-2358138.847340281, -3744072.459541374, 4581158.5714175375),
                 new Cesium.Cartesian3(-2357231.4925370603, -3745103.7886602185, 4580702.9757762635),
                 new Cesium.Cartesian3(-2355912.902205431, -3744249.029778454, 4582402.154378103),
                 new Cesium.Cartesian3(-2357208.0209552636, -3743553.4420488174, 4581961.863286629)];

var polygonHierarchy = { positions : positions };

var groundPolygon = scene.primitives.add(new Cesium.GroundPolygon({
    debugVolume : true,
    polygonHierarchy : polygonHierarchy
}));

viewer.scene.farToNearRatio = 100000000.0;

viewer.camera.lookAt(new Cesium.Cartesian3(-2354331.3069306486, -3742016.2427205616, 4581875.591571755), new Cesium.HeadingPitchRange(Cesium.Math.toRadians(20.0), Cesium.Math.toRadians(-35.0), 10000.0));
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

viewer.extend(Cesium.viewerCesiumInspectorMixin);

Sandcastle.addToolbarButton('Toggle', function() {
    groundPolygon.debugVolume = !groundPolygon.debugVolume;
});

Then hit the Toggle button to see how the debug volume shading changes when the polygon disappears:
example

@bagnell
Copy link
Contributor

bagnell commented Aug 20, 2015

@pjcozzi This is ready for another look.

* @param {Occluder} occluder The occluder.
* @returns {Boolean} <code>true</code> if the sphere is not visible; otherwise <code>false</code>.
*/
BoundingSphere.isOccluded = function(sphere, occluder) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add these new functions to CHANGES.md.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Aug 21, 2015

In Firefox only, picking is inconsistent. Check out the blinking when mousing over the green rectangle:

ok

@mramato
Copy link
Contributor

mramato commented Aug 21, 2015

In Firefox only, picking is inconsistent.

This isn't specific to this branch/polygons, see #2942

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Aug 21, 2015

The GroundPrimitive tests fail in IE. Can we just bail on them when we don't have stencil bits?

We should also make this more clear in the Sandcastle example.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Aug 21, 2015

That's all. This is basically ready.

@bagnell
Copy link
Contributor

bagnell commented Aug 21, 2015

Can we just bail on them when we don't have stencil bits?

I checked the spec and depth-stencil renderbuffers must be supported. If you go to the picking Sandcastle example, it still works with a depth-stencil renderbuffer attachment.

The reason it fails in IE is because we need the EXT_frag_depth extension. I added a check to the tests that render.

@bagnell
Copy link
Contributor

bagnell commented Aug 21, 2015

@pjcozzi This is ready.

@bagnell
Copy link
Contributor

bagnell commented Aug 21, 2015

@pjcozzi I added an isSupported function like we talked about offline. This is now ready.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Aug 21, 2015

Amazing.

pjcozzi added a commit that referenced this pull request Aug 21, 2015
@pjcozzi pjcozzi merged commit bf38196 into master Aug 21, 2015
@pjcozzi pjcozzi deleted the ground-primitive branch August 21, 2015 19:37
@nmschulte
Copy link
Contributor

Where's the +1 button? 👍

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Aug 21, 2015

@bagnell can you merge master into 3d-tiles and fix the conflicts in Primitive.js and PolygonGeometry.js? The conflict in Scene.js is just:

image

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.

5 participants