-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Invert classification #5836
Conversation
@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 I am a bot who helps you make Cesium awesome! Thanks again. |
Very nice! @lilleyse can you please take a first pass this week and then bump to me for a quick review? |
Source/Renderer/UniformState.js
Outdated
* The highlight color of unclassified 3D Tiles. | ||
* | ||
* @memberof UniformState.prototype | ||
* @type {Number} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be Color
.
Source/Scene/FrameState.js
Outdated
|
||
/** | ||
* 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}. |
There was a problem hiding this comment.
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.
Source/Scene/Scene.js
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.0
?
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 This is ready for another look. |
While picking in the inspector sandcastle, what should be transparent-yellow becomes invisible. 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. |
Actually ignore that - I forgot to rebuild and the |
The new changes look good. |
@pjcozzi this is ready for you to review when you have a chance. |
@bagnell can you merge and fix the conflict in |
CHANGES.md
Outdated
@@ -20,6 +20,7 @@ Change Log | |||
* Fixed removing multiple event listeners within event callbacks. [#5827](https://github.com/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://github.com/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://github.com/AnalyticalGraphicsInc/cesium/pull/5836) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@pjcozzi The merge conflict is resolved and |
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? |
Also, can you add an invert alpha example? |
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Cesium3DTilesetTraversal.js#L167
Instead of a depth of 255, the depth would be limited to 15.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
Source/Scene/InvertClassification.js
Outdated
}; | ||
|
||
var stencilReference = 0; | ||
var stencilMask = 0x0F; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used anywhere?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@bagnell this looks good, just those comments. |
@pjcozzi This is ready for another look. |
Sandcastle example looks great! @lilleyse can you make a final pass and merge? |
Looks good! |
Adds
invertClassification
andinvertClassificationColor
toScene
. WheninvertClassification
istrue
, any 3D Tiles geometry that is not classified will have its color multiplied byinvertClassificationColor
. See the Classification Sandcastle example.