Skip to content

Commit

Permalink
Merge pull request #5455 from AnimatedRNG/point-cloud-processor-ss
Browse files Browse the repository at this point in the history
More robust point cloud post processor
  • Loading branch information
lilleyse authored Oct 19, 2017
2 parents 411944b + 4b1a918 commit 93145ba
Show file tree
Hide file tree
Showing 16 changed files with 2,672 additions and 7 deletions.
245 changes: 245 additions & 0 deletions Apps/Sandcastle/gallery/3D Tiles Point Cloud Post Processing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <!-- Use Chrome Frame in IE -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Point occlusion and region growing example.">
<meta name="cesium-sandcastle-labels" content="3D Tiles">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
<script type="text/javascript">
require.config({
baseUrl : '../../../Source',
waitSeconds : 60
});
</script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
<style>
@import url(../templates/bucket.css);
#toolbar button { display: block; }
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar">
<table>
<tbody>
<tr>
<td>Occlusion Angle</td>
<td>
<input type="range" min="-1" max="1" step="0.05" data-bind="value: occlusionAngle, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: occlusionAngle">
</td>
</tr>
<tr>
<td>Point Occlusion Filter Size</td>
<td>
<input type="range" min="0" max="4" step="1" data-bind="value: neighborhoodHalfWidth, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: neighborhoodHalfWidth">
</td>
</tr>
<tr>
<td>Maximum Region Growing Iterations</td>
<td>
<input type="range" min="0" max="10" step="1" data-bind="value: numRegionGrowingPasses, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: numRegionGrowingPasses">
</td>
</tr>
<tr>
<td>Region Growing Range Parameter</td>
<td>
<input type="range" min="0" max="1" step="1e-41" data-bind="value: rangeParameter, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: rangeParameter">
</td>
</tr>
<tr>
<td>Maximum Neighborhood Vector Size</td>
<td>
<input type="range" min="0.0" max="200.0" step="1e-2" data-bind="value: neighborhoodVectorSize, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: neighborhoodVectorSize">
</td>
</tr>
<tr>
<td>Max Neighborhood ABS ratio</td>
<td>
<input type="range" min="0.0" max="1.0" step="1e-2" data-bind="value: maxAbsRatio, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: maxAbsRatio">
</td>
</tr>
<tr>
<td>Max Distance Constraint</td>
<td>
<input type="range" min="0.0" max="10000" step="1" data-bind="value: distanceConstraint, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: distanceConstraint">
</td>
</tr>
<tr>
<td>Point Attenuation Multiplier</td>
<td>
<input type="range" min="1.0" max="10.0" step="1" data-bind="value: pointAttenuationMultiplier, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: pointAttenuationMultiplier">
</td>
</tr>
<tr>
<td>AO Sigmoid Domain Offset</td>
<td>
<input type="range" min="0.0" max="1.0" step="0.01" data-bind="value: sigmoidDomainOffset, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: sigmoidDomainOffset">
</td>
</tr>
<tr>
<td>AO Sigmoid Sharpness</td>
<td>
<input type="range" min="0.0" max="1.0" step="0.01" data-bind="value: sigmoidSharpness, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: sigmoidSharpness">
</td>
</tr>
<tr>
<td>Dropout Factor</td>
<td>
<input type="range" min="0.0" max="1.0" step="0.01" data-bind="value: dropoutFactor, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: dropoutFactor">
</td>
</tr>
<tr>
<td>Delay</td>
<td>
<input type="range" min="0" max="4" step="1" data-bind="value: delay, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: delay">
</td>
</tr>
</tbody>
</table>
</div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin

var viewer = new Cesium.Viewer('cesiumContainer');
viewer.extend(Cesium.viewerCesium3DTilesInspectorMixin);
var inspectorViewModel = viewer.cesium3DTilesInspector.viewModel;
inspectorViewModel.picking = false;

var scene = viewer.scene;
var url = 'https://beta.cesium.com/api/assets/1460?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyMzk2YzJiOS1jZGFmLTRlZmYtYmQ4MS00NTA3NjEwMzViZTkiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjBdLCJpYXQiOjE0OTkyNjQ3NTV9.oWjvN52CRQ-dk3xtvD4e8ZnOHZhoWSpJLlw115mbQJM';
var tileset = scene.primitives.add(new Cesium.Cesium3DTileset({
url : url
}));
tileset.pointCloudPostProcessorOptions.enabled = false;
inspectorViewModel.tileset = tileset;

tileset.readyPromise.then(function() {
var boundingSphere = tileset.boundingSphere;
viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0.0, -1.0, 50.0));
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
});

var viewModel = {
occlusionAngle : tileset.pointCloudPostProcessorOptions.occlusionAngle,
rangeParameter : tileset.pointCloudPostProcessorOptions.rangeParameter,
numRegionGrowingPasses : tileset.pointCloudPostProcessorOptions.numRegionGrowingPasses,
neighborhoodHalfWidth : tileset.pointCloudPostProcessorOptions.neighborhoodHalfWidth,
neighborhoodVectorSize : tileset.pointCloudPostProcessorOptions.neighborhoodVectorSize,
maxAbsRatio : tileset.pointCloudPostProcessorOptions.maxAbsRatio,
distanceConstraint : tileset.pointCloudPostProcessorOptions.distanceConstraint,
pointAttenuationMultiplier : tileset.pointCloudPostProcessorOptions.pointAttenuationMultiplier,
sigmoidDomainOffset : tileset.pointCloudPostProcessorOptions.sigmoidDomainOffset,
sigmoidSharpness : tileset.pointCloudPostProcessorOptions.sigmoidSharpness,
dropoutFactor : tileset.pointCloudPostProcessorOptions.dropoutFactor,
delay : tileset.pointCloudPostProcessorOptions.delay
};
Cesium.knockout.track(viewModel);

