Skip to content

Commit

Permalink
Merge pull request #6113 from AnalyticalGraphicsInc/translucent-shade…
Browse files Browse the repository at this point in the history
…r-update

Fix applying translucent style to point cloud
  • Loading branch information
ggetz authored Jan 17, 2018
2 parents d7ad2e1 + 38cfc31 commit 3f4a499
Show file tree
Hide file tree
Showing 13 changed files with 256 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Change Log
* Fixed a bug when creating billboard and model entities without a globe. [#6109](https://github.com/AnalyticalGraphicsInc/cesium/pull/6109)
* Updated documentation links to reflect new locations on cesiumjs.org and cesium.com.
* Added support for vertex shader uniforms when `tileset.colorBlendMode` is `MIX` or `REPLACE`. [#5874](https://github.com/AnalyticalGraphicsInc/cesium/pull/5874)
* Fixed applying a translucent style to a point cloud tileset. [#6113](https://github.com/AnalyticalGraphicsInc/cesium/pull/6113)

### 1.41 - 2018-01-02

Expand Down
4 changes: 4 additions & 0 deletions Source/Scene/Cesium3DTileStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ define([
this._showShaderFunctionReady = false;
this._pointSizeShaderFunctionReady = false;

this._colorShaderTranslucent = false;

var promise;
if (typeof style === 'string') {
promise = loadJson(style);
Expand Down Expand Up @@ -1453,12 +1455,14 @@ define([
*/
Cesium3DTileStyle.prototype.getColorShaderFunction = function(functionName, attributePrefix, shaderState) {
if (this._colorShaderFunctionReady) {
shaderState.translucent = this._colorShaderTranslucent;
// Return the cached result, may be undefined
return this._colorShaderFunction;
}

this._colorShaderFunctionReady = true;
this._colorShaderFunction = defined(this.color) ? this.color.getShaderFunction(functionName, attributePrefix, shaderState, 'vec4') : undefined;
this._colorShaderTranslucent = shaderState.translucent;
return this._colorShaderFunction;
};

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
225 changes: 225 additions & 0 deletions Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/tileset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
{
"asset": {
"version": "0.0"
},
"geometricError": 17.32,
"root": {
"boundingVolume": {
"box": [
0,
0,
0,
5,
0,
0,
0,
5,
0,
0,
0,
5
]
},
"transform": [
0.968635634376879,
0.24848542777253735,
0,
0,
-0.15986460794399626,
0.6231776137472074,
0.7655670897127491,
0,
0.190232265775849,
-0.7415555636019701,
0.6433560687121489,
0,
1215012.8828876738,
-4736313.051199594,
4081605.22126042,
1
],
"geometricError": 8.66,
"refine": "ADD",
"content": {
"url": "parent.pnts"
},
"children": [
{
"boundingVolume": {
"box": [
-2.5,
-2.5,
-2.5,
2.5,
0,
0,
0,
2.5,
0,
0,
0,
2.5
]
},
"geometricError": 0,
"content": {
"url": "0.pnts"
}
},
{
"boundingVolume": {
"box": [
-2.5,
2.5,
2.5,
2.5,
0,
0,
0,
2.5,
0,
0,
0,
2.5
]
},
"geometricError": 0,
"content": {
"url": "1.pnts"
}
},
{
"boundingVolume": {
"box": [
-2.5,
-2.5,
2.5,
2.5,
0,
0,
0,
2.5,
0,
0,
0,
2.5
]
},
"geometricError": 0,
"content": {
"url": "2.pnts"
}
},
{
"boundingVolume": {
"box": [
-2.5,
2.5,
-2.5,
2.5,
0,
0,
0,
2.5,
0,
0,
0,
2.5
]
},
"geometricError": 0,
"content": {
"url": "3.pnts"
}
},
{
"boundingVolume": {
"box": [
2.5,
-2.5,
-2.5,
2.5,
0,
0,
0,
2.5,
0,
0,
0,
2.5
]
},
"geometricError": 0,
"content": {
"url": "4.pnts"
}
},
{
"boundingVolume": {
"box": [
2.5,
2.5,
-2.5,
2.5,
0,
0,
0,
2.5,
0,
0,
0,
2.5
]
},
"geometricError": 0,
"content": {
"url": "5.pnts"
}
},
{
"boundingVolume": {
"box": [
2.5,
-2.5,
2.5,
2.5,
0,
0,
0,
2.5,
0,
0,
0,
2.5
]
},
"geometricError": 0,
"content": {
"url": "6.pnts"
}
},
{
"boundingVolume": {
"box": [
2.5,
2.5,
2.5,
2.5,
0,
0,
0,
2.5,
0,
0,
0,
2.5
]
},
"geometricError": 0,
"content": {
"url": "7.pnts"
}
}
]
}
}
27 changes: 26 additions & 1 deletion Specs/Scene/PointCloud3DTileContentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defineSuite([
'Core/PerspectiveFrustum',
'Core/Plane',
'Core/Transforms',
'Renderer/Pass',
'Scene/Cesium3DTileStyle',
'Scene/Expression',
'Specs/Cesium3DTilesTester',
Expand All @@ -29,6 +30,7 @@ defineSuite([
PerspectiveFrustum,
Plane,
Transforms,
Pass,
Cesium3DTileStyle,
Expression,
Cesium3DTilesTester,
Expand All @@ -53,6 +55,7 @@ defineSuite([
var pointCloudBatchedUrl = './Data/Cesium3DTiles/PointCloud/PointCloudBatched';
var pointCloudWithPerPointPropertiesUrl = './Data/Cesium3DTiles/PointCloud/PointCloudWithPerPointProperties';
var pointCloudWithTransformUrl = './Data/Cesium3DTiles/PointCloud/PointCloudWithTransform';
var pointCloudTilesetUrl = './Data/Cesium3DTiles/Tilesets/TilesetPoints';

function setCamera(longitude, latitude) {
// Point the camera to the center of the tile
Expand Down Expand Up @@ -539,7 +542,7 @@ defineSuite([
});

it('rebuilds shader style when expression changes', function() {
return Cesium3DTilesTester.loadTileset(scene, pointCloudWithPerPointPropertiesUrl).then(function(tileset) {
return Cesium3DTilesTester.loadTileset(scene, pointCloudTilesetUrl).then(function(tileset) {
// Solid red color
tileset.style = new Cesium3DTileStyle({
color : 'color("red")'
Expand All @@ -549,6 +552,28 @@ defineSuite([
tileset.style.color = new Expression('color("lime")');
tileset.makeStyleDirty();
expect(scene).toRender([0, 255, 0, 255]);

tileset.style.color = new Expression('color("blue", 0.5)');
tileset.makeStyleDirty();
expect(scene).toRender([0, 0, 255, 255]);

var i;
var commands = scene.frameState.commandList;
var commandsLength = commands.length;
expect(commandsLength).toBeGreaterThan(1); // Just check that at least some children are rendered
for (i = 0; i < commandsLength; ++i) {
expect(commands[i].pass).toBe(Pass.TRANSLUCENT);
}

tileset.style.color = new Expression('color("yellow")');
tileset.makeStyleDirty();
expect(scene).toRender([255, 255, 0, 255]);

commands = scene.frameState.commandList;
commandsLength = commands.length;
for (i = 0; i < commandsLength; ++i) {
expect(commands[i].pass).not.toBe(Pass.TRANSLUCENT);
}
});
});

Expand Down

0 comments on commit 3f4a499

Please sign in to comment.