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

Fix flickering for tileset with thin walls #5940

Merged
merged 4 commits into from
Oct 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ Change Log
* Added `customTags` property to the UrlTemplateImageryProvider to allow custom keywords in the template URL. [#5696](https://github.com/AnalyticalGraphicsInc/cesium/pull/5696)
* Improved CZML Reference Properties example [#5754](https://github.com/AnalyticalGraphicsInc/cesium/pull/5754)
* Fixed bug with placemarks in imported KML: placemarks with no specified icon would be displayed with default icon. [#5819](https://github.com/AnalyticalGraphicsInc/cesium/issues/5819)
* Fixed flickering artifacts on tilesets with thin walls. [#5940](https://github.com/AnalyticalGraphicsInc/cesium/pull/5940)
* Fixed bright fog when terrain lighting is enabled and added `Fog.minimumBrightness` to affect how bright the fog will be when in complete darkness. [#5934](https://github.com/AnalyticalGraphicsInc/cesium/pull/5934)

### 1.38 - 2017-10-02
3 changes: 2 additions & 1 deletion Source/Scene/Batched3DModel3DTileContent.js
Original file line number Diff line number Diff line change
@@ -452,7 +452,8 @@ define([
// If any commands were pushed, add derived commands
var commandEnd = frameState.commandList.length;
if ((commandStart < commandEnd) && frameState.passes.render) {
this._batchTable.addDerivedCommands(frameState, commandStart);
var finalResolution = this._tile._finalResolution;
this._batchTable.addDerivedCommands(frameState, commandStart, finalResolution);
}
};

18 changes: 16 additions & 2 deletions Source/Scene/Cesium3DTileBatchTable.js
Original file line number Diff line number Diff line change
@@ -1209,7 +1209,7 @@ define([
OPAQUE_AND_TRANSLUCENT : 2
};

Cesium3DTileBatchTable.prototype.addDerivedCommands = function(frameState, commandStart) {
Cesium3DTileBatchTable.prototype.addDerivedCommands = function(frameState, commandStart, finalResolution) {
var commandList = frameState.commandList;
var commandEnd = commandList.length;
var tile = this._content._tile;
@@ -1236,7 +1236,7 @@ define([
}

if (bivariateVisibilityTest) {
if (command.pass !== Pass.TRANSLUCENT) {
if (command.pass !== Pass.TRANSLUCENT && !finalResolution) {
if (!defined(derivedCommands.zback)) {
derivedCommands.zback = deriveZBackfaceCommand(derivedCommands.originalCommand);
}
@@ -1329,6 +1329,20 @@ define([
var rs = clone(derivedCommand.renderState, true);
rs.cull.enabled = true;
rs.cull.face = CullFace.FRONT;
// Back faces do not need to write color.
rs.colorMask = {
red : false,
green : false,
blue : false,
alpha : false
};
// Push back face depth away from the camera so it is less likely that back faces and front faces of the same tile
// intersect and overlap. This helps avoid flickering for very thin double-sided walls.
rs.polygonOffset = {
enabled : true,
factor : 5.0,
units : 5.0
};
derivedCommand.renderState = RenderState.fromCache(rs);
derivedCommand.castShadows = false;
derivedCommand.receiveShadows = false;
2 changes: 1 addition & 1 deletion Source/Scene/Instanced3DModel3DTileContent.js
Original file line number Diff line number Diff line change
@@ -517,7 +517,7 @@ define([
// If any commands were pushed, add derived commands
var commandEnd = frameState.commandList.length;
if ((commandStart < commandEnd) && frameState.passes.render) {
this._batchTable.addDerivedCommands(frameState, commandStart);
this._batchTable.addDerivedCommands(frameState, commandStart, false);
}
};

6 changes: 4 additions & 2 deletions Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
@@ -2492,8 +2492,9 @@ defineSuite([

scene.renderForSpecs();

// 2 for root tile, 2 for child, 1 for stencil clear
expect(statistics.numberOfCommands).toEqual(5);
// 2 for root tile, 1 for child, 1 for stencil clear
// Tiles that are marked as finalResolution, including leaves, do not create back face commands
expect(statistics.numberOfCommands).toEqual(4);
expect(root.selected).toBe(true);
expect(root._finalResolution).toBe(false);
expect(root.children[0].children[0].children[3].selected).toBe(true);
@@ -2504,6 +2505,7 @@ defineSuite([
var rs = commandList[1].renderState;
expect(rs.cull.enabled).toBe(true);
expect(rs.cull.face).toBe(CullFace.FRONT);
expect(rs.polygonOffset.enabled).toBe(true);
});
});