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

Invert classification #5836

Merged
merged 21 commits into from
Oct 19, 2017
Merged

Invert classification #5836

merged 21 commits into from
Oct 19, 2017

Conversation

bagnell
Copy link
Contributor

@bagnell bagnell commented Sep 18, 2017

Adds invertClassification and invertClassificationColor to Scene. When invertClassification is true, any 3D Tiles geometry that is not classified will have its color multiplied by invertClassificationColor. See the Classification Sandcastle example.

@cesium-concierge
Copy link

@bagnell, thanks for the pull request! Maintainers, we have a signed CLA from @bagnell, so you can review this at any time.

I noticed that CHANGES.md has not been updated. If this change updates the public API in any way, fixes a bug, or makes any non-trivial update, please add a bullet point to CHANGES.md and comment on this pull request so we know it was updated. For more info, see the Pull Request Guidelines.

I am a bot who helps you make Cesium awesome! Thanks again.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 18, 2017

Very nice!

@lilleyse can you please take a first pass this week and then bump to me for a quick review?

* The highlight color of unclassified 3D Tiles.
*
* @memberof UniformState.prototype
* @type {Number}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be Color.


/**
* When <code>false</code>, 3D Tiles will render normally. When <code>true</code>, classified 3D Tile geometry will render opaque and
* unclassified 3D Tile geometry will render translucent with the alpha set to {@link FrameState#invertClassificationAlpha}.
Copy link
Contributor

Choose a reason for hiding this comment

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

This description is still referring to alpha instead of highlight color.

@@ -1988,10 +2104,17 @@ define([
us.updateFrustum(frustum);
}

var invertClassification;
if (!picking && environmentState.useInvertClassification && scene.frameState.invertClassificationColor.alpha < 1.0) {
// Fullscreen pass to copy unclassified fragments when alpha < 0.0.
Copy link
Contributor

Choose a reason for hiding this comment

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

0.0?

@lilleyse
Copy link
Contributor

It would be nice to have a Sandcastle demo that has translucency and uses inverse classification. Maybe the New York data set with a style that applies translucency to certain buildings, and then a ground primitive covering a single city block.

@lilleyse
Copy link
Contributor

lilleyse commented Sep 19, 2017

Setting the alpha of the classification color less than 1.0 throws this error:
classification

@bagnell
Copy link
Contributor Author

bagnell commented Sep 28, 2017

@lilleyse This is ready for another look.

@lilleyse
Copy link
Contributor

lilleyse commented Oct 2, 2017

While picking in the inspector sandcastle, what should be transparent-yellow becomes invisible.

picking-transparent

Though it renders fine if the tile contains a mix of translucent / opaque gltf, like the Translucent/Opaque tileset in http://localhost:8080/Apps/Sandcastle/index.html?src=3D%20Tiles%20Formats.html&label=3D%20Tiles. So it must be something about whether features are opaque vs. translucent.

@lilleyse
Copy link
Contributor

lilleyse commented Oct 2, 2017

Actually ignore that - I forgot to rebuild and the Pass numbers were out of sync with the shaders.

@lilleyse
Copy link
Contributor

lilleyse commented Oct 2, 2017

The new changes look good.

@lilleyse
Copy link
Contributor

lilleyse commented Oct 2, 2017

@pjcozzi this is ready for you to review when you have a chance.

@pjcozzi
Copy link
Contributor

pjcozzi commented Oct 3, 2017

@bagnell can you merge and fix the conflict in Classification.html?

CHANGES.md Outdated
@@ -20,6 +20,7 @@ Change Log
* Fixed removing multiple event listeners within event callbacks. [#5827](https:/AnalyticalGraphicsInc/cesium/issues/5827)
* Running `buildApps` now creates a built version of Sandcastle which uses the built version of Cesium for better performance.
* Fixed a tileset traversal bug when the `skipLevelOfDetail` optimization is off. [#5869](https:/AnalyticalGraphicsInc/cesium/issues/5869)
* Adds `invertClassification` and `invertClassificationColor` to `Scene`. When `invertClassification` is `true`, any 3D Tiles geometry that is not classified will have its color multiplied by `invertClassificationColor`. [#5836](https:/AnalyticalGraphicsInc/cesium/pull/5836)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this also apply to the classification primitives? I think so, right? If so, then update this.

Otherwise, if this is 3D Tiles specific, maybe rename to invert3DTilesClassification and invert3DTilesClassificationColor?

Longer-term, would this move to per-primitive/tileset properties that could use the bounding volume as a scissor? Maybe an event could notify the scene when these are enabled so that the main rendering pipeline still has the information it needs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. It applies to ClassificationPrimitive and GroundPrimitive.

Yes, longer-term we could move this to per-primitive/tileset properties.

@bagnell
Copy link
Contributor Author

bagnell commented Oct 3, 2017

@pjcozzi The merge conflict is resolved and CHANGES.md has been updated.

@pjcozzi
Copy link
Contributor

pjcozzi commented Oct 3, 2017

The Sandcastle example is good, but it is not 100% clear what the invert is doing since it goes from colored selection to darkened invert. Can the select and invert colors be the same? Not sure what to do about the colored trees - maybe this should be two Sandcastle examples or this example should have a drop down instead of buttons and the check box?

@pjcozzi
Copy link
Contributor

pjcozzi commented Oct 3, 2017

Also, can you add an invert alpha example?

@pjcozzi
Copy link
Contributor

pjcozzi commented Oct 3, 2017

Tests pass and profile looks OK.

@@ -1342,8 +1342,12 @@ define([
// selection depth to the stencil buffer to prevent ancestor tiles from drawing on top
derivedCommand = DrawCommand.shallowClone(command);
var rs = clone(derivedCommand.renderState, true);
// Stencil test is masked to the most significant 4 bits so the reference is shifted.
Copy link
Contributor

Choose a reason for hiding this comment

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

For my knowledge, remind me what limitation the 4 bits creates, e.g., can't have more than 16 tilesets in the same pixel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See this comment when traversing 3D Tiles with the skip LOD optimization: https:/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Cesium3DTilesetTraversal.js#L167

Instead of a depth of 255, the depth would be limited to 15.

Copy link
Contributor

Choose a reason for hiding this comment

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

An unlikely, but potentially possible case now, right? But this is limited to just classification?

At the least, please add appropriate comments if you haven't already in case we need to investigate this in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's still very unlikely the selection depth will reach 15. I'll add a comment.

@@ -344,6 +347,9 @@ define([
return scene.context.stencilBuffer;
};

var stencilReference = 0;
var stencilMask = 0x0F;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps comment where this came from.

}
});

InvertClassification.isTranslucencySupported = function(context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this requirement/limitation mentioned in the reference doc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

};

var stencilReference = 0;
var stencilMask = 0x0F;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment.

*
* @see czm_pass
*/
const float czm_passCesium3DTileClassificationIgnoreShow = 6.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. The only czm_pass* constant that is used is czm_passTranslucent.

Copy link
Contributor

Choose a reason for hiding this comment

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

So should this be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These constants mirror the Pass enum. I'm OK with removing this because it's not used, but then why not remove the rest?

/**
* @private
*/
function InvertClassification() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it reasonable to have a unit test for this file?

If not, how is the current coverage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Coverage is at 91%. The only thing not covered is the destroy function.

@pjcozzi
Copy link
Contributor

pjcozzi commented Oct 3, 2017

@bagnell this looks good, just those comments.

@bagnell
Copy link
Contributor Author

bagnell commented Oct 18, 2017

@pjcozzi This is ready for another look.

@pjcozzi
Copy link
Contributor

pjcozzi commented Oct 18, 2017

Sandcastle example looks great!

@lilleyse can you make a final pass and merge?

@lilleyse
Copy link
Contributor

Looks good!

@lilleyse lilleyse merged commit d568775 into master Oct 19, 2017
@lilleyse lilleyse deleted the invert-classification branch October 19, 2017 19:43
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.

4 participants