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

improve attribute reliability for ground primitive materials #7421

Merged
merged 10 commits into from
Sep 23, 2019
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Change Log
* 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 an issue where polygons, corridors, rectangles, and ellipses on terrain would not render on some mobile devices. [#6739](https://github.com/AnalyticalGraphicsInc/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/AnalyticalGraphicsInc/cesium/issues/7974)

### 1.61 - 2019-09-03
Expand Down
2 changes: 1 addition & 1 deletion Source/Renderer/ComputeCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ define([
/**
* Executes the compute command.
*
* @param {Context} computeEngine The context that processes the compute command.
* @param {ComputeEngine} computeEngine The context that processes the compute command.
*/
ComputeCommand.prototype.execute = function(computeEngine) {
computeEngine.execute(this);
Expand Down
16 changes: 16 additions & 0 deletions Source/Renderer/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ define([
'../Core/WebGLConstants',
'../Shaders/ViewportQuadVS',
'./BufferUsage',
'./checkFloatTexturePrecision',
'./ClearCommand',
'./ContextLimits',
'./CubeMap',
Expand Down Expand Up @@ -51,6 +52,7 @@ define([
WebGLConstants,
ViewportQuadVS,
BufferUsage,
checkFloatTexturePrecision,
ClearCommand,
ContextLimits,
CubeMap,
Expand Down Expand Up @@ -445,6 +447,8 @@ define([
this.cache = {};

RenderState.apply(gl, rs, ps);

this._floatTexSixPlaces = checkFloatTexturePrecision(this);
}

var defaultFramebufferMarker = {};
Expand Down Expand Up @@ -586,6 +590,18 @@ define([
}
},

/**
* <code>true</code> returns if the context's floating point textures support 6 decimal places of precision.
likangning93 marked this conversation as resolved.
Show resolved Hide resolved
* @memberof Context.prototype
* @type {Boolean}
* @see {@link https://www.khronos.org/registry/webgl/extensions/OES_texture_float/}
*/
floatTextureSixPlaces : {
get : function() {
return this._floatTexSixPlaces;
}
},

/**
* <code>true</code> 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.
Expand Down
101 changes: 101 additions & 0 deletions Source/Renderer/checkFloatTexturePrecision.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
define([
'../Core/PixelFormat',
'../Shaders/CheckFloatTexturePrecisionFS',
'./ComputeCommand',
'./ComputeEngine',
'./Framebuffer',
'./PixelDatatype',
'./Texture'
], function(
PixelFormat,
CheckFloatTexturePrecisionFS,
ComputeCommand,
ComputeEngine,
Framebuffer,
PixelDatatype,
Texture
) {
'use strict';

/**
* 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
likangning93 marked this conversation as resolved.
Show resolved Hide resolved
*
* @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);
};

return checkFloatTexturePrecision;
});
2 changes: 1 addition & 1 deletion Source/Scene/ClassificationPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ define([
});
var attributeLocations = classificationPrimitive._primitive._attributeLocations;

var shadowVolumeAppearance = new ShadowVolumeAppearance(cullFragmentsUsingExtents, planarExtents, classificationPrimitive.appearance);
var shadowVolumeAppearance = new ShadowVolumeAppearance(cullFragmentsUsingExtents, planarExtents, classificationPrimitive.appearance, context.floatTextureSixPlaces);

classificationPrimitive._spStencil = ShaderProgram.replaceCache({
context : context,
Expand Down
5 changes: 3 additions & 2 deletions Source/Scene/GroundPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,10 +730,11 @@ define([
var boundingRectangle = getRectangle(frameState, geometry);
var textureCoordinateRotationPoints = geometry.textureCoordinateRotationPoints;

var useFloatBatchTable = frameState.context.floatTextureSixPlaces;
if (usePlanarExtents) {
attributes = ShadowVolumeAppearance.getPlanarTextureCoordinateAttributes(boundingRectangle, textureCoordinateRotationPoints, ellipsoid, frameState.mapProjection, this._maxHeight);
attributes = ShadowVolumeAppearance.getPlanarTextureCoordinateAttributes(boundingRectangle, textureCoordinateRotationPoints, ellipsoid, frameState.mapProjection, useFloatBatchTable, this._maxHeight);
} else {
attributes = ShadowVolumeAppearance.getSphericalExtentGeometryInstanceAttributes(boundingRectangle, textureCoordinateRotationPoints, ellipsoid, frameState.mapProjection);
attributes = ShadowVolumeAppearance.getSphericalExtentGeometryInstanceAttributes(boundingRectangle, textureCoordinateRotationPoints, ellipsoid, frameState.mapProjection, useFloatBatchTable);
}

var instanceAttributes = instance.attributes;
Expand Down
Loading