Skip to content

Commit

Permalink
Merge pull request #12317 from connormanning/point-cloud-show-perform…
Browse files Browse the repository at this point in the history
…ance

Fix point cloud performance issue when points are filtered via "show"
  • Loading branch information
lilleyse authored Nov 21, 2024
2 parents 5808a0c + a394dab commit b17154b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
##### Fixes :wrench:

- Fix label rendering bug in WebGL1 contexts. [#12301](https://github.com/CesiumGS/cesium/pull/12301)
- Fix point cloud filtering performance on certain hardware [#12317](https://github.com/CesiumGS/cesium/pull/12317)

#### @cesium/widgets

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Michael Nusair](https://github.com/mnpcmw6444)
- [Kirn Kim](https://github.com/squrki)
- [Emanuele Mastaglia](https://github.com/Masty88)
- [Connor Manning](https://github.com/connormanning)
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,10 @@ function addShaderFunctionsAndDefines(shaderBuilder, shaderFunctionInfo) {
shaderBuilder.addDefine(
"HAS_POINT_CLOUD_SHOW_STYLE",
undefined,
ShaderDestination.VERTEX,
ShaderDestination.BOTH,
);
shaderBuilder.addVertexLines(showStyleFunction);
shaderBuilder.addVarying("float", "v_pointCloudShow");
}

const pointSizeStyleFunction = shaderFunctionInfo.pointSizeStyleFunction;
Expand Down
7 changes: 7 additions & 0 deletions packages/engine/Source/Shaders/Model/ModelFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ SelectedFeature selectedFeature;

void main()
{
#ifdef HAS_POINT_CLOUD_SHOW_STYLE
if (v_pointCloudShow == 0.0)
{
discard;
}
#endif

#ifdef HAS_MODEL_SPLITTER
modelSplitterStage();
#endif
Expand Down
10 changes: 9 additions & 1 deletion packages/engine/Source/Shaders/Model/ModelVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,13 @@ void main()
gl_PointSize *= show;
#endif

gl_Position = show * positionClip;
// Important NOT to compute gl_Position = show * positionClip or we hit:
// https://github.com/CesiumGS/cesium/issues/11270
//
// We will discard points with v_pointCloudShow == 0 in the fragment shader.
gl_Position = positionClip;

#ifdef HAS_POINT_CLOUD_SHOW_STYLE
v_pointCloudShow = show;
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ describe(
"HAS_POINT_CLOUD_SHOW_STYLE",
"COMPUTE_POSITION_WC_STYLE",
]);
ShaderBuilderTester.expectHasFragmentDefines(shaderBuilder, []);
ShaderBuilderTester.expectHasFragmentDefines(shaderBuilder, [
"HAS_POINT_CLOUD_SHOW_STYLE",
]);

ShaderBuilderTester.expectHasVertexUniforms(shaderBuilder, [
"uniform vec4 model_pointCloudParameters;",
Expand Down

0 comments on commit b17154b

Please sign in to comment.