Skip to content

Commit 019ae68

Browse files
authored
Merge pull request #8227 from AnalyticalGraphicsInc/cssPixelFix
Fixed pixel size for polylines and point clouds under different resolutions
2 parents fda9890 + fd7ec91 commit 019ae68

19 files changed

+34
-35
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Change Log
3333
* Fixed alpha equation for `BlendingState.ALPHA_BLEND` and `BlendingState.ADDITIVE_BLEND`. [#8202](https://github.com/AnalyticalGraphicsInc/cesium/pull/8202)
3434
* Fixed atmosphere brightness when High Dynamic Range is disabled. [#8149](https://github.com/AnalyticalGraphicsInc/cesium/issues/8149)
3535
* Fixed brightness levels for procedural Image Based Lighting. [#7803](https://github.com/AnalyticalGraphicsInc/cesium/issues/7803)
36+
* Made pixel sizes consistent for polylines and point clouds when rendering at different pixel ratios. [#8113](https://github.com/AnalyticalGraphicsInc/cesium/issues/8113)
3637

3738
### 1.61 - 2019-09-03
3839

Source/DataSources/PolylineDashMaterialProperty.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ define([
2929
* @param {Object} [options] Object with the following properties:
3030
* @param {Property} [options.color=Color.WHITE] A Property specifying the {@link Color} of the line.
3131
* @param {Property} [options.gapColor=Color.TRANSPARENT] A Property specifying the {@link Color} of the gaps in the line.
32-
* @param {Property} [options.dashLength=16.0] A numeric Property specifying the length of the dash pattern in pixel.s
32+
* @param {Property} [options.dashLength=16.0] A numeric Property specifying the length of the dash pattern in pixels.
3333
* @param {Property} [options.dashPattern=255.0] A numeric Property specifying a 16 bit pattern for the dash
3434
*/
3535
function PolylineDashMaterialProperty(options) {

Source/Renderer/AutomaticUniforms.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,18 +1665,18 @@ define([
16651665
/**
16661666
* An automatic GLSL uniform representing the ratio of canvas coordinate space to canvas pixel space.
16671667
*
1668-
* @alias czm_resolutionScale
1668+
* @alias czm_pixelRatio
16691669
* @namespace
16701670
* @glslUniform
16711671
*
16721672
* @example
1673-
* uniform float czm_resolutionScale;
1673+
* uniform float czm_pixelRatio;
16741674
*/
1675-
czm_resolutionScale : new AutomaticUniform({
1675+
czm_pixelRatio : new AutomaticUniform({
16761676
size : 1,
16771677
datatype : WebGLConstants.FLOAT,
16781678
getValue : function(uniformState) {
1679-
return uniformState.resolutionScale;
1679+
return uniformState.pixelRatio;
16801680
}
16811681
}),
16821682

Source/Renderer/UniformState.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ define([
158158
this._cameraUp = new Cartesian3();
159159
this._frustum2DWidth = 0.0;
160160
this._eyeHeight2D = new Cartesian2();
161-
this._resolutionScale = 1.0;
161+
this._pixelRatio = 1.0;
162162
this._orthographicIn3D = false;
163163
this._backgroundColor = new Color();
164164

@@ -813,9 +813,9 @@ define([
813813
* @memberof UniformState.prototype
814814
* @type {Number}
815815
*/
816-
resolutionScale : {
816+
pixelRatio : {
817817
get : function() {
818-
return this._resolutionScale;
818+
return this._pixelRatio;
819819
}
820820
},
821821

@@ -1118,9 +1118,7 @@ define([
11181118
UniformState.prototype.update = function(frameState) {
11191119
this._mode = frameState.mode;
11201120
this._mapProjection = frameState.mapProjection;
1121-
1122-
var canvas = frameState.context._canvas;
1123-
this._resolutionScale = canvas.width / canvas.clientWidth;
1121+
this._pixelRatio = frameState.pixelRatio;
11241122

11251123
var camera = frameState.camera;
11261124
this.updateCamera(camera);

Source/Scene/FrameState.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ define([
157157
this.maximumScreenSpaceError = undefined;
158158

159159
/**
160-
* Ratio between a pixel and a density-independent pixel. Provides a standard unity of
160+
* Ratio between a pixel and a density-independent pixel. Provides a standard unit of
161161
* measure for real pixel measurements appropriate to a particular device.
162162
*
163163
* @type {Number}

Source/Scene/LabelCollection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ define([
864864
}
865865

866866
var uniformState = context.uniformState;
867-
var resolutionScale = uniformState.resolutionScale;
867+
var resolutionScale = uniformState.pixelRatio;
868868
var resolutionChanged = this._resolutionScale !== resolutionScale;
869869
this._resolutionScale = resolutionScale;
870870

Source/Scene/PointCloud.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,8 @@ define([
782782
u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier : function() {
783783
var scratch = scratchPointSizeAndTimeAndGeometricErrorAndDepthMultiplier;
784784
scratch.x = pointCloud._attenuation ? pointCloud.maximumAttenuation : pointCloud._pointSize;
785+
scratch.x *= frameState.pixelRatio;
786+
785787
scratch.y = pointCloud.time;
786788

787789
if (pointCloud._attenuation) {
@@ -1145,7 +1147,7 @@ define([
11451147
}
11461148

11471149
if (hasPointSizeStyle) {
1148-
vs += ' gl_PointSize = getPointSizeFromStyle(position, position_absolute, color, normal); \n';
1150+
vs += ' gl_PointSize = getPointSizeFromStyle(position, position_absolute, color, normal) * czm_pixelRatio; \n';
11491151
} else if (attenuation) {
11501152
vs += ' vec4 positionEC = czm_modelView * vec4(position, 1.0); \n' +
11511153
' float depth = -positionEC.z; \n' +

Source/Scene/PointCloudEyeDomeLighting.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ define([
243243
}
244244

245245
this._strength = pointCloudShading.eyeDomeLightingStrength;
246-
this._radius = pointCloudShading.eyeDomeLightingRadius;
246+
this._radius = pointCloudShading.eyeDomeLightingRadius * frameState.pixelRatio;
247247

248248
var dirty = createResources(this, frameState.context);
249249

Source/Scene/Scene.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ define([
16201620
},
16211621

16221622
/**
1623-
* Ratio between a pixel and a density-independent pixel. Provides a standard unity of
1623+
* Ratio between a pixel and a density-independent pixel. Provides a standard unit of
16241624
* measure for real pixel measurements appropriate to a particular device.
16251625
*
16261626
* @memberof Scene.prototype

Source/Shaders/BillboardCollectionVS.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ vec4 addScreenSpaceOffset(vec4 positionEC, vec2 imageSize, float scale, vec2 dir
5656
{
5757
// Note the halfSize cannot be computed in JavaScript because it is sent via
5858
// compressed vertex attributes that coerce it to an integer.
59-
vec2 halfSize = imageSize * scale * czm_resolutionScale * 0.5;
59+
vec2 halfSize = imageSize * scale * czm_pixelRatio * 0.5;
6060
halfSize *= ((direction * 2.0) - 1.0);
6161

6262
vec2 originTranslate = origin * abs(halfSize);
@@ -102,7 +102,7 @@ vec4 addScreenSpaceOffset(vec4 positionEC, vec2 imageSize, float scale, vec2 dir
102102
}
103103

104104
positionEC.xy += translate * mpp;
105-
positionEC.xy += (pixelOffset * czm_resolutionScale) * mpp;
105+
positionEC.xy += (pixelOffset * czm_pixelRatio) * mpp;
106106
return positionEC;
107107
}
108108

0 commit comments

Comments
 (0)