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

Support for model outlining #4314

Merged
merged 42 commits into from
Dec 14, 2016
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9f58e9c
Working on drawing highlighted models
jasonbeverage Aug 31, 2016
de364e9
Changed demo to be able to modify the highlight size
jasonbeverage Aug 31, 2016
cea7291
Better outlining algorithm
jasonbeverage Aug 31, 2016
c72757b
Documentation and slight tweaks
jasonbeverage Sep 1, 2016
b8a2c44
Changed Cartesian4 to Color
jasonbeverage Sep 1, 2016
6a532d1
Making vertex shader for highlighting more generic, works with animat…
jasonbeverage Sep 1, 2016
2362111
Terrible code for looking up the projection matrix uniform name
jasonbeverage Sep 1, 2016
aa759ac
Merge branch 'master' into modelhighlight
jasonbeverage Sep 8, 2016
590bafc
Spelling and added a highlightCommand2D
jasonbeverage Sep 8, 2016
73d9fb2
Comment
jasonbeverage Sep 9, 2016
116bdfc
Moved outline example to it's own sandcastle example and reverted the…
jasonbeverage Sep 9, 2016
fa23733
Fix jshint issues
jasonbeverage Sep 13, 2016
751fbda
Added new getUniformNameForSemantic function
jasonbeverage Sep 13, 2016
f41bb6e
Changed the highlightSize parameter to be in pixels instead of clip s…
jasonbeverage Sep 13, 2016
36f046d
Simplified highlight shader just using cesium builtins
jasonbeverage Sep 13, 2016
d247a65
Merge branch 'master' into modelhighlight
jasonbeverage Sep 13, 2016
32d74a1
Merge branch 'master' into modelhighlight
jasonbeverage Oct 17, 2016
af86c9a
Defaulting highlight to true in 3D Models Outline example. Changed h…
jasonbeverage Oct 17, 2016
817da19
Changed highlightColor default to default constructed color and highl…
jasonbeverage Oct 17, 2016
a492379
Changed hilightSize default to 2.0 in Model.js and highlightColor to …
jasonbeverage Oct 17, 2016
20a7149
Removed extra whitespace
jasonbeverage Oct 17, 2016
d98e0ea
Not setting face in highlightRS, just enabled: false
jasonbeverage Oct 17, 2016
aa62d4d
Whitespace
jasonbeverage Oct 17, 2016
c2a8ed1
Whitespace
jasonbeverage Oct 17, 2016
df36205
Enabling ALPHA_BLEND blending on highlight state
jasonbeverage Oct 17, 2016
fa3c2e9
Added opacity slider to 3D Models Outline demo.
jasonbeverage Oct 17, 2016
1bcce58
Explicitly requesting a stencil buffer in the 3D Models Outline demo …
jasonbeverage Oct 17, 2016
fee0674
Only rendering highlight commands if stencilBits is greater than 0, o…
jasonbeverage Oct 17, 2016
508b14d
ModelGraphicSpec tests for model highlighting
jasonbeverage Oct 17, 2016
1c33371
Model testing
jasonbeverage Oct 17, 2016
bd77f27
Merge branch 'master' into modelhighlight
lilleyse Dec 6, 2016
5f93bf1
Reorganized silhouetting
lilleyse Dec 6, 2016
93d4e68
Prevent divide-by-zero during unpremultiply
lilleyse Dec 7, 2016
d7ae242
Issue clear command
lilleyse Dec 7, 2016
5e1e9cf
More accurate translucencly check
lilleyse Dec 8, 2016
246dc83
Fix spec
lilleyse Dec 8, 2016
60caefa
Change order of stencilReference
lilleyse Dec 8, 2016
11fc0da
Doc and stencil clear after ground pass
lilleyse Dec 12, 2016
cb35414
No longer hardcoding v_normal
lilleyse Dec 12, 2016
95d024e
Updated CHANGES.md
lilleyse Dec 12, 2016
077e225
Added tests
lilleyse Dec 12, 2016
7a399f2
Merge branch 'master' into modelhighlight
lilleyse Dec 13, 2016
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
69 changes: 40 additions & 29 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
@@ -1853,26 +1853,32 @@ define([
// Get the projection matrix name. There is probably a better way to do this.
var projectionMatrixUniformName = null;
for (var techniqueName in model.gltf.techniques) {
var projectionMatrixParameterName = "";
var technique = model.gltf.techniques[techniqueName];
for (var parameterName in technique.parameters) {
var parameter = technique.parameters[parameterName];
if (parameter.semantic === "PROJECTION") {
projectionMatrixParameterName = parameterName;
break;
if (model.gltf.techniques.hasOwnProperty(techniqueName)) {
var technique = model.gltf.techniques[techniqueName];
var projectionMatrixParameterName = "";
for (var parameterName in technique.parameters) {
if (technique.parameters.hasOwnProperty(parameterName)) {
var parameter = technique.parameters[parameterName];
if (parameter.semantic === "PROJECTION") {
projectionMatrixParameterName = parameterName;
break;
}
}
}
}

for (var uniformName in technique.uniforms) {
var paramName = technique.uniforms[uniformName];
if (paramName == projectionMatrixParameterName) {
projectionMatrixUniformName = uniformName;
break;
for (var uniformName in technique.uniforms) {
if (technique.uniforms.hasOwnProperty(uniformName)) {
var paramName = technique.uniforms[uniformName];
if (paramName === projectionMatrixParameterName) {
projectionMatrixUniformName = uniformName;
break;
}
}
}
}

if (projectionMatrixUniformName) {
break;
if (projectionMatrixUniformName) {
break;
}
}
}

@@ -2955,6 +2961,18 @@ define([
};
}

function createHighlightColorFunction(model) {
return function() {
return model.highlightColor;
};
}

function createHighlightSizeFunction(model) {
return function() {
return model.highlightSize;
};
}

function createCommand(model, gltfNode, runtimeNode, context, scene3DOnly) {
var nodeCommands = model._nodeCommands;
var pickIds = model._pickIds;
@@ -3115,14 +3133,9 @@ define([

highlightRS = RenderState.fromCache(highlightRS);

// Setup the highlight color uniform.
uniformMap.u_highlightColor = function(){
return model.highlightColor;
};

uniformMap.u_highlightSize = function() {
return model.highlightSize;
};
// Setup the highlight color and size uniforms.
uniformMap.u_highlightColor = createHighlightColorFunction(model);
uniformMap.u_highlightSize = createHighlightSizeFunction(model);

var highlightCommand = new DrawCommand({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create these commands and related resources on-demand the first time highlight is true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to mimic what was done with the pickCommands, so kept the highlight command and resource creation close to where the pick commands are generated. If you don't mind I'll defer this to you to move around so I don't break anything :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lilleyse let me know if you have any questions on this one; I prefer creating these on-demand since they may not be used in many apps, and users should only pay for what they use when it's reasonable for us to implement.

boundingVolume : new BoundingSphere(), // updated in update()
@@ -3991,10 +4004,9 @@ define([
for (i = 0; i < length; ++i) {
nc = nodeCommands[i];
if (nc.show) {
var command = nc.command;
commandList.push(command);
commandList.push(nc.command);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and just below, I don't think this change is needed.


boundingVolume = command.boundingVolume;
boundingVolume = nc.command.boundingVolume;
if (frameState.mode === SceneMode.SCENE2D &&
(boundingVolume.center.y + boundingVolume.radius > idl2D || boundingVolume.center.y - boundingVolume.radius < idl2D)) {
commandList.push(nc.command2D);
@@ -4008,8 +4020,7 @@ define([
nc = nodeCommands[i];
if (nc.show) {
commandList.push(nc.highlightCommand);

boundingVolume = command.boundingVolume;
boundingVolume = nc.command.boundingVolume;
if (frameState.mode === SceneMode.SCENE2D &&
(boundingVolume.center.y + boundingVolume.radius > idl2D || boundingVolume.center.y - boundingVolume.radius < idl2D)) {
commandList.push(nc.highlightCommand2D);