From e30ff207986b97846bb58611688144ce8e2dc3b4 Mon Sep 17 00:00:00 2001 From: YoussefV Date: Mon, 27 Apr 2020 12:26:52 -0400 Subject: [PATCH 1/5] fixing highp issue, testing using CI --- Source/Scene/BatchTable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Scene/BatchTable.js b/Source/Scene/BatchTable.js index 8675ed821a8f..a6b130ff334a 100644 --- a/Source/Scene/BatchTable.js +++ b/Source/Scene/BatchTable.js @@ -579,7 +579,7 @@ BatchTable.prototype.getVertexShaderCallback = function () { }; } - var batchTableShader = "uniform sampler2D batchTexture; \n"; + var batchTableShader = "uniform highp sampler2D batchTexture; \n"; batchTableShader += getGlslComputeSt(this) + "\n"; var length = attributes.length; From fa5701cc7a45767aa166bd8863873d853be8ac17 Mon Sep 17 00:00:00 2001 From: YoussefV Date: Tue, 28 Apr 2020 15:36:17 -0400 Subject: [PATCH 2/5] Removed reliance on batchTables, specs pass now --- CHANGES.md | 20 +- Source/Renderer/Context.js | 15 - Source/Renderer/checkFloatTexturePrecision.js | 88 ----- Source/Scene/ClassificationPrimitive.js | 3 +- Source/Scene/GroundPrimitive.js | 5 +- Source/Scene/ShadowVolumeAppearance.js | 218 +---------- .../Shaders/CheckFloatTexturePrecisionFS.glsl | 8 - Source/Shaders/ShadowVolumeAppearanceFS.glsl | 12 +- Source/Shaders/ShadowVolumeAppearanceVS.glsl | 108 ------ Specs/Renderer/ContextSpec.js | 4 +- .../checkFloatTexturePrecisionSpec.js | 44 --- Specs/Scene/ShadowVolumeAppearanceSpec.js | 349 +----------------- 12 files changed, 51 insertions(+), 823 deletions(-) delete mode 100644 Source/Renderer/checkFloatTexturePrecision.js delete mode 100644 Source/Shaders/CheckFloatTexturePrecisionFS.glsl delete mode 100644 Specs/Renderer/checkFloatTexturePrecisionSpec.js diff --git a/CHANGES.md b/CHANGES.md index 4ba54958bf61..b88c8ed30890 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -206,6 +206,8 @@ var viewer = new Viewer("cesiumContainer", { ##### Fixes :wrench: +<<<<<<< HEAD + - Fixed labels not showing for individual entities in data sources when clustering is enabled. [#6087](https://github.com/CesiumGS/cesium/issues/6087) - Fixed an issue where polygons, corridors, rectangles, and ellipses on terrain would not render on some mobile devices. [#6739](https://github.com/CesiumGS/cesium/issues/6739) - Fixed a bug where GlobeSurfaceTile would not render the tile until all layers completed loading causing globe to appear to hang. [#7974](https://github.com/CesiumGS/cesium/issues/7974) @@ -224,7 +226,23 @@ var viewer = new Viewer("cesiumContainer", { - Reduced size of approximateTerrainHeights.json [#7959](https://github.com/CesiumGS/cesium/pull/7959) - Fixed undefined `quadDetails` error from zooming into the map really close. [#8011](https://github.com/CesiumGS/cesium/pull/8011) - Fixed a crash for 3D Tiles that have zero volume. [#7945](https://github.com/CesiumGS/cesium/pull/7945) -- Fixed relative-to-center check, `depthFailAppearance` resource freeing for `Primitive` [#8044](https://github.com/CesiumGS/cesium/pull/8044) +- # Fixed relative-to-center check, `depthFailAppearance` resource freeing for `Primitive` [#8044](https://github.com/CesiumGS/cesium/pull/8044) + +* `Camera.flyTo` flies to the correct location in 2D when the destination crosses the international date line [#7909](https://github.com/AnalyticalGraphicsInc/cesium/pull/7909) +* Fixed 3D tiles style coloring when multiple tilesets are in the scene [#8051](https://github.com/AnalyticalGraphicsInc/cesium/pull/8051) +* Improved display of tile coordinates for `TileCoordinatesImageryProvider` [#8131](https://github.com/AnalyticalGraphicsInc/cesium/pull/8131) +* Fixed relative-to-center check, `depthFailAppearance` resource freeing for `Primitive` [#8044](https://github.com/AnalyticalGraphicsInc/cesium/pull/8044) +* Reduces size of approximateTerrainHeights.json by rounding the numbers [#7959](https://github.com/AnalyticalGraphicsInc/cesium/pull/7959) +* Fixed undefined `quadDetails` error from zooming into the map really close. [#8011](https://github.com/AnalyticalGraphicsInc/cesium/pull/8011) +* Fixed a bug where extruded polygons would sometimes be missing segments. [#8035](https://github.com/AnalyticalGraphicsInc/cesium/pull/8035) +* 3D Tiles geometric error now scales with transform. [#8182](https://github.com/AnalyticalGraphicsInc/cesium/pull/8182) +* Fixed per-feature post processing from sometimes selecting the wrong feature. [#7929](https://github.com/AnalyticalGraphicsInc/cesium/pull/7929) +* Fixed labels not showing for individual entities in data sources when clustering is enabled. [#6087](https://github.com/AnalyticalGraphicsInc/cesium/issues/6087) +* Fixed a crash for 3D Tiles that have zero volume. [#7945](https://github.com/AnalyticalGraphicsInc/cesium/pull/7945) +* Fixed a bug where dynamic polylines did not use the given arcType. [#8191](https://github.com/AnalyticalGraphicsInc/cesium/issues/8191) +* Fixed a bug where GlobeSurfaceTile would not render the tile until all layers completed loading causing globe to appear to hang. [#7974](https://github.com/AnalyticalGraphicsInc/cesium/issues/7974) +* Fixed alpha equation for `BlendingState.ALPHA_BLEND` and `BlendingState.ADDITIVE_BLEND`. [#8202](https://github.com/AnalyticalGraphicsInc/cesium/pull/8202) + > > > > > > > parent of 8bd1c61c17... Merge pull request #7421 from AnalyticalGraphicsInc/mtls-on-groundPrimitives-iOS ### 1.61 - 2019-09-03 diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js index dcc832b4170e..d253b8a22ebe 100644 --- a/Source/Renderer/Context.js +++ b/Source/Renderer/Context.js @@ -16,7 +16,6 @@ import RuntimeError from "../Core/RuntimeError.js"; import WebGLConstants from "../Core/WebGLConstants.js"; import ViewportQuadVS from "../Shaders/ViewportQuadVS.js"; import BufferUsage from "./BufferUsage.js"; -import checkFloatTexturePrecision from "./checkFloatTexturePrecision.js"; import ClearCommand from "./ClearCommand.js"; import ContextLimits from "./ContextLimits.js"; import CubeMap from "./CubeMap.js"; @@ -506,8 +505,6 @@ function Context(canvas, options) { this.cache = {}; RenderState.apply(gl, rs, ps); - - this._floatTexSixPlaces = checkFloatTexturePrecision(this); } var defaultFramebufferMarker = {}; @@ -662,18 +659,6 @@ Object.defineProperties(Context.prototype, { }, }, - /** - * Returns true if the context's floating point textures support 6 decimal places of precision. - * @memberof Context.prototype - * @type {Boolean} - * @see {@link https://www.khronos.org/registry/webgl/extensions/OES_texture_float/} - */ - floatTextureSixPlaces: { - get: function () { - return this._floatTexSixPlaces; - }, - }, - /** * true if OES_texture_half_float is supported. This extension provides * access to floating point textures that, for example, can be attached to framebuffers for high dynamic range. diff --git a/Source/Renderer/checkFloatTexturePrecision.js b/Source/Renderer/checkFloatTexturePrecision.js deleted file mode 100644 index 7132ba2146ae..000000000000 --- a/Source/Renderer/checkFloatTexturePrecision.js +++ /dev/null @@ -1,88 +0,0 @@ -import PixelFormat from "../Core/PixelFormat.js"; -import CheckFloatTexturePrecisionFS from "../Shaders/CheckFloatTexturePrecisionFS.js"; -import ComputeCommand from "./ComputeCommand.js"; -import ComputeEngine from "./ComputeEngine.js"; -import Framebuffer from "./Framebuffer.js"; -import PixelDatatype from "./PixelDatatype.js"; -import Texture from "./Texture.js"; - -/** - * Checks if the context's floating point textures support 6 decimal places of precision. - * - * @param {Context} context A context wrapping a gl implementation. - * @returns {Boolean} Whether or not the context's floating point textures support 6 decimal places of precision - * - * @private - */ -function checkFloatTexturePrecision(context) { - if (!context.floatingPointTexture) { - return false; - } - - var computeEngine = new ComputeEngine(context); - var outputTexture = new Texture({ - context: context, - width: 1, - height: 1, - pixelFormat: PixelFormat.RGBA, - }); - - var floatTexture = new Texture({ - context: context, - width: 1, - height: 1, - pixelFormat: PixelFormat.RGBA, - pixelDatatype: checkFloatTexturePrecision._getFloatPixelType(), - source: { - width: 1, - height: 1, - arrayBufferView: checkFloatTexturePrecision._getArray([123456, 0, 0, 0]), - }, - }); - - var framebuffer = new Framebuffer({ - context: context, - colorTextures: [outputTexture], - destroyAttachments: false, - }); - - var readState = { - framebuffer: framebuffer, - x: 0, - y: 0, - width: 1, - height: 1, - }; - - var sixPlaces = false; - var computeCommand = new ComputeCommand({ - fragmentShaderSource: CheckFloatTexturePrecisionFS, - outputTexture: outputTexture, - uniformMap: { - u_floatTexture: function () { - return floatTexture; - }, - }, - persists: false, - postExecute: function () { - var pixel = context.readPixels(readState); - sixPlaces = pixel[0] === 0; - }, - }); - - computeCommand.execute(computeEngine); - - computeEngine.destroy(); - framebuffer.destroy(); - - return sixPlaces; -} - -checkFloatTexturePrecision._getFloatPixelType = function () { - return PixelDatatype.FLOAT; -}; - -checkFloatTexturePrecision._getArray = function (array) { - return new Float32Array(array); -}; -export default checkFloatTexturePrecision; diff --git a/Source/Scene/ClassificationPrimitive.js b/Source/Scene/ClassificationPrimitive.js index e269fe2d0161..47012dac112a 100644 --- a/Source/Scene/ClassificationPrimitive.js +++ b/Source/Scene/ClassificationPrimitive.js @@ -589,8 +589,7 @@ function createShaderProgram(classificationPrimitive, frameState) { var shadowVolumeAppearance = new ShadowVolumeAppearance( cullFragmentsUsingExtents, planarExtents, - classificationPrimitive.appearance, - context.floatTextureSixPlaces + classificationPrimitive.appearance ); classificationPrimitive._spStencil = ShaderProgram.replaceCache({ diff --git a/Source/Scene/GroundPrimitive.js b/Source/Scene/GroundPrimitive.js index 232192eada10..943e508d9157 100644 --- a/Source/Scene/GroundPrimitive.js +++ b/Source/Scene/GroundPrimitive.js @@ -805,14 +805,12 @@ GroundPrimitive.prototype.update = function (frameState) { var textureCoordinateRotationPoints = geometry.textureCoordinateRotationPoints; - var useFloatBatchTable = frameState.context.floatTextureSixPlaces; if (usePlanarExtents) { attributes = ShadowVolumeAppearance.getPlanarTextureCoordinateAttributes( boundingRectangle, textureCoordinateRotationPoints, ellipsoid, frameState.mapProjection, - useFloatBatchTable, this._maxHeight ); } else { @@ -820,8 +818,7 @@ GroundPrimitive.prototype.update = function (frameState) { boundingRectangle, textureCoordinateRotationPoints, ellipsoid, - frameState.mapProjection, - useFloatBatchTable + frameState.mapProjection ); } diff --git a/Source/Scene/ShadowVolumeAppearance.js b/Source/Scene/ShadowVolumeAppearance.js index 33b3d050a3bf..6cfa05ff7aa4 100644 --- a/Source/Scene/ShadowVolumeAppearance.js +++ b/Source/Scene/ShadowVolumeAppearance.js @@ -21,20 +21,13 @@ import ShadowVolumeAppearanceFS from "../Shaders/ShadowVolumeAppearanceFS.js"; * @param {Boolean} extentsCulling Discard fragments outside the instance's texture coordinate extents. * @param {Boolean} planarExtents If true, texture coordinates will be computed using planes instead of spherical coordinates. * @param {Appearance} appearance An Appearance to be used with a ClassificationPrimitive via GroundPrimitive. - * @param {Boolean} useFloatBatchTable Whether or not the ShadowVolumeAppearance should use floating point batch table values. * @private */ -function ShadowVolumeAppearance( - extentsCulling, - planarExtents, - appearance, - useFloatBatchTable -) { +function ShadowVolumeAppearance(extentsCulling, planarExtents, appearance) { //>>includeStart('debug', pragmas.debug); Check.typeOf.bool("extentsCulling", extentsCulling); Check.typeOf.bool("planarExtents", planarExtents); Check.typeOf.object("appearance", appearance); - Check.typeOf.bool("useFloatBatchTable", useFloatBatchTable); //>>includeEnd('debug'); this._projectionExtentDefines = { @@ -44,8 +37,6 @@ function ShadowVolumeAppearance( westMostYlowDefine: "", }; - this._useFloatBatchTable = useFloatBatchTable; - // Compute shader dependencies var colorShaderDependencies = new ShaderDependencies(); colorShaderDependencies.requiresTextureCoordinates = extentsCulling; @@ -211,7 +202,6 @@ ShadowVolumeAppearance.prototype.createVertexShader = function ( vertexShaderSource, this._appearance, mapProjection, - this._useFloatBatchTable, this._projectionExtentDefines ); }; @@ -245,7 +235,6 @@ ShadowVolumeAppearance.prototype.createPickVertexShader = function ( vertexShaderSource, undefined, mapProjection, - this._useFloatBatchTable, this._projectionExtentDefines ); }; @@ -264,7 +253,6 @@ function createShadowVolumeAppearanceVS( vertexShaderSource, appearance, mapProjection, - useFloatBatchTable, projectionExtentDefines ) { var allDefines = defines.slice(); @@ -327,10 +315,6 @@ function createShadowVolumeAppearanceVS( } } - if (!useFloatBatchTable) { - allDefines.push("UINT8_PACKING"); - } - return new ShaderSource({ defines: allDefines, sources: [vertexShaderSource], @@ -493,86 +477,12 @@ function addTextureCoordinateRotationAttributes( }); } -function encodeLowLessThan100k(value, valueName, attributes) { - // Encode a value like 12,345.678 to 4 uint8 values: 12 34 56 78 - var fract = Math.abs(value); - var d12 = Math.floor(fract / 1000); - fract -= d12 * 1000; // 345.678 - var d34 = Math.floor(fract / 10); - fract -= d34 * 10; // 5.678 - var d56 = Math.floor(fract * 10); - fract -= d56 * 0.1; // 0.078 - var d78 = Math.floor(fract * 1000); - - if (value < 0) { - d12 = 255 - d12; - } - - attributes[valueName] = new GeometryInstanceAttribute({ - componentDatatype: ComponentDatatype.UNSIGNED_BYTE, - componentsPerAttribute: 4, - normalize: false, - value: [d12, d34, d56, d78], - }); -} - -function encodeHighLessThan100Million(value, valueName, attributes) { - // Encode a value like -12,345,678 to 4 uint8 values: sign+12 34 56 78 - var fract = Math.abs(value); - var d12 = Math.floor(fract / 1000000); - fract -= d12 * 1000000; // 345678 - var d34 = Math.floor(fract / 10000); - fract -= d34 * 10000; // 5678 - var d56 = Math.floor(fract / 100); - fract -= d56 * 100; // 78 - var d78 = Math.floor(fract); - - if (value < 0) { - d12 = 255 - d12; - } - - attributes[valueName] = new GeometryInstanceAttribute({ - componentDatatype: ComponentDatatype.UNSIGNED_BYTE, - componentsPerAttribute: 4, - normalize: false, - value: [d12, d34, d56, d78], - }); -} - -function encodeLessThan1000k(value, valueName, attributes) { - // Encode a value like -123456.78 to 4 uint8 values sign+12 34 56 78 - var fract = Math.abs(value); - var d12 = Math.floor(fract / 10000); - fract -= d12 * 10000; // 3456.78 - var d34 = Math.floor(fract / 100); - fract -= d34 * 100; // 56.78 - var d56 = Math.floor(fract); - fract -= d56; // 0.78 - var d78 = Math.floor(fract / 0.001); - - if (value < 0) { - d12 = 255 - d12; - } - - attributes[valueName] = new GeometryInstanceAttribute({ - componentDatatype: ComponentDatatype.UNSIGNED_BYTE, - componentsPerAttribute: 4, - normalize: false, - value: [d12, d34, d56, d78], - }); -} - var cartographicScratch = new Cartographic(); var cornerScratch = new Cartesian3(); var northWestScratch = new Cartesian3(); var southEastScratch = new Cartesian3(); var highLowScratch = { high: 0.0, low: 0.0 }; -function add2DTextureCoordinateAttributes( - rectangle, - projection, - attributes, - useFloatBatchTable -) { +function add2DTextureCoordinateAttributes(rectangle, projection, attributes) { // Compute corner positions in double precision var carto = cartographicScratch; carto.height = 0.0; @@ -597,29 +507,9 @@ function add2DTextureCoordinateAttributes( // z: y value for northWest // w: x value for southEast - var encoded; - if (!useFloatBatchTable) { - encoded = EncodedCartesian3.encode(southWestCorner.x, highLowScratch); - encodeHighLessThan100Million(encoded.high, "planes2D_HIGH_x", attributes); - encodeLowLessThan100k(encoded.low, "planes2D_LOW_x", attributes); - - encoded = EncodedCartesian3.encode(southWestCorner.y, highLowScratch); - encodeHighLessThan100Million(encoded.high, "planes2D_HIGH_y", attributes); - encodeLowLessThan100k(encoded.low, "planes2D_LOW_y", attributes); - - encoded = EncodedCartesian3.encode(northWest.y, highLowScratch); - encodeHighLessThan100Million(encoded.high, "planes2D_HIGH_z", attributes); - encodeLowLessThan100k(encoded.low, "planes2D_LOW_z", attributes); - - encoded = EncodedCartesian3.encode(southEast.x, highLowScratch); - encodeHighLessThan100Million(encoded.high, "planes2D_HIGH_w", attributes); - encodeLowLessThan100k(encoded.low, "planes2D_LOW_w", attributes); - return; - } - var valuesHigh = [0, 0, 0, 0]; var valuesLow = [0, 0, 0, 0]; - encoded = EncodedCartesian3.encode(southWestCorner.x, highLowScratch); + var encoded = EncodedCartesian3.encode(southWestCorner.x, highLowScratch); valuesHigh[0] = encoded.high; valuesLow[0] = encoded.low; @@ -782,7 +672,6 @@ var encodeScratch = new EncodedCartesian3(); * @param {Number[]} textureCoordinateRotationPoints Points in the computed texture coordinate system for remapping texture coordinates * @param {Ellipsoid} ellipsoid Ellipsoid for converting Rectangle points to world coordinates * @param {MapProjection} projection The MapProjection used for 2D and Columbus View. - * @param {Boolean} useFloatBatchTable Whether or not the ShadowVolumeAppearance should use floating point batch table values. * @param {Number} [height=0] The maximum height for the shadow volume. * @returns {Object} An attributes dictionary containing planar texture coordinate attributes. */ @@ -791,7 +680,6 @@ ShadowVolumeAppearance.getPlanarTextureCoordinateAttributes = function ( textureCoordinateRotationPoints, ellipsoid, projection, - useFloatBatchTable, height ) { //>>includeStart('debug', pragmas.debug); @@ -802,7 +690,6 @@ ShadowVolumeAppearance.getPlanarTextureCoordinateAttributes = function ( ); Check.typeOf.object("ellipsoid", ellipsoid); Check.typeOf.object("projection", projection); - Check.typeOf.bool("useFloatBatchTable", useFloatBatchTable); //>>includeEnd('debug'); var corner = cornerScratch; @@ -825,34 +712,6 @@ ShadowVolumeAppearance.getPlanarTextureCoordinateAttributes = function ( var encoded = EncodedCartesian3.fromCartesian(corner, encodeScratch); - if (!useFloatBatchTable) { - var high = encoded.high; - encodeHighLessThan100Million(high.x, "southWest_HIGH_x", attributes); - encodeHighLessThan100Million(high.y, "southWest_HIGH_y", attributes); - encodeHighLessThan100Million(high.z, "southWest_HIGH_z", attributes); - - var low = encoded.low; - encodeLowLessThan100k(low.x, "southWest_LOW_x", attributes); - encodeLowLessThan100k(low.y, "southWest_LOW_y", attributes); - encodeLowLessThan100k(low.z, "southWest_LOW_z", attributes); - - encodeLessThan1000k(eastward.x, "eastward_x", attributes); - encodeLessThan1000k(eastward.y, "eastward_y", attributes); - encodeLessThan1000k(eastward.z, "eastward_z", attributes); - - encodeLessThan1000k(northward.x, "northward_x", attributes); - encodeLessThan1000k(northward.y, "northward_y", attributes); - encodeLessThan1000k(northward.z, "northward_z", attributes); - - add2DTextureCoordinateAttributes( - boundingRectangle, - projection, - attributes, - false - ); - return attributes; - } - attributes.southWest_HIGH = new GeometryInstanceAttribute({ componentDatatype: ComponentDatatype.FLOAT, componentsPerAttribute: 3, @@ -878,12 +737,7 @@ ShadowVolumeAppearance.getPlanarTextureCoordinateAttributes = function ( value: Cartesian3.pack(northward, [0, 0, 0]), }); - add2DTextureCoordinateAttributes( - boundingRectangle, - projection, - attributes, - true - ); + add2DTextureCoordinateAttributes(boundingRectangle, projection, attributes); return attributes; }; @@ -936,15 +790,13 @@ var sphericalScratch = new Cartesian2(); * @param {Number[]} textureCoordinateRotationPoints Points in the computed texture coordinate system for remapping texture coordinates * @param {Ellipsoid} ellipsoid Ellipsoid for converting Rectangle points to world coordinates * @param {MapProjection} projection The MapProjection used for 2D and Columbus View. - * @param {Boolean} useFloatBatchTable Whether or not the ShadowVolumeAppearance should use floating point batch table values. * @returns {Object} An attributes dictionary containing spherical texture coordinate attributes. */ ShadowVolumeAppearance.getSphericalExtentGeometryInstanceAttributes = function ( boundingRectangle, textureCoordinateRotationPoints, ellipsoid, - projection, - useFloatBatchTable + projection ) { //>>includeStart('debug', pragmas.debug); Check.typeOf.object("boundingRectangle", boundingRectangle); @@ -954,7 +806,6 @@ ShadowVolumeAppearance.getSphericalExtentGeometryInstanceAttributes = function ( ); Check.typeOf.object("ellipsoid", ellipsoid); Check.typeOf.object("projection", projection); - Check.typeOf.bool("useFloatBatchTable", useFloatBatchTable); //>>includeEnd('debug'); // rectangle cartographic coords !== spherical because it's on an ellipsoid @@ -1014,19 +865,14 @@ ShadowVolumeAppearance.getSphericalExtentGeometryInstanceAttributes = function ( attributes, textureCoordinateRotationPoints ); - add2DTextureCoordinateAttributes( - boundingRectangle, - projection, - attributes, - useFloatBatchTable - ); + add2DTextureCoordinateAttributes(boundingRectangle, projection, attributes); return attributes; }; ShadowVolumeAppearance.hasAttributesForTextureCoordinatePlanes = function ( attributes ) { - var hasFloatAttributes = + return ( defined(attributes.southWest_HIGH) && defined(attributes.southWest_LOW) && defined(attributes.northward) && @@ -1034,61 +880,21 @@ ShadowVolumeAppearance.hasAttributesForTextureCoordinatePlanes = function ( defined(attributes.planes2D_HIGH) && defined(attributes.planes2D_LOW) && defined(attributes.uMaxVmax) && - defined(attributes.uvMinAndExtents); - - var hasUint8Attributes = - defined(attributes.southWest_HIGH_x) && - defined(attributes.southWest_LOW_x) && - defined(attributes.southWest_HIGH_y) && - defined(attributes.southWest_LOW_y) && - defined(attributes.southWest_HIGH_z) && - defined(attributes.southWest_LOW_z) && - defined(attributes.northward_x) && - defined(attributes.eastward_x) && - defined(attributes.northward_y) && - defined(attributes.eastward_y) && - defined(attributes.northward_z) && - defined(attributes.eastward_z) && - defined(attributes.planes2D_HIGH_x) && - defined(attributes.planes2D_LOW_x) && - defined(attributes.planes2D_HIGH_y) && - defined(attributes.planes2D_LOW_y) && - defined(attributes.planes2D_HIGH_z) && - defined(attributes.planes2D_LOW_z) && - defined(attributes.planes2D_HIGH_w) && - defined(attributes.planes2D_LOW_w) && - defined(attributes.uMaxVmax) && - defined(attributes.uvMinAndExtents); - - return hasFloatAttributes || hasUint8Attributes; + defined(attributes.uvMinAndExtents) + ); }; ShadowVolumeAppearance.hasAttributesForSphericalExtents = function ( attributes ) { - var hasFloatAttributes = + return ( defined(attributes.sphericalExtents) && defined(attributes.longitudeRotation) && defined(attributes.planes2D_HIGH) && defined(attributes.planes2D_LOW) && defined(attributes.uMaxVmax) && - defined(attributes.uvMinAndExtents); - - var hasUint8Attributes = - defined(attributes.sphericalExtents) && - defined(attributes.longitudeRotation) && - defined(attributes.planes2D_HIGH_x) && - defined(attributes.planes2D_LOW_x) && - defined(attributes.planes2D_HIGH_y) && - defined(attributes.planes2D_LOW_y) && - defined(attributes.planes2D_HIGH_z) && - defined(attributes.planes2D_LOW_z) && - defined(attributes.planes2D_HIGH_w) && - defined(attributes.planes2D_LOW_w) && - defined(attributes.uMaxVmax) && - defined(attributes.uvMinAndExtents); - - return hasFloatAttributes || hasUint8Attributes; + defined(attributes.uvMinAndExtents) + ); }; function shouldUseSpherical(rectangle) { diff --git a/Source/Shaders/CheckFloatTexturePrecisionFS.glsl b/Source/Shaders/CheckFloatTexturePrecisionFS.glsl deleted file mode 100644 index 8f77d167cef5..000000000000 --- a/Source/Shaders/CheckFloatTexturePrecisionFS.glsl +++ /dev/null @@ -1,8 +0,0 @@ -uniform sampler2D u_floatTexture; - -void main() -{ - float actual = texture2D(u_floatTexture, vec2(0.5, 0.5)).r; - float expected = 123456.0; - gl_FragColor = vec4(abs(actual - expected), 0.0, 0.0, 1.0); -} diff --git a/Source/Shaders/ShadowVolumeAppearanceFS.glsl b/Source/Shaders/ShadowVolumeAppearanceFS.glsl index 1f9de9b4f924..1231a8b0cbae 100644 --- a/Source/Shaders/ShadowVolumeAppearanceFS.glsl +++ b/Source/Shaders/ShadowVolumeAppearanceFS.glsl @@ -20,14 +20,12 @@ varying vec4 v_color; #endif #ifdef NORMAL_EC -vec3 getEyeCoordinate3FromWindowCoordinate(vec2 fragCoord, float logDepthOrDepth) -{ +vec3 getEyeCoordinate3FromWindowCoordinate(vec2 fragCoord, float logDepthOrDepth) { vec4 eyeCoordinate = czm_windowToEyeCoordinates(fragCoord, logDepthOrDepth); return eyeCoordinate.xyz / eyeCoordinate.w; } -vec3 vectorFromOffset(vec4 eyeCoordinate, vec2 positiveOffset) -{ +vec3 vectorFromOffset(vec4 eyeCoordinate, vec2 positiveOffset) { vec2 glFragCoordXY = gl_FragCoord.xy; // Sample depths at both offset and negative offset float upOrRightLogDepth = czm_unpackDepth(texture2D(czm_globeDepthTexture, (glFragCoordXY + positiveOffset) / czm_viewport.zw)); @@ -73,8 +71,7 @@ void main(void) #ifdef PICK #ifdef CULL_FRAGMENTS - if (0.0 <= uv.x && uv.x <= 1.0 && 0.0 <= uv.y && uv.y <= 1.0) - { + if (0.0 <= uv.x && uv.x <= 1.0 && 0.0 <= uv.y && uv.y <= 1.0) { gl_FragColor.a = 1.0; // 0.0 alpha leads to discard from ShaderSource.createPickFragmentShaderSource czm_writeDepthClampedToFarPlane(); } @@ -84,8 +81,7 @@ void main(void) #else // PICK #ifdef CULL_FRAGMENTS - if (uv.x <= 0.0 || 1.0 <= uv.x || uv.y <= 0.0 || 1.0 <= uv.y) - { + if (uv.x <= 0.0 || 1.0 <= uv.x || uv.y <= 0.0 || 1.0 <= uv.y) { discard; } #endif diff --git a/Source/Shaders/ShadowVolumeAppearanceVS.glsl b/Source/Shaders/ShadowVolumeAppearanceVS.glsl index b5d486c7de68..0f2b1c456a3b 100644 --- a/Source/Shaders/ShadowVolumeAppearanceVS.glsl +++ b/Source/Shaders/ShadowVolumeAppearanceVS.glsl @@ -25,88 +25,6 @@ varying vec3 v_uMaxAndInverseDistance; varying vec3 v_vMaxAndInverseDistance; #endif // TEXTURE_COORDINATES -#if defined(TEXTURE_COORDINATES) && !defined(SPHERICAL) && defined(UINT8_PACKING) -vec4 clampAndMagnitude(vec4 sd) -{ - vec4 d = sd; - d.x = czm_branchFreeTernary(sd.x < 128.0, d.x, (255.0 - sd.x)); - d.x = floor(0.5 + d.x); - d.y = floor(0.5 + d.y); - d.z = floor(0.5 + d.z); - d.w = floor(0.5 + d.w); - return d; -} - -float unpackLowLessThan100k(vec4 sd) -{ - vec4 d = clampAndMagnitude(sd); - return (1000.0 * d.x + 10.0 * d.y + 0.1 * d.z + 0.001 * d.w) * czm_branchFreeTernary(sd.x < 128.0, 1.0, -1.0); -} - -vec3 southwest_LOW(vec4 x, vec4 y, vec4 z) -{ - vec3 value; - value.x = unpackLowLessThan100k(x); - value.y = unpackLowLessThan100k(y); - value.z = unpackLowLessThan100k(z); - return value; -} - -float unpackHighMagLessThan100Million(vec4 sd) -{ - vec4 d = clampAndMagnitude(sd); - return (1000000.0 * d.x + 10000.0 * d.y + 100.0 * d.z + d.w) * czm_branchFreeTernary(sd.x < 128.0, 1.0, -1.0); -} - -vec3 southwest_HIGH(vec4 x, vec4 y, vec4 z) -{ - vec3 value; - value.x = unpackHighMagLessThan100Million(x); - value.y = unpackHighMagLessThan100Million(y); - value.z = unpackHighMagLessThan100Million(z); - return value; -} - -#ifdef COLUMBUS_VIEW_2D -vec4 unpackPlanes2D_HIGH(vec4 x, vec4 y, vec4 z, vec4 w) -{ - vec4 value; - value.x = unpackHighMagLessThan100Million(x); - value.y = unpackHighMagLessThan100Million(y); - value.z = unpackHighMagLessThan100Million(z); - value.w = unpackHighMagLessThan100Million(w); - return value; -} - -vec4 unpackPlanes2D_LOW(vec4 x, vec4 y, vec4 z, vec4 w) -{ - vec4 value; - value.x = unpackLowLessThan100k(x); - value.y = unpackLowLessThan100k(y); - value.z = unpackLowLessThan100k(z); - value.w = unpackLowLessThan100k(w); - return value; -} - -#else -float unpackLowLessThan1000k(vec4 sd) -{ - vec4 d = clampAndMagnitude(sd); - return (10000.0 * d.x + 100.0 * d.y + d.z + 0.01 * d.w) * czm_branchFreeTernary(sd.x < 128.0, 1.0, -1.0); -} - -vec3 unpackExtent(vec4 x, vec4 y, vec4 z) -{ - vec3 value; - value.x = unpackLowLessThan1000k(x); - value.y = unpackLowLessThan1000k(y); - value.z = unpackLowLessThan1000k(z); - return value; -} - -#endif -#endif - void main() { vec4 position = czm_computePosition(); @@ -125,19 +43,8 @@ void main() v_uvMinAndSphericalLongitudeRotation.z = czm_batchTable_longitudeRotation(batchId); #else // SPHERICAL #ifdef COLUMBUS_VIEW_2D -#ifdef UINT8_PACKING - vec4 planes2D_high = unpackPlanes2D_HIGH(czm_batchTable_planes2D_HIGH_x(batchId), - czm_batchTable_planes2D_HIGH_y(batchId), - czm_batchTable_planes2D_HIGH_z(batchId), - czm_batchTable_planes2D_HIGH_w(batchId)); - vec4 planes2D_low = unpackPlanes2D_LOW(czm_batchTable_planes2D_LOW_x(batchId), - czm_batchTable_planes2D_LOW_y(batchId), - czm_batchTable_planes2D_LOW_z(batchId), - czm_batchTable_planes2D_LOW_w(batchId)); -#else // UINT8_PACKING vec4 planes2D_high = czm_batchTable_planes2D_HIGH(batchId); vec4 planes2D_low = czm_batchTable_planes2D_LOW(batchId); -#endif // UINT8_PACKING // If the primitive is split across the IDL (planes2D_high.x > planes2D_high.w): // - If this vertex is on the east side of the IDL (position3DLow.y > 0.0, comparison with position3DHigh may produce artifacts) @@ -161,24 +68,9 @@ void main() vec3 southEastCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(vec3(0.0, planes2D_high.w, planes2D_high.y), vec3(0.0, planes2D_low.w, planes2D_low.y))).xyz; #else // COLUMBUS_VIEW_2D // 3D case has smaller "plane extents," so planes encoded as a 64 bit position and 2 vec3s for distances/direction -#ifdef UINT8_PACKING - vec3 low = southwest_LOW(czm_batchTable_southWest_LOW_x(batchId), czm_batchTable_southWest_LOW_y(batchId), czm_batchTable_southWest_LOW_z(batchId)); - vec3 high = southwest_HIGH(czm_batchTable_southWest_HIGH_x(batchId), czm_batchTable_southWest_HIGH_y(batchId), czm_batchTable_southWest_HIGH_z(batchId)); - vec3 southWestCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(high, low)).xyz; - vec3 northWestCorner = czm_normal * unpackExtent( - czm_batchTable_northward_x(batchId), - czm_batchTable_northward_y(batchId), - czm_batchTable_northward_z(batchId)) + southWestCorner; - - vec3 southEastCorner = czm_normal * unpackExtent( - czm_batchTable_eastward_x(batchId), - czm_batchTable_eastward_y(batchId), - czm_batchTable_eastward_z(batchId)) + southWestCorner; -#else // UINT8_PACKING vec3 southWestCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(czm_batchTable_southWest_HIGH(batchId), czm_batchTable_southWest_LOW(batchId))).xyz; vec3 northWestCorner = czm_normal * czm_batchTable_northward(batchId) + southWestCorner; vec3 southEastCorner = czm_normal * czm_batchTable_eastward(batchId) + southWestCorner; -#endif // UINT8_PACKING #endif // COLUMBUS_VIEW_2D vec3 eastWard = southEastCorner - southWestCorner; diff --git a/Specs/Renderer/ContextSpec.js b/Specs/Renderer/ContextSpec.js index 56ace0151714..1d1620a8fd25 100644 --- a/Specs/Renderer/ContextSpec.js +++ b/Specs/Renderer/ContextSpec.js @@ -174,8 +174,8 @@ describe( expect(context.floatingPointTexture).toBeDefined(); }); - it("gets whether the texture float has 6 places of precision", function () { - expect(context.floatTextureSixPlaces).toBeDefined(); + it("gets texture filter anisotropic extension", function () { + expect(context.textureFilterAnisotropic).toBeDefined(); }); it("gets texture filter anisotropic extension", function () { diff --git a/Specs/Renderer/checkFloatTexturePrecisionSpec.js b/Specs/Renderer/checkFloatTexturePrecisionSpec.js deleted file mode 100644 index 0ff6e473dbe6..000000000000 --- a/Specs/Renderer/checkFloatTexturePrecisionSpec.js +++ /dev/null @@ -1,44 +0,0 @@ -import { checkFloatTexturePrecision } from "../../Source/Cesium.js"; -import { PixelDatatype } from "../../Source/Cesium.js"; -import createContext from "../createContext.js"; - -describe( - "Renderer/checkFloatTexturePrecision", - function () { - var context; - - beforeAll(function () { - context = createContext(); - }); - - afterAll(function () { - context.destroyForSpecs(); - }); - - it("returns false when float textures are not available", function () { - expect(checkFloatTexturePrecision({ floatingPointTexture: false })).toBe( - false - ); - }); - - it("returns false when float textures are of insufficient precision", function () { - if (!context.floatingPointTexture) { - return; - } - - spyOn(checkFloatTexturePrecision, "_getFloatPixelType").and.callFake( - function () { - return PixelDatatype.HALF_FLOAT; - } - ); - spyOn(checkFloatTexturePrecision, "_getArray").and.callFake(function ( - array - ) { - return new Uint16Array(array); - }); - - expect(checkFloatTexturePrecision(context)).toBe(false); - }); - }, - "WebGL" -); diff --git a/Specs/Scene/ShadowVolumeAppearanceSpec.js b/Specs/Scene/ShadowVolumeAppearanceSpec.js index f66b865f2bc4..f6ff26afc902 100644 --- a/Specs/Scene/ShadowVolumeAppearanceSpec.js +++ b/Specs/Scene/ShadowVolumeAppearanceSpec.js @@ -33,29 +33,13 @@ describe("Scene/ShadowVolumeAppearance", function () { largeTestRectangle, [0, 0, 0, 1, 1, 0], unitSphereEllipsoid, - projection, - true + projection ); var smallRectangleAttributes = ShadowVolumeAppearance.getPlanarTextureCoordinateAttributes( smallTestRectangle, [0, 0, 0, 1, 1, 0], unitSphereEllipsoid, - projection, - true - ); - var largeRectangleAttributesBadFloats = ShadowVolumeAppearance.getSphericalExtentGeometryInstanceAttributes( - largeTestRectangle, - [0, 0, 0, 1, 1, 0], - unitSphereEllipsoid, - projection, - false - ); - var smallRectangleAttributesBadFloats = ShadowVolumeAppearance.getPlanarTextureCoordinateAttributes( - smallTestRectangle, - [0, 0, 0, 1, 1, 0], - unitSphereEllipsoid, - projection, - false + projection ); var perInstanceColorMaterialAppearance = new PerInstanceColorAppearance(); @@ -155,53 +139,6 @@ describe("Scene/ShadowVolumeAppearance", function () { expect(attribute.normalize).toEqual(false); } - function clampAndMagnitude(signedVec4Attribute) { - var signedVec4 = signedVec4Attribute.value; - var unsigned = signedVec4.slice(); - unsigned[0] = signedVec4[0] < 128.0 ? signedVec4[0] : 255.0 - signedVec4[0]; - unsigned[0] = Math.floor(0.5 + unsigned[0]); - unsigned[1] = Math.floor(0.5 + unsigned[1]); - unsigned[2] = Math.floor(0.5 + unsigned[2]); - unsigned[3] = Math.floor(0.5 + unsigned[3]); - return unsigned; - } - - function unpackLowLessThan100k(signedVec4Attribute) { - var signed = signedVec4Attribute.value; - var unsigned = clampAndMagnitude(signedVec4Attribute); - return ( - (1000.0 * unsigned[0] + - 10.0 * unsigned[1] + - 0.1 * unsigned[2] + - 0.001 * unsigned[3]) * - (signed[0] < 128.0 ? 1.0 : -1.0) - ); - } - - function unpackHighMagLessThan100Million(signedVec4Attribute) { - var signed = signedVec4Attribute.value; - var unsigned = clampAndMagnitude(signedVec4Attribute); - return ( - (1000000.0 * unsigned[0] + - 10000.0 * unsigned[1] + - 100.0 * unsigned[2] + - unsigned[3]) * - (signed[0] < 128.0 ? 1.0 : -1.0) - ); - } - - function unpackLowLessThan1000k(signedVec4Attribute) { - var signed = signedVec4Attribute.value; - var unsigned = clampAndMagnitude(signedVec4Attribute); - return ( - (10000.0 * unsigned[0] + - 100.0 * unsigned[1] + - unsigned[2] + - 0.01 * unsigned[3]) * - (signed[0] < 128.0 ? 1.0 : -1.0) - ); - } - describe("floating point textures reliable", function () { it("provides attributes for computing texture coordinates using planes in 3D", function () { var attributes = smallRectangleAttributes; @@ -335,180 +272,6 @@ describe("Scene/ShadowVolumeAppearance", function () { }); }); - describe("floating point textures unreliable", function () { - it("provides attributes for computing texture coordinates using planes in 3D", function () { - var attributes = smallRectangleAttributesBadFloats; - - var southWest_LOW = [0, 0, 0]; - southWest_LOW[0] = unpackLowLessThan100k(attributes.southWest_LOW_x); - southWest_LOW[1] = unpackLowLessThan100k(attributes.southWest_LOW_y); - southWest_LOW[2] = unpackLowLessThan100k(attributes.southWest_LOW_z); - - var southWest_HIGH = [0, 0, 0]; - southWest_HIGH[0] = unpackHighMagLessThan100Million( - attributes.southWest_HIGH_x - ); - southWest_HIGH[1] = unpackHighMagLessThan100Million( - attributes.southWest_HIGH_y - ); - southWest_HIGH[2] = unpackHighMagLessThan100Million( - attributes.southWest_HIGH_z - ); - - var eastward = [0, 0, 0]; - eastward[0] = unpackLowLessThan1000k(attributes.eastward_x); - eastward[1] = unpackLowLessThan1000k(attributes.eastward_y); - eastward[2] = unpackLowLessThan1000k(attributes.eastward_z); - - var northward = [0, 0, 0]; - northward[0] = unpackLowLessThan1000k(attributes.northward_x); - northward[1] = unpackLowLessThan1000k(attributes.northward_y); - northward[2] = unpackLowLessThan1000k(attributes.northward_z); - - // We're using a unit sphere, so expect all HIGH values to be basically 0 - // and LOW value to be within a small cone around UNIT_X - expect(southWest_HIGH[0]).toEqualEpsilon(0.0, CesiumMath.EPSILON2); - expect(southWest_HIGH[1]).toEqualEpsilon(0.0, CesiumMath.EPSILON2); - expect(southWest_HIGH[2]).toEqualEpsilon(0.0, CesiumMath.EPSILON2); - - expect(southWest_LOW[0]).toBeGreaterThan( - Math.cos(CesiumMath.toRadians(0.2)) - ); - - // Expect eastward and northward to be unit-direction vectors in the ENU coordinate system at the rectangle center - var smallRectangleCenter = Cartographic.toCartesian( - Rectangle.center(smallTestRectangle), - unitSphereEllipsoid - ); - var enuMatrix = Transforms.eastNorthUpToFixedFrame( - smallRectangleCenter, - unitSphereEllipsoid - ); - var inverseEnu = Matrix4.inverse(enuMatrix, new Matrix4()); - - var eastwardENU = Matrix4.multiplyByPointAsVector( - inverseEnu, - Cartesian3.fromArray(eastward), - new Cartesian3() - ); - eastwardENU = Cartesian3.normalize(eastwardENU, eastwardENU); - expect( - Cartesian3.equalsEpsilon( - eastwardENU, - Cartesian3.UNIT_X, - CesiumMath.EPSILON2 - ) - ).toBe(true); - - var northwardENU = Matrix4.multiplyByPointAsVector( - inverseEnu, - Cartesian3.fromArray(northward), - new Cartesian3() - ); - northwardENU = Cartesian3.normalize(northwardENU, northwardENU); - expect( - Cartesian3.equalsEpsilon( - northwardENU, - Cartesian3.UNIT_Y, - CesiumMath.EPSILON2 - ) - ).toBe(true); - }); - - it("provides attributes for computing planes in 2D and Columbus View", function () { - var attributes = largeRectangleAttributesBadFloats; - var highValue = [0, 0, 0, 0]; - highValue[0] = unpackHighMagLessThan100Million( - attributes.planes2D_HIGH_x - ); - highValue[1] = unpackHighMagLessThan100Million( - attributes.planes2D_HIGH_y - ); - highValue[2] = unpackHighMagLessThan100Million( - attributes.planes2D_HIGH_z - ); - highValue[3] = unpackHighMagLessThan100Million( - attributes.planes2D_HIGH_w - ); - - var lowValue = [0, 0, 0, 0]; - lowValue[0] = unpackLowLessThan100k(attributes.planes2D_LOW_x); - lowValue[1] = unpackLowLessThan100k(attributes.planes2D_LOW_y); - lowValue[2] = unpackLowLessThan100k(attributes.planes2D_LOW_z); - lowValue[3] = unpackLowLessThan100k(attributes.planes2D_LOW_w); - - // Because using a unit sphere expect all HIGH values to be basically 0 - expect(highValue[0]).toEqualEpsilon(0.0, CesiumMath.EPSILON2); - expect(highValue[1]).toEqualEpsilon(0.0, CesiumMath.EPSILON2); - expect(highValue[2]).toEqualEpsilon(0.0, CesiumMath.EPSILON2); - expect(highValue[3]).toEqualEpsilon(0.0, CesiumMath.EPSILON2); - - var cartographic = Cartographic.fromDegrees(-45, -45, 0.0); // southwest corner - var southwestCartesian = projection.project(cartographic); - expect(lowValue[0]).toEqualEpsilon( - southwestCartesian.x, - CesiumMath.EPSILON2 - ); - expect(lowValue[1]).toEqualEpsilon( - southwestCartesian.y, - CesiumMath.EPSILON2 - ); - expect(lowValue[2]).toEqualEpsilon( - -southwestCartesian.y, - CesiumMath.EPSILON2 - ); - expect(lowValue[3]).toEqualEpsilon( - -southwestCartesian.x, - CesiumMath.EPSILON2 - ); - - // Small case - attributes = smallRectangleAttributesBadFloats; - // Because using a unit sphere expect all HIGH values to be basically 0 - highValue[0] = unpackHighMagLessThan100Million( - attributes.planes2D_HIGH_x - ); - highValue[1] = unpackHighMagLessThan100Million( - attributes.planes2D_HIGH_y - ); - highValue[2] = unpackHighMagLessThan100Million( - attributes.planes2D_HIGH_z - ); - highValue[3] = unpackHighMagLessThan100Million( - attributes.planes2D_HIGH_w - ); - - expect(highValue[0]).toEqualEpsilon(0.0, CesiumMath.EPSILON2); - expect(highValue[1]).toEqualEpsilon(0.0, CesiumMath.EPSILON2); - expect(highValue[2]).toEqualEpsilon(0.0, CesiumMath.EPSILON2); - expect(highValue[3]).toEqualEpsilon(0.0, CesiumMath.EPSILON2); - - cartographic = Cartographic.fromDegrees(-0.1, -0.1, 0.0); // southwest corner - southwestCartesian = projection.project(cartographic); - lowValue[0] = unpackLowLessThan100k(attributes.planes2D_LOW_x); - lowValue[1] = unpackLowLessThan100k(attributes.planes2D_LOW_y); - lowValue[2] = unpackLowLessThan100k(attributes.planes2D_LOW_z); - lowValue[3] = unpackLowLessThan100k(attributes.planes2D_LOW_w); - - expect(lowValue[0]).toEqualEpsilon( - southwestCartesian.x, - CesiumMath.EPSILON2 - ); - expect(lowValue[1]).toEqualEpsilon( - southwestCartesian.y, - CesiumMath.EPSILON2 - ); - expect(lowValue[2]).toEqualEpsilon( - -southwestCartesian.y, - CesiumMath.EPSILON2 - ); - expect(lowValue[3]).toEqualEpsilon( - -southwestCartesian.x, - CesiumMath.EPSILON2 - ); - }); - }); - it("provides attributes for rotating texture coordinates", function () { // 90 degree rotation of a square, so "max" in Y direction is (0,0), "max" in X direction is (1,1) var attributes = ShadowVolumeAppearance.getPlanarTextureCoordinateAttributes( @@ -516,7 +279,6 @@ describe("Scene/ShadowVolumeAppearance", function () { [1, 0, 0, 0, 1, 1], unitSphereEllipsoid, projection, - false, 0.0 ); @@ -555,16 +317,6 @@ describe("Scene/ShadowVolumeAppearance", function () { largeRectangleAttributes ) ).toBe(true); - expect( - ShadowVolumeAppearance.hasAttributesForSphericalExtents( - smallRectangleAttributesBadFloats - ) - ).toBe(false); - expect( - ShadowVolumeAppearance.hasAttributesForSphericalExtents( - largeRectangleAttributesBadFloats - ) - ).toBe(true); }); it("checks for planar texture coordinate attributes", function () { @@ -578,16 +330,6 @@ describe("Scene/ShadowVolumeAppearance", function () { largeRectangleAttributes ) ).toBe(false); - expect( - ShadowVolumeAppearance.hasAttributesForTextureCoordinatePlanes( - smallRectangleAttributesBadFloats - ) - ).toBe(true); - expect( - ShadowVolumeAppearance.hasAttributesForTextureCoordinatePlanes( - largeRectangleAttributesBadFloats - ) - ).toBe(false); }); it("checks if a rectangle should use spherical texture coordinates", function () { @@ -599,70 +341,12 @@ describe("Scene/ShadowVolumeAppearance", function () { ).toBe(true); }); - it("creates vertex shaders based on whether or not float textures are used for high/low positions", function () { - // Check defines - var sphericalTexturedAppearanceUnsafe = new ShadowVolumeAppearance( - true, - false, - textureMaterialAppearance, - false - ); - var shaderSource = sphericalTexturedAppearanceUnsafe.createVertexShader( - [], - testVs, - false, - projection - ); - var defines = shaderSource.defines; - expect(defines.length).toEqual(3); - expect(defines.indexOf("UINT8_PACKING")).not.toEqual(-1); - - // 2D variant - shaderSource = sphericalTexturedAppearanceUnsafe.createVertexShader( - [], - testVs, - true, - projection - ); - defines = shaderSource.defines; - expect(defines.length).toEqual(7); - expect(defines.indexOf("UINT8_PACKING")).not.toEqual(-1); - - var sphericalTexturedAppearanceSafe = new ShadowVolumeAppearance( - true, - false, - textureMaterialAppearance, - true - ); - shaderSource = sphericalTexturedAppearanceSafe.createVertexShader( - [], - testVs, - false, - projection - ); - defines = shaderSource.defines; - expect(defines.length).toEqual(2); - expect(defines.indexOf("UINT8_PACKING")).toEqual(-1); - - // 2D variant - shaderSource = sphericalTexturedAppearanceSafe.createVertexShader( - [], - testVs, - true, - projection - ); - defines = shaderSource.defines; - expect(defines.length).toEqual(6); - expect(defines.indexOf("UINT8_PACKING")).toEqual(-1); - }); - it("creates vertex shaders for color", function () { // Check defines var sphericalTexturedAppearance = new ShadowVolumeAppearance( true, false, - textureMaterialAppearance, - true + textureMaterialAppearance ); var shaderSource = sphericalTexturedAppearance.createVertexShader( [], @@ -696,8 +380,7 @@ describe("Scene/ShadowVolumeAppearance", function () { var sphericalUnculledColorAppearance = new ShadowVolumeAppearance( false, false, - perInstanceColorMaterialAppearance, - true + perInstanceColorMaterialAppearance ); shaderSource = sphericalUnculledColorAppearance.createVertexShader( [], @@ -730,8 +413,7 @@ describe("Scene/ShadowVolumeAppearance", function () { var planarTexturedAppearance = new ShadowVolumeAppearance( false, true, - textureMaterialAppearance, - true + textureMaterialAppearance ); shaderSource = planarTexturedAppearance.createVertexShader( [], @@ -766,8 +448,7 @@ describe("Scene/ShadowVolumeAppearance", function () { var sphericalTexturedAppearance = new ShadowVolumeAppearance( true, false, - textureMaterialAppearance, - true + textureMaterialAppearance ); var shaderSource = sphericalTexturedAppearance.createPickVertexShader( [], @@ -801,8 +482,7 @@ describe("Scene/ShadowVolumeAppearance", function () { var sphericalUnculledColorAppearance = new ShadowVolumeAppearance( false, false, - perInstanceColorMaterialAppearance, - true + perInstanceColorMaterialAppearance ); shaderSource = sphericalUnculledColorAppearance.createPickVertexShader( [], @@ -833,8 +513,7 @@ describe("Scene/ShadowVolumeAppearance", function () { var planarTexturedAppearance = new ShadowVolumeAppearance( false, true, - textureMaterialAppearance, - true + textureMaterialAppearance ); shaderSource = planarTexturedAppearance.createPickVertexShader( [], @@ -866,8 +545,7 @@ describe("Scene/ShadowVolumeAppearance", function () { var sphericalTexturedAppearance = new ShadowVolumeAppearance( true, false, - textureMaterialAppearance, - true + textureMaterialAppearance ); var shaderSource = sphericalTexturedAppearance.createFragmentShader(false); var defines = shaderSource.defines; @@ -904,8 +582,7 @@ describe("Scene/ShadowVolumeAppearance", function () { var planarColorAppearance = new ShadowVolumeAppearance( true, true, - perInstanceColorMaterialAppearance, - true + perInstanceColorMaterialAppearance ); shaderSource = planarColorAppearance.createFragmentShader(false); defines = shaderSource.defines; @@ -933,8 +610,7 @@ describe("Scene/ShadowVolumeAppearance", function () { var flatSphericalTexturedAppearance = new ShadowVolumeAppearance( true, false, - flatTextureMaterialAppearance, - true + flatTextureMaterialAppearance ); shaderSource = flatSphericalTexturedAppearance.createFragmentShader(false); defines = shaderSource.defines; @@ -953,8 +629,7 @@ describe("Scene/ShadowVolumeAppearance", function () { var flatSphericalColorAppearance = new ShadowVolumeAppearance( false, false, - flatPerInstanceColorMaterialAppearance, - true + flatPerInstanceColorMaterialAppearance ); shaderSource = flatSphericalColorAppearance.createFragmentShader(false); defines = shaderSource.defines; From 15f5ce9688f0f7becac8337f4e3b55e4a57027c2 Mon Sep 17 00:00:00 2001 From: YoussefV Date: Tue, 28 Apr 2020 18:21:03 -0400 Subject: [PATCH 3/5] fixed incorrect merge in CHANGES.md --- CHANGES.md | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d9a45e25836e..805583d6224a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -205,8 +205,6 @@ var viewer = new Viewer("cesiumContainer", { ##### Fixes :wrench: -<<<<<<< HEAD - - Fixed labels not showing for individual entities in data sources when clustering is enabled. [#6087](https://github.com/CesiumGS/cesium/issues/6087) - Fixed an issue where polygons, corridors, rectangles, and ellipses on terrain would not render on some mobile devices. [#6739](https://github.com/CesiumGS/cesium/issues/6739) - Fixed a bug where GlobeSurfaceTile would not render the tile until all layers completed loading causing globe to appear to hang. [#7974](https://github.com/CesiumGS/cesium/issues/7974) @@ -225,23 +223,7 @@ var viewer = new Viewer("cesiumContainer", { - Reduced size of approximateTerrainHeights.json [#7959](https://github.com/CesiumGS/cesium/pull/7959) - Fixed undefined `quadDetails` error from zooming into the map really close. [#8011](https://github.com/CesiumGS/cesium/pull/8011) - Fixed a crash for 3D Tiles that have zero volume. [#7945](https://github.com/CesiumGS/cesium/pull/7945) -- # Fixed relative-to-center check, `depthFailAppearance` resource freeing for `Primitive` [#8044](https://github.com/CesiumGS/cesium/pull/8044) - -* `Camera.flyTo` flies to the correct location in 2D when the destination crosses the international date line [#7909](https://github.com/AnalyticalGraphicsInc/cesium/pull/7909) -* Fixed 3D tiles style coloring when multiple tilesets are in the scene [#8051](https://github.com/AnalyticalGraphicsInc/cesium/pull/8051) -* Improved display of tile coordinates for `TileCoordinatesImageryProvider` [#8131](https://github.com/AnalyticalGraphicsInc/cesium/pull/8131) -* Fixed relative-to-center check, `depthFailAppearance` resource freeing for `Primitive` [#8044](https://github.com/AnalyticalGraphicsInc/cesium/pull/8044) -* Reduces size of approximateTerrainHeights.json by rounding the numbers [#7959](https://github.com/AnalyticalGraphicsInc/cesium/pull/7959) -* Fixed undefined `quadDetails` error from zooming into the map really close. [#8011](https://github.com/AnalyticalGraphicsInc/cesium/pull/8011) -* Fixed a bug where extruded polygons would sometimes be missing segments. [#8035](https://github.com/AnalyticalGraphicsInc/cesium/pull/8035) -* 3D Tiles geometric error now scales with transform. [#8182](https://github.com/AnalyticalGraphicsInc/cesium/pull/8182) -* Fixed per-feature post processing from sometimes selecting the wrong feature. [#7929](https://github.com/AnalyticalGraphicsInc/cesium/pull/7929) -* Fixed labels not showing for individual entities in data sources when clustering is enabled. [#6087](https://github.com/AnalyticalGraphicsInc/cesium/issues/6087) -* Fixed a crash for 3D Tiles that have zero volume. [#7945](https://github.com/AnalyticalGraphicsInc/cesium/pull/7945) -* Fixed a bug where dynamic polylines did not use the given arcType. [#8191](https://github.com/AnalyticalGraphicsInc/cesium/issues/8191) -* Fixed a bug where GlobeSurfaceTile would not render the tile until all layers completed loading causing globe to appear to hang. [#7974](https://github.com/AnalyticalGraphicsInc/cesium/issues/7974) -* Fixed alpha equation for `BlendingState.ALPHA_BLEND` and `BlendingState.ADDITIVE_BLEND`. [#8202](https://github.com/AnalyticalGraphicsInc/cesium/pull/8202) - > > > > > > > parent of 8bd1c61c17... Merge pull request #7421 from AnalyticalGraphicsInc/mtls-on-groundPrimitives-iOS +- Fixed relative-to-center check, `depthFailAppearance` resource freeing for `Primitive` [#8044](https://github.com/CesiumGS/cesium/pull/8044) ### 1.61 - 2019-09-03 From 050b74107080dbb7f92b1c12a17f43878b5a5c20 Mon Sep 17 00:00:00 2001 From: YoussefV Date: Wed, 29 Apr 2020 13:57:56 -0400 Subject: [PATCH 4/5] updated CHANGES.md, removed describe block that was used to distinguish unreliable floats --- CHANGES.md | 1 + Specs/Scene/ShadowVolumeAppearanceSpec.js | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 805583d6224a..50d101b96648 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,6 +18,7 @@ - Fixed an issue with glTF skinning support where an optional property `skeleton` was considered required by Cesium. [#8175](https://github.com/CesiumGS/cesium/issues/8175) - Fixed a bug with very long view ranges requiring multiple frustums even with the logarithmic depth buffer enabled. Previously, such scenes could resolve depth incorrectly. [#8727](https://github.com/CesiumGS/cesium/pull/8727) - Fixed a bug where the elevation contour material's alpha was not being applied. [#8749](https://github.com/CesiumGS/cesium/pull/8749) +- Geometry instance floats now work for high precision floats on newer iOS devices. [#8805](https://github.com/CesiumGS/cesium/pull/8805) ### 1.68.0 - 2020-04-01 diff --git a/Specs/Scene/ShadowVolumeAppearanceSpec.js b/Specs/Scene/ShadowVolumeAppearanceSpec.js index f6ff26afc902..85360eff61e8 100644 --- a/Specs/Scene/ShadowVolumeAppearanceSpec.js +++ b/Specs/Scene/ShadowVolumeAppearanceSpec.js @@ -139,8 +139,7 @@ describe("Scene/ShadowVolumeAppearance", function () { expect(attribute.normalize).toEqual(false); } - describe("floating point textures reliable", function () { - it("provides attributes for computing texture coordinates using planes in 3D", function () { + it("provides attributes for computing texture coordinates using planes in 3D", function () { var attributes = smallRectangleAttributes; var southWest_LOW = attributes.southWest_LOW; @@ -203,7 +202,7 @@ describe("Scene/ShadowVolumeAppearance", function () { ).toBe(true); }); - it("provides attributes for computing planes in 2D and Columbus View", function () { + it("provides attributes for computing planes in 2D and Columbus View", function () { var planes2D_HIGH = largeRectangleAttributes.planes2D_HIGH; var planes2D_LOW = largeRectangleAttributes.planes2D_LOW; @@ -269,7 +268,6 @@ describe("Scene/ShadowVolumeAppearance", function () { -southwestCartesian.x, CesiumMath.EPSILON7 ); - }); }); it("provides attributes for rotating texture coordinates", function () { From 0eafb467d119f584177592f48dd70cf417724691 Mon Sep 17 00:00:00 2001 From: Kangning Li Date: Wed, 29 Apr 2020 14:07:34 -0400 Subject: [PATCH 5/5] fix indentation in ShadowVolumeAppearanceSpec --- Specs/Scene/ShadowVolumeAppearanceSpec.js | 250 +++++++++++----------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/Specs/Scene/ShadowVolumeAppearanceSpec.js b/Specs/Scene/ShadowVolumeAppearanceSpec.js index 85360eff61e8..fd5e69eff2a0 100644 --- a/Specs/Scene/ShadowVolumeAppearanceSpec.js +++ b/Specs/Scene/ShadowVolumeAppearanceSpec.js @@ -140,134 +140,134 @@ describe("Scene/ShadowVolumeAppearance", function () { } it("provides attributes for computing texture coordinates using planes in 3D", function () { - var attributes = smallRectangleAttributes; - - var southWest_LOW = attributes.southWest_LOW; - var southWest_HIGH = attributes.southWest_HIGH; - var eastward = attributes.eastward; - var northward = attributes.northward; - - checkGeometryInstanceAttributeVec3(southWest_LOW); - checkGeometryInstanceAttributeVec3(southWest_HIGH); - checkGeometryInstanceAttributeVec3(eastward); - checkGeometryInstanceAttributeVec3(northward); - - // We're using a unit sphere, so expect all HIGH values to be basically 0 - // and LOW value to be within a small cone around UNIT_X - expect(southWest_HIGH.value[0]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); - expect(southWest_HIGH.value[1]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); - expect(southWest_HIGH.value[2]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); - - expect(southWest_LOW.value[0]).toBeGreaterThan( - Math.cos(CesiumMath.toRadians(0.2)) - ); - - // Expect eastward and northward to be unit-direction vectors in the ENU coordinate system at the rectangle center - var smallRectangleCenter = Cartographic.toCartesian( - Rectangle.center(smallTestRectangle), - unitSphereEllipsoid - ); - var enuMatrix = Transforms.eastNorthUpToFixedFrame( - smallRectangleCenter, - unitSphereEllipsoid - ); - var inverseEnu = Matrix4.inverse(enuMatrix, new Matrix4()); - - var eastwardENU = Matrix4.multiplyByPointAsVector( - inverseEnu, - Cartesian3.fromArray(eastward.value), - new Cartesian3() - ); - eastwardENU = Cartesian3.normalize(eastwardENU, eastwardENU); - expect( - Cartesian3.equalsEpsilon( - eastwardENU, - Cartesian3.UNIT_X, - CesiumMath.EPSILON7 - ) - ).toBe(true); - - var northwardENU = Matrix4.multiplyByPointAsVector( - inverseEnu, - Cartesian3.fromArray(northward.value), - new Cartesian3() - ); - northwardENU = Cartesian3.normalize(northwardENU, northwardENU); - expect( - Cartesian3.equalsEpsilon( - northwardENU, - Cartesian3.UNIT_Y, - CesiumMath.EPSILON7 - ) - ).toBe(true); - }); + var attributes = smallRectangleAttributes; + + var southWest_LOW = attributes.southWest_LOW; + var southWest_HIGH = attributes.southWest_HIGH; + var eastward = attributes.eastward; + var northward = attributes.northward; + + checkGeometryInstanceAttributeVec3(southWest_LOW); + checkGeometryInstanceAttributeVec3(southWest_HIGH); + checkGeometryInstanceAttributeVec3(eastward); + checkGeometryInstanceAttributeVec3(northward); + + // We're using a unit sphere, so expect all HIGH values to be basically 0 + // and LOW value to be within a small cone around UNIT_X + expect(southWest_HIGH.value[0]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); + expect(southWest_HIGH.value[1]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); + expect(southWest_HIGH.value[2]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); + + expect(southWest_LOW.value[0]).toBeGreaterThan( + Math.cos(CesiumMath.toRadians(0.2)) + ); - it("provides attributes for computing planes in 2D and Columbus View", function () { - var planes2D_HIGH = largeRectangleAttributes.planes2D_HIGH; - var planes2D_LOW = largeRectangleAttributes.planes2D_LOW; - - expect(planes2D_HIGH.componentDatatype).toEqual(ComponentDatatype.FLOAT); - expect(planes2D_HIGH.componentsPerAttribute).toEqual(4); - expect(planes2D_HIGH.normalize).toEqual(false); - - // Because using a unit sphere expect all HIGH values to be basically 0 - var highValue = planes2D_HIGH.value; - expect(highValue[0]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); - expect(highValue[1]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); - expect(highValue[2]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); - expect(highValue[3]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); - - expect(planes2D_LOW.componentDatatype).toEqual(ComponentDatatype.FLOAT); - expect(planes2D_LOW.componentsPerAttribute).toEqual(4); - expect(planes2D_LOW.normalize).toEqual(false); - - var cartographic = Cartographic.fromDegrees(-45, -45, 0.0); // southwest corner - var southwestCartesian = projection.project(cartographic); - var lowValue = planes2D_LOW.value; - expect(lowValue[0]).toEqualEpsilon( - southwestCartesian.x, - CesiumMath.EPSILON7 - ); - expect(lowValue[1]).toEqualEpsilon( - southwestCartesian.y, - CesiumMath.EPSILON7 - ); - expect(lowValue[2]).toEqualEpsilon( - -southwestCartesian.y, - CesiumMath.EPSILON7 - ); - expect(lowValue[3]).toEqualEpsilon( - -southwestCartesian.x, - CesiumMath.EPSILON7 - ); - - // Small case - // Because using a unit sphere expect all HIGH values to be basically 0 - highValue = smallRectangleAttributes.planes2D_HIGH.value; - expect(highValue[0]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); - expect(highValue[1]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); - expect(highValue[2]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); - expect(highValue[3]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); - - cartographic = Cartographic.fromDegrees(-0.1, -0.1, 0.0); // southwest corner - southwestCartesian = projection.project(cartographic); - lowValue = smallRectangleAttributes.planes2D_LOW.value; - expect(lowValue[0]).toEqualEpsilon( - southwestCartesian.x, - CesiumMath.EPSILON7 - ); - expect(lowValue[1]).toEqualEpsilon( - southwestCartesian.y, - CesiumMath.EPSILON7 - ); - expect(lowValue[2]).toEqualEpsilon( - -southwestCartesian.y, + // Expect eastward and northward to be unit-direction vectors in the ENU coordinate system at the rectangle center + var smallRectangleCenter = Cartographic.toCartesian( + Rectangle.center(smallTestRectangle), + unitSphereEllipsoid + ); + var enuMatrix = Transforms.eastNorthUpToFixedFrame( + smallRectangleCenter, + unitSphereEllipsoid + ); + var inverseEnu = Matrix4.inverse(enuMatrix, new Matrix4()); + + var eastwardENU = Matrix4.multiplyByPointAsVector( + inverseEnu, + Cartesian3.fromArray(eastward.value), + new Cartesian3() + ); + eastwardENU = Cartesian3.normalize(eastwardENU, eastwardENU); + expect( + Cartesian3.equalsEpsilon( + eastwardENU, + Cartesian3.UNIT_X, CesiumMath.EPSILON7 - ); - expect(lowValue[3]).toEqualEpsilon( - -southwestCartesian.x, + ) + ).toBe(true); + + var northwardENU = Matrix4.multiplyByPointAsVector( + inverseEnu, + Cartesian3.fromArray(northward.value), + new Cartesian3() + ); + northwardENU = Cartesian3.normalize(northwardENU, northwardENU); + expect( + Cartesian3.equalsEpsilon( + northwardENU, + Cartesian3.UNIT_Y, CesiumMath.EPSILON7 - ); + ) + ).toBe(true); + }); + + it("provides attributes for computing planes in 2D and Columbus View", function () { + var planes2D_HIGH = largeRectangleAttributes.planes2D_HIGH; + var planes2D_LOW = largeRectangleAttributes.planes2D_LOW; + + expect(planes2D_HIGH.componentDatatype).toEqual(ComponentDatatype.FLOAT); + expect(planes2D_HIGH.componentsPerAttribute).toEqual(4); + expect(planes2D_HIGH.normalize).toEqual(false); + + // Because using a unit sphere expect all HIGH values to be basically 0 + var highValue = planes2D_HIGH.value; + expect(highValue[0]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); + expect(highValue[1]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); + expect(highValue[2]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); + expect(highValue[3]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); + + expect(planes2D_LOW.componentDatatype).toEqual(ComponentDatatype.FLOAT); + expect(planes2D_LOW.componentsPerAttribute).toEqual(4); + expect(planes2D_LOW.normalize).toEqual(false); + + var cartographic = Cartographic.fromDegrees(-45, -45, 0.0); // southwest corner + var southwestCartesian = projection.project(cartographic); + var lowValue = planes2D_LOW.value; + expect(lowValue[0]).toEqualEpsilon( + southwestCartesian.x, + CesiumMath.EPSILON7 + ); + expect(lowValue[1]).toEqualEpsilon( + southwestCartesian.y, + CesiumMath.EPSILON7 + ); + expect(lowValue[2]).toEqualEpsilon( + -southwestCartesian.y, + CesiumMath.EPSILON7 + ); + expect(lowValue[3]).toEqualEpsilon( + -southwestCartesian.x, + CesiumMath.EPSILON7 + ); + + // Small case + // Because using a unit sphere expect all HIGH values to be basically 0 + highValue = smallRectangleAttributes.planes2D_HIGH.value; + expect(highValue[0]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); + expect(highValue[1]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); + expect(highValue[2]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); + expect(highValue[3]).toEqualEpsilon(0.0, CesiumMath.EPSILON7); + + cartographic = Cartographic.fromDegrees(-0.1, -0.1, 0.0); // southwest corner + southwestCartesian = projection.project(cartographic); + lowValue = smallRectangleAttributes.planes2D_LOW.value; + expect(lowValue[0]).toEqualEpsilon( + southwestCartesian.x, + CesiumMath.EPSILON7 + ); + expect(lowValue[1]).toEqualEpsilon( + southwestCartesian.y, + CesiumMath.EPSILON7 + ); + expect(lowValue[2]).toEqualEpsilon( + -southwestCartesian.y, + CesiumMath.EPSILON7 + ); + expect(lowValue[3]).toEqualEpsilon( + -southwestCartesian.x, + CesiumMath.EPSILON7 + ); }); it("provides attributes for rotating texture coordinates", function () {