Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add a pass for 3D Tiles #5168

Merged
merged 4 commits into from
Apr 11, 2017
Merged
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions Source/Renderer/Pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ define([
ENVIRONMENT : 0,
COMPUTE : 1,
GLOBE : 2,
GROUND : 3,
OPAQUE : 4,
TRANSLUCENT : 5,
OVERLAY : 6,
NUMBER_OF_PASSES : 7
CESIUM_3D_TILE : 3,
GROUND : 4,
OPAQUE : 5,
TRANSLUCENT : 6,
OVERLAY : 7,
NUMBER_OF_PASSES : 8
};

return freezeObject(Pass);
Expand Down
1 change: 1 addition & 0 deletions Source/Scene/Cesium3DTileBatchTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,7 @@ define([

function deriveCommand(command) {
var derivedCommand = DrawCommand.shallowClone(command);
derivedCommand.pass = Pass.CESIUM_3D_TILE;

// Add a uniform to indicate if the original command was translucent so
// the shader knows not to cull vertices that were originally transparent
Expand Down
6 changes: 3 additions & 3 deletions Source/Scene/PointCloud3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ define([
shaderProgram : undefined, // Updated in createShaders
uniformMap : drawUniformMap,
renderState : isTranslucent ? content._translucentRenderState : content._opaqueRenderState,
pass : isTranslucent ? Pass.TRANSLUCENT : Pass.OPAQUE,
pass : isTranslucent ? Pass.TRANSLUCENT : Pass.CESIUM_3D_TILE,
owner : content
});

Expand All @@ -811,7 +811,7 @@ define([
shaderProgram : undefined, // Updated in createShaders
uniformMap : pickUniformMap,
renderState : isTranslucent ? content._translucentRenderState : content._opaqueRenderState,
pass : isTranslucent ? Pass.TRANSLUCENT : Pass.OPAQUE,
pass : isTranslucent ? Pass.TRANSLUCENT : Pass.CESIUM_3D_TILE,
owner : content
});
}
Expand Down Expand Up @@ -1259,7 +1259,7 @@ define([
// Update the render state
var isTranslucent = (this._highlightColor.alpha < 1.0) || (this._constantColor.alpha < 1.0) || this._styleTranslucent;
this._drawCommand.renderState = isTranslucent ? this._translucentRenderState : this._opaqueRenderState;
this._drawCommand.pass = isTranslucent ? Pass.TRANSLUCENT : Pass.OPAQUE;
this._drawCommand.pass = isTranslucent ? Pass.TRANSLUCENT : Pass.CESIUM_3D_TILE;

if (defined(this.batchTable)) {
this.batchTable.update(tileset, frameState);
Expand Down
11 changes: 9 additions & 2 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ define([
break;
}

var pass = command instanceof ClearCommand ? Pass.OPAQUE : command.pass;
var pass = command.pass;
var index = frustumCommands.indices[pass]++;
frustumCommands.commands[pass][index] = command;

Expand Down Expand Up @@ -1928,6 +1928,13 @@ define([
}
}

us.updatePass(Pass.CESIUM_3D_TILE);
commands = frustumCommands.commands[Pass.CESIUM_3D_TILE];
length = frustumCommands.indices[Pass.CESIUM_3D_TILE];
for (j = 0; j < length; ++j) {
executeCommand(commands[j], scene, context, passState);
}

// Execute commands in order by pass up to the translucent pass.
// Translucent geometry needs special handling (sorting/OIT).
var startPass = Pass.GROUND + 1;
Expand Down Expand Up @@ -2001,7 +2008,7 @@ define([
var command = commandList[i];
updateDerivedCommands(scene, command);

if (command.castShadows && (command.pass === Pass.GLOBE || command.pass === Pass.OPAQUE || command.pass === Pass.TRANSLUCENT)) {
if (command.castShadows && (command.pass === Pass.GLOBE || command.pass === Pass.CESIUM_3D_TILE || command.pass === Pass.OPAQUE || command.pass === Pass.TRANSLUCENT)) {
if (isVisible(command, shadowVolume)) {
if (isPointLight) {
for (var k = 0; k < numberOfPasses; ++k) {
Expand Down
9 changes: 9 additions & 0 deletions Source/Shaders/Builtin/Constants/passCesium3DTile.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE}
*
* @name czm_passCesium3DTile
* @glslConstant
*
* @see czm_pass
*/
const float czm_passCesium3DTile = 3.0;
2 changes: 1 addition & 1 deletion Source/Shaders/Builtin/Constants/passGround.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
*
* @see czm_pass
*/
const float czm_passGround = 3.0;
const float czm_passGround = 4.0;
2 changes: 1 addition & 1 deletion Source/Shaders/Builtin/Constants/passOpaque.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
*
* @see czm_pass
*/
const float czm_passOpaque = 4.0;
const float czm_passOpaque = 5.0;
2 changes: 1 addition & 1 deletion Source/Shaders/Builtin/Constants/passOverlay.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
*
* @see czm_pass
*/
const float czm_passOverlay = 6.0;
const float czm_passOverlay = 7.0;
2 changes: 1 addition & 1 deletion Source/Shaders/Builtin/Constants/passTranslucent.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
*
* @see czm_pass
*/
const float czm_passTranslucent = 5.0;
const float czm_passTranslucent = 6.0;