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

Picking causes a double-render #2790

Closed
emackey opened this issue Jun 5, 2015 · 7 comments
Closed

Picking causes a double-render #2790

emackey opened this issue Jun 5, 2015 · 7 comments

Comments

@emackey
Copy link
Contributor

emackey commented Jun 5, 2015

Try pasting the following code in Sandcastle:

var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;

// Turn stars off, so sun will flash on pick.
scene.skyBox = scene.skyBox.destroy();

// Just for help finding the sun, not part of the bug.
scene.globe.enableLighting = true;

var primitive = scene.primitives.add(new Cesium.EllipsoidPrimitive({
    modelMatrix : Cesium.Transforms.eastNorthUpToFixedFrame(
        Cesium.Cartesian3.fromDegrees(-95.0, 40.0, 3000000.0)),
    radii : new Cesium.Cartesian3(1200000.0, 1200000.0, 3000000.0),
    material : Cesium.Material.fromType(Cesium.Material.StripeType)
}));

In the above demo in master, left-clicking the globe will cause a single-frame "flash" of both the Sun and the portion of the blue ellipsoid that is not in front of the Earth.

For added fun, you can cause a pick to happen on mouse move, which will cause the Sun and the blue ellipsoid to leave streaks as they move:

viewer.screenSpaceEventHandler.setInputAction(function(movement) {
    var pickedPrimitive = viewer.scene.pick(movement.endPosition);
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
@mramato
Copy link
Contributor

mramato commented Jun 5, 2015

Possibly the same bug as this?

@emackey
Copy link
Contributor Author

emackey commented Jun 5, 2015

Could be.

@mramato
Copy link
Contributor

mramato commented Jun 11, 2015

Multiple users are reporting issues at my above forum link. It would be nice to look at this for 1.11.

@emackey
Copy link
Contributor Author

emackey commented Jun 11, 2015

Git bisect shows this went bad in 42e4b8d, which was the first commit to a long-running branch that merged to master in #2506. /cc @bagnell

@mramato
Copy link
Contributor

mramato commented Jun 11, 2015

Given several users have hit this bug, and it was a regression introduced with 1.10, I marked this as a showstopper.

@dotansimha
Copy link

Same problem here, drawing polygons and then do "drillPick" on mouse move... any chance to release a fix version for this one ASAP?

Thanks

@emackey
Copy link
Contributor Author

emackey commented Jun 16, 2015

Here are some new findings after a long debug session.

  1. When the app calls Scene.pick, one of the commands in Scene.executeTranslucentCommandsSorted ends up calling Context.applyRenderState with some interesting parameters. In these parameters, the renderState itself calls for the scissor test to be disabled, but the passState calls for that to be enabled, for picking a small 3x3 region. What ends up happening is the scissor test is enabled, but the last known renderState is recorded as having it disabled.
  2. Picking works fine, in spite of the clerical error. The next animation frame, where a new render pass begins, is where problems crop up. The last known renderState has the scissor test turned off, when in fact the real gl context still has it enabled. Thus the clear commands only execute in a 3x3 region around the last pick location.
  3. After the clear commands execute, the renderState does change and the scissor test is properly turned off. Thus the rest of the frame renders correctly, except that OIT blends the translucent stuff with the previous frame that never got cleared out.

If you call pick between each render frame, your clear commands never work except in the immediate vicinity of your mouse pointer. This leaves smeary trails of translucent objects, with little mouse holes in them. See the Sandcastle volumes demo for an example of this, or run the above demo with the extra snippet at the bottom of my original post above.

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

3 participants