var toolbar = document.getElementById('toolbar');
Cesium.knockout.applyBindings(viewModel, toolbar);

function subscribeParameter(name) {
Cesium.knockout.getObservable(viewModel, name).subscribe(
function(newValue) {
viewModel[name] = newValue;
tileset.pointCloudPostProcessorOptions[name] = newValue;
}
);
}

subscribeParameter('occlusionAngle');
subscribeParameter('rangeParameter');
subscribeParameter('neighborhoodHalfWidth');
subscribeParameter('numRegionGrowingPasses');
subscribeParameter('neighborhoodVectorSize');
subscribeParameter('maxAbsRatio');
subscribeParameter('distanceConstraint');
subscribeParameter('pointAttenuationMultiplier');
subscribeParameter('sigmoidDomainOffset');
subscribeParameter('sigmoidSharpness');
subscribeParameter('dropoutFactor');
subscribeParameter('delay');

Sandcastle.addToggleButton('Enabled', false, function(checked) {
tileset.pointCloudPostProcessorOptions.enabled = checked;
});

Sandcastle.addToggleButton('Use Triangle Wave', false, function(checked) {
tileset.pointCloudPostProcessorOptions.useTriangle = checked;
});

Sandcastle.addToggleButton('Enable AO', true, function(checked) {
tileset.pointCloudPostProcessorOptions.enableAO = checked;
});

Sandcastle.addToolbarMenu([{
text : 'Color View',
onselect : function() {
tileset.pointCloudPostProcessorOptions.depthViewEnabled = false;
tileset.pointCloudPostProcessorOptions.densityViewEnabled = false;
tileset.pointCloudPostProcessorOptions.stencilViewEnabled = false;
tileset.pointCloudPostProcessorOptions.AOViewEnabled = false;
}
}, {
text : 'Depth View',
onselect : function() {
tileset.pointCloudPostProcessorOptions.depthViewEnabled = true;
tileset.pointCloudPostProcessorOptions.densityViewEnabled = false;
tileset.pointCloudPostProcessorOptions.stencilViewEnabled = false;
tileset.pointCloudPostProcessorOptions.AOViewEnabled = false;
}
}, {
text : 'Density View',
onselect : function() {
tileset.pointCloudPostProcessorOptions.depthViewEnabled = false;
tileset.pointCloudPostProcessorOptions.densityViewEnabled = true;
tileset.pointCloudPostProcessorOptions.stencilViewEnabled = false;
tileset.pointCloudPostProcessorOptions.AOViewEnabled = false;
}
}, {
text : 'Stencil View',
onselect : function() {
tileset.pointCloudPostProcessorOptions.depthViewEnabled = false;
tileset.pointCloudPostProcessorOptions.densityViewEnabled = false;
tileset.pointCloudPostProcessorOptions.stencilViewEnabled = true;
tileset.pointCloudPostProcessorOptions.AOViewEnabled = false;
}
}, {
text : 'AO View',
onselect : function() {
tileset.pointCloudPostProcessorOptions.depthViewEnabled = false;
tileset.pointCloudPostProcessorOptions.densityViewEnabled = false;
tileset.pointCloudPostProcessorOptions.stencilViewEnabled = false;
tileset.pointCloudPostProcessorOptions.AOViewEnabled = true;
}
}]);

//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions Source/Renderer/AutomaticUniforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,14 @@ define([
}
}),

czm_clampedFrustum : new AutomaticUniform({
size : 1,
datatype : WebGLConstants.FLOAT_VEC2,
getValue : function(uniformState) {
return uniformState.clampedFrustum;
}
}),

/**
* The distances to the frustum planes. The top, bottom, left and right distances are
* the x, y, z, and w components, respectively.
Expand Down
15 changes: 15 additions & 0 deletions Source/Renderer/UniformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ define([
this._infiniteProjection = Matrix4.clone(Matrix4.IDENTITY);
this._entireFrustum = new Cartesian2();
this._currentFrustum = new Cartesian2();
this._clampedFrustum = new Cartesian2();
this._frustumPlanes = new Cartesian4();

this._frameState = undefined;
Expand Down Expand Up @@ -639,6 +640,18 @@ define([
}
},

/**
* The distance to the clamped near and far planes. The nearest object determines the near
* plane and the farthest object determines the far plane.
* @memberof UniformState.prototype
* @type {Cartesian2}
*/
clampedFrustum : {
get : function() {
return this._clampedFrustum;
}
},

/**
* The the height (<code>x</code>) and the height squared (<code>y</code>)
* in meters of the camera above the 2D world plane. This uniform is only valid
Expand Down Expand Up @@ -991,6 +1004,8 @@ define([

var camera = frameState.camera;
this.updateCamera(camera);
this._clampedFrustum.x = frameState.clampedNear;
this._clampedFrustum.y = frameState.clampedFar;

if (frameState.mode === SceneMode.SCENE2D) {
this._frustum2DWidth = camera.frustum.right - camera.frustum.left;
Expand Down
Loading

0 comments on commit 93145ba

Please sign in to comment.