From 1926560162c712e1f0723479c2950032114d6247 Mon Sep 17 00:00:00 2001 From: jjspace <8007967+jjspace@users.noreply.github.com> Date: Tue, 27 Aug 2024 13:07:40 -0400 Subject: [PATCH] enable msaa by default --- Apps/Sandcastle/gallery/Bathymetry.html | 3 --- Apps/Sandcastle/gallery/I3S Building Scene Layer.html | 1 - Apps/Sandcastle/gallery/Japan Buildings.html | 1 - Apps/Sandcastle/gallery/glTF PBR Extensions.html | 2 -- CHANGES.md | 2 +- packages/engine/Source/Scene/Scene.js | 4 ++-- packages/engine/Source/Widget/CesiumWidget.js | 2 +- packages/engine/Specs/Scene/SceneSpec.js | 1 + packages/widgets/Source/Viewer/Viewer.js | 2 +- 9 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Apps/Sandcastle/gallery/Bathymetry.html b/Apps/Sandcastle/gallery/Bathymetry.html index 34b650a4a0ea..2b7ad4eabbf7 100644 --- a/Apps/Sandcastle/gallery/Bathymetry.html +++ b/Apps/Sandcastle/gallery/Bathymetry.html @@ -106,9 +106,6 @@ const scene = viewer.scene; - // prevent aliasing from countour lines - scene.msaaSamples = 4; - const globe = scene.globe; globe.enableLighting = true; globe.maximumScreenSpaceError = 1.0; // Load higher resolution tiles for better seafloor shading diff --git a/Apps/Sandcastle/gallery/I3S Building Scene Layer.html b/Apps/Sandcastle/gallery/I3S Building Scene Layer.html index 06de162a80fc..eaf58aada313 100644 --- a/Apps/Sandcastle/gallery/I3S Building Scene Layer.html +++ b/Apps/Sandcastle/gallery/I3S Building Scene Layer.html @@ -56,7 +56,6 @@

Loading...

animation: false, timeline: false, orderIndependentTranslucency: false, - msaaSamples: 4, // enables multisample antialiasing for improved visual quality }); // More datasets to tour can be added here... diff --git a/Apps/Sandcastle/gallery/Japan Buildings.html b/Apps/Sandcastle/gallery/Japan Buildings.html index 5534dd276bdf..c767e78b5860 100644 --- a/Apps/Sandcastle/gallery/Japan Buildings.html +++ b/Apps/Sandcastle/gallery/Japan Buildings.html @@ -45,7 +45,6 @@ sceneModePicker: false, animation: false, timeline: false, - msaaSamples: 4, }); const scene = viewer.scene; scene.globe.depthTestAgainstTerrain = true; diff --git a/Apps/Sandcastle/gallery/glTF PBR Extensions.html b/Apps/Sandcastle/gallery/glTF PBR Extensions.html index 44b5dbc9f4d4..3029425bd1de 100644 --- a/Apps/Sandcastle/gallery/glTF PBR Extensions.html +++ b/Apps/Sandcastle/gallery/glTF PBR Extensions.html @@ -47,8 +47,6 @@ ); } - scene.msaaSamples = 4; - const height = 20.0; const hpr = new Cesium.HeadingPitchRoll(0.0, 0.0, 0.0); const origin = Cesium.Cartesian3.fromDegrees( diff --git a/CHANGES.md b/CHANGES.md index 003d3a93908f..8dea3057a07f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,8 +6,8 @@ ##### Additions :tada: +- Enable MSAA by default with 4 samples. To turn MSAA off set `scene.msaaSamples = 1` - Made the `time` parameter optional for `Property`, using `JulianDate.now()` as default. [#12099](https://github.com/CesiumGS/cesium/pull/12099) - - Exposes `ScreenSpaceCameraController.zoomFactor` to allow adjusting the zoom factor (speed). [#9145](https://github.com/CesiumGS/cesium/pull/9145) ##### Fixes :wrench: diff --git a/packages/engine/Source/Scene/Scene.js b/packages/engine/Source/Scene/Scene.js index 985e19cc0509..3aead7f3e298 100644 --- a/packages/engine/Source/Scene/Scene.js +++ b/packages/engine/Source/Scene/Scene.js @@ -107,7 +107,7 @@ const requestRenderAfterFrame = function (scene) { * @param {boolean} [options.requestRenderMode=false] If true, rendering a frame will only occur when needed as determined by changes within the scene. Enabling improves performance of the application, but requires using {@link Scene#requestRender} to render a new frame explicitly in this mode. This will be necessary in many cases after making changes to the scene in other parts of the API. See {@link https://cesium.com/blog/2018/01/24/cesium-scene-rendering-performance/|Improving Performance with Explicit Rendering}. * @param {number} [options.maximumRenderTimeChange=0.0] If requestRenderMode is true, this value defines the maximum change in simulation time allowed before a render is requested. See {@link https://cesium.com/blog/2018/01/24/cesium-scene-rendering-performance/|Improving Performance with Explicit Rendering}. * @param {number} [options.depthPlaneEllipsoidOffset=0.0] Adjust the DepthPlane to address rendering artefacts below ellipsoid zero elevation. - * @param {number} [options.msaaSamples=1] If provided, this value controls the rate of multisample antialiasing. Typical multisampling rates are 2, 4, and sometimes 8 samples per pixel. Higher sampling rates of MSAA may impact performance in exchange for improved visual quality. This value only applies to WebGL2 contexts that support multisample render targets. + * @param {number} [options.msaaSamples=4] If provided, this value controls the rate of multisample antialiasing. Typical multisampling rates are 2, 4, and sometimes 8 samples per pixel. Higher sampling rates of MSAA may impact performance in exchange for improved visual quality. This value only applies to WebGL2 contexts that support multisample render targets. Set to 1 to disable MSAA. * * @see CesiumWidget * @see {@link http://www.khronos.org/registry/webgl/specs/latest/#5.2|WebGLContextAttributes} @@ -228,7 +228,7 @@ function Scene(options) { this._minimumDisableDepthTestDistance = 0.0; this._debugInspector = new DebugInspector(); - this._msaaSamples = defaultValue(options.msaaSamples, 1); + this._msaaSamples = defaultValue(options.msaaSamples, 4); /** * Exceptions occurring in render are always caught in order to raise the diff --git a/packages/engine/Source/Widget/CesiumWidget.js b/packages/engine/Source/Widget/CesiumWidget.js index 7e45d1e0fb54..20b2e7172ec2 100644 --- a/packages/engine/Source/Widget/CesiumWidget.js +++ b/packages/engine/Source/Widget/CesiumWidget.js @@ -143,7 +143,7 @@ function configureCameraFrustum(widget) { * @param {boolean} [options.blurActiveElementOnCanvasFocus=true] If true, the active element will blur when the viewer's canvas is clicked. Setting this to false is useful for cases when the canvas is clicked only for retrieving position or an entity data without actually meaning to set the canvas to be the active element. * @param {boolean} [options.requestRenderMode=false] If true, rendering a frame will only occur when needed as determined by changes within the scene. Enabling improves performance of the application, but requires using {@link Scene#requestRender} to render a new frame explicitly in this mode. This will be necessary in many cases after making changes to the scene in other parts of the API. See {@link https://cesium.com/blog/2018/01/24/cesium-scene-rendering-performance/|Improving Performance with Explicit Rendering}. * @param {number} [options.maximumRenderTimeChange=0.0] If requestRenderMode is true, this value defines the maximum change in simulation time allowed before a render is requested. See {@link https://cesium.com/blog/2018/01/24/cesium-scene-rendering-performance/|Improving Performance with Explicit Rendering}. - * @param {number} [options.msaaSamples=1] If provided, this value controls the rate of multisample antialiasing. Typical multisampling rates are 2, 4, and sometimes 8 samples per pixel. Higher sampling rates of MSAA may impact performance in exchange for improved visual quality. This value only applies to WebGL2 contexts that support multisample render targets. + * @param {number} [options.msaaSamples=4] If provided, this value controls the rate of multisample antialiasing. Typical multisampling rates are 2, 4, and sometimes 8 samples per pixel. Higher sampling rates of MSAA may impact performance in exchange for improved visual quality. This value only applies to WebGL2 contexts that support multisample render targets. Set to 1 to disable MSAA. * * @exception {DeveloperError} Element with id "container" does not exist in the document. * diff --git a/packages/engine/Specs/Scene/SceneSpec.js b/packages/engine/Specs/Scene/SceneSpec.js index 78f0eb33fe18..8b6bb475c1ac 100644 --- a/packages/engine/Specs/Scene/SceneSpec.js +++ b/packages/engine/Specs/Scene/SceneSpec.js @@ -137,6 +137,7 @@ describe( expect(scene.mapProjection).toBeInstanceOf(GeographicProjection); expect(scene.frameState).toBeInstanceOf(FrameState); expect(scene.tweens).toBeInstanceOf(TweenCollection); + expect(scene.msaaSamples).toEqual(4); const contextAttributes = scene.context._gl.getContextAttributes(); // Do not check depth and antialias since they are requests not requirements diff --git a/packages/widgets/Source/Viewer/Viewer.js b/packages/widgets/Source/Viewer/Viewer.js index 20572ebece87..4b4f8cf35e26 100644 --- a/packages/widgets/Source/Viewer/Viewer.js +++ b/packages/widgets/Source/Viewer/Viewer.js @@ -342,7 +342,7 @@ function enableVRUI(viewer, enabled) { * @property {boolean} [requestRenderMode=false] If true, rendering a frame will only occur when needed as determined by changes within the scene. Enabling reduces the CPU/GPU usage of your application and uses less battery on mobile, but requires using {@link Scene#requestRender} to render a new frame explicitly in this mode. This will be necessary in many cases after making changes to the scene in other parts of the API. See {@link https://cesium.com/blog/2018/01/24/cesium-scene-rendering-performance/|Improving Performance with Explicit Rendering}. * @property {number} [maximumRenderTimeChange=0.0] If requestRenderMode is true, this value defines the maximum change in simulation time allowed before a render is requested. See {@link https://cesium.com/blog/2018/01/24/cesium-scene-rendering-performance/|Improving Performance with Explicit Rendering}. * @property {number} [depthPlaneEllipsoidOffset=0.0] Adjust the DepthPlane to address rendering artefacts below ellipsoid zero elevation. - * @property {number} [msaaSamples=1] If provided, this value controls the rate of multisample antialiasing. Typical multisampling rates are 2, 4, and sometimes 8 samples per pixel. Higher sampling rates of MSAA may impact performance in exchange for improved visual quality. This value only applies to WebGL2 contexts that support multisample render targets. + * @property {number} [msaaSamples=4] If provided, this value controls the rate of multisample antialiasing. Typical multisampling rates are 2, 4, and sometimes 8 samples per pixel. Higher sampling rates of MSAA may impact performance in exchange for improved visual quality. This value only applies to WebGL2 contexts that support multisample render targets. Set to 1 to disable MSAA. */ /**