From d6f91aaf6338e996c794b1aadcd84b26bcd8ba9d Mon Sep 17 00:00:00 2001 From: Zhouhai Date: Tue, 18 Jun 2019 21:30:03 +0800 Subject: [PATCH 01/10] Solve struct ellipsoid caused the model to dark Solved the problem that struct ellipsoid caused the model to darken on Qualcomm platform --- CONTRIBUTORS.md | 1 + Source/Scene/processPbrMaterials.js | 4 ++-- .../Builtin/Functions/ellipsoidNew.glsl | 6 +++-- .../Functions/getWgs84EllipsoidEC.glsl | 10 +++++---- .../rayEllipsoidIntersectionInterval.glsl | 22 +++++++++---------- Source/Shaders/Builtin/Structs/ellipsoid.glsl | 20 +++++++---------- Source/Shaders/DepthPlaneFS.glsl | 4 ++-- Source/Shaders/EllipsoidFS.glsl | 4 ++-- Source/Shaders/GlobeFS.glsl | 7 +++--- Source/Shaders/GlobeVS.glsl | 3 ++- 10 files changed, 42 insertions(+), 39 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 070e4376d78f..66c029cf7a0a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -211,3 +211,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Trubie Turner](https://github.com/flexei) * [Merijn Wijngaard](https://github.com/mwijngaard) * [Dennis Adams](https://github.com/dennisadams) +* [Hai Zhou](https://github.com/verybigzhouhai) diff --git a/Source/Scene/processPbrMaterials.js b/Source/Scene/processPbrMaterials.js index b9eeb0af8f9d..5d322756f140 100644 --- a/Source/Scene/processPbrMaterials.js +++ b/Source/Scene/processPbrMaterials.js @@ -740,9 +740,9 @@ define([ fragmentShader += ' vec3 r = normalize(czm_inverseViewRotation * normalize(reflect(v, n)));\n'; // Figure out if the reflection vector hits the ellipsoid - fragmentShader += ' czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC();\n'; + fragmentShader += ' czm_getWgs84EllipsoidEC();\n'; fragmentShader += ' float vertexRadius = length(positionWC);\n'; - fragmentShader += ' float horizonDotNadir = 1.0 - min(1.0, ellipsoid.radii.x / vertexRadius);\n'; + fragmentShader += ' float horizonDotNadir = 1.0 - min(1.0, czm_ellipsoid_radii.x / vertexRadius);\n'; fragmentShader += ' float reflectionDotNadir = dot(r, normalize(positionWC));\n'; // Flipping the X vector is a cheap way to get the inverse of czm_temeToPseudoFixed, since that's a rotation about Z. fragmentShader += ' r.x = -r.x;\n'; diff --git a/Source/Shaders/Builtin/Functions/ellipsoidNew.glsl b/Source/Shaders/Builtin/Functions/ellipsoidNew.glsl index b1bd61fce129..57f3f576bf99 100644 --- a/Source/Shaders/Builtin/Functions/ellipsoidNew.glsl +++ b/Source/Shaders/Builtin/Functions/ellipsoidNew.glsl @@ -9,6 +9,8 @@ czm_ellipsoid czm_ellipsoidNew(vec3 center, vec3 radii) { vec3 inverseRadii = vec3(1.0 / radii.x, 1.0 / radii.y, 1.0 / radii.z); vec3 inverseRadiiSquared = inverseRadii * inverseRadii; - czm_ellipsoid temp = czm_ellipsoid(center, radii, inverseRadii, inverseRadiiSquared); - return temp; + czm_ellipsoid_center = center; + czm_ellipsoid_radii = radii; + czm_ellipsoid_inverseRadii = inverseRadii; + czm_ellipsoid_inverseRadiiSquared = inverseRadiiSquared; } diff --git a/Source/Shaders/Builtin/Functions/getWgs84EllipsoidEC.glsl b/Source/Shaders/Builtin/Functions/getWgs84EllipsoidEC.glsl index 204e9f31a63b..56f6ea1ba8bc 100644 --- a/Source/Shaders/Builtin/Functions/getWgs84EllipsoidEC.glsl +++ b/Source/Shaders/Builtin/Functions/getWgs84EllipsoidEC.glsl @@ -4,18 +4,20 @@ * @name czm_getWgs84EllipsoidEC * @glslFunction * - * @returns {czm_ellipsoid} The WGS84 ellipsoid, with its center at the origin of world coordinates, in eye coordinates. * * @see Ellipsoid.WGS84 * * @example - * czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); + * czm_getWgs84EllipsoidEC(); */ czm_ellipsoid czm_getWgs84EllipsoidEC() { vec3 radii = vec3(6378137.0, 6378137.0, 6356752.314245); vec3 inverseRadii = vec3(1.0 / radii.x, 1.0 / radii.y, 1.0 / radii.z); vec3 inverseRadiiSquared = inverseRadii * inverseRadii; - czm_ellipsoid temp = czm_ellipsoid(czm_view[3].xyz, radii, inverseRadii, inverseRadiiSquared); - return temp; + czm_ellipsoid_center = czm_view[3].xyz; + czm_ellipsoid_radii = radii; + czm_ellipsoid_inverseRadii = inverseRadii; + czm_ellipsoid_inverseRadiiSquared = inverseRadiiSquared; + } diff --git a/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl b/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl index b1bea1a33495..b776888e449e 100644 --- a/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl +++ b/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl @@ -4,17 +4,17 @@ * @name czm_rayEllipsoidIntersectionInterval * @glslFunction */ -czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, czm_ellipsoid ellipsoid) +czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 center, vec3 inverseRadii) { - // ray and ellipsoid center in eye coordinates. radii in model coordinates. - vec3 q = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz; - vec3 w = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz; - - q = q - ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ellipsoid.center, 1.0)).xyz; - + // ray and ellipsoid center in eye coordinates. radii in model coordinates. + vec3 q = inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz; + vec3 w = inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz; + + q = q - inverseRadii * (czm_inverseModelView * vec4(center, 1.0)).xyz; + float q2 = dot(q, q); float qw = dot(q, w); - + if (q2 > 1.0) // Outside ellipsoid. { if (qw >= 0.0) // Looking outward or tangent (0 intersections). @@ -27,11 +27,11 @@ czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, czm_ellipsoid e float difference = q2 - 1.0; // Positively valued. float w2 = dot(w, w); float product = w2 * difference; - + if (qw2 < product) // Imaginary roots (0 intersections). { - return czm_emptyRaySegment; - } + return czm_emptyRaySegment; + } else if (qw2 > product) // Distinct roots (2 intersections). { float discriminant = qw * qw - product; diff --git a/Source/Shaders/Builtin/Structs/ellipsoid.glsl b/Source/Shaders/Builtin/Structs/ellipsoid.glsl index c4bf84a440c0..62e3854426db 100644 --- a/Source/Shaders/Builtin/Structs/ellipsoid.glsl +++ b/Source/Shaders/Builtin/Structs/ellipsoid.glsl @@ -1,12 +1,8 @@ -/** DOC_TBA - * - * @name czm_ellipsoid - * @glslStruct - */ -struct czm_ellipsoid -{ - vec3 center; - vec3 radii; - vec3 inverseRadii; - vec3 inverseRadiiSquared; -}; +/** +* +struct ellipsoid +*/ +vec3 czm_ellipsoid_center; +vec3 czm_ellipsoid_radii; +vec3 czm_ellipsoid_inverseRadii; +vec3 czm_ellipsoid_inverseRadiiSquared; diff --git a/Source/Shaders/DepthPlaneFS.glsl b/Source/Shaders/DepthPlaneFS.glsl index 41385729ae4b..aa4036e0a5e8 100644 --- a/Source/Shaders/DepthPlaneFS.glsl +++ b/Source/Shaders/DepthPlaneFS.glsl @@ -3,12 +3,12 @@ varying vec4 positionEC; void main() { // TODO: make arbitrary ellipsoid - czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); + czm_getWgs84EllipsoidEC(); vec3 direction = normalize(positionEC.xyz); czm_ray ray = czm_ray(vec3(0.0), direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, czm_ellipsoid_center, czm_ellipsoid_inverseRadii); if (!czm_isEmpty(intersection)) { gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); diff --git a/Source/Shaders/EllipsoidFS.glsl b/Source/Shaders/EllipsoidFS.glsl index d028e502b96d..f742acca4038 100644 --- a/Source/Shaders/EllipsoidFS.glsl +++ b/Source/Shaders/EllipsoidFS.glsl @@ -73,9 +73,9 @@ void main() // March ray forward to intersection with larger sphere and find // actual intersection point with ellipsoid. - czm_ellipsoid ellipsoid = czm_ellipsoidNew(ellipsoidCenter, u_radii); + czm_ellipsoidNew(ellipsoidCenter, u_radii); czm_ray ray = czm_ray(t * direction, direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, czm_ellipsoid_center, czm_ellipsoid_inverseRadii); if (czm_isEmpty(intersection)) { diff --git a/Source/Shaders/GlobeFS.glsl b/Source/Shaders/GlobeFS.glsl index ed6085494247..1953abced014 100644 --- a/Source/Shaders/GlobeFS.glsl +++ b/Source/Shaders/GlobeFS.glsl @@ -278,7 +278,8 @@ void main() float fadeOutDist = u_lightingFadeDistance.x; float fadeInDist = u_lightingFadeDistance.y; if (czm_sceneMode != czm_sceneMode3D) { - vec3 radii = czm_getWgs84EllipsoidEC().radii; + czm_getWgs84EllipsoidEC(); + vec3 radii = czm_ellipsoid_radii; float maxRadii = max(radii.x, max(radii.y, radii.z)); fadeOutDist -= maxRadii; fadeInDist -= maxRadii; @@ -376,7 +377,7 @@ void main() } #if defined(PER_FRAGMENT_GROUND_ATMOSPHERE) && (defined(ENABLE_DAYNIGHT_SHADING) || defined(ENABLE_VERTEX_LIGHTING)) - czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); + czm_getWgs84EllipsoidEC(); float mpp = czm_metersPerPixel(vec4(0.0, 0.0, -czm_currentFrustum.x, 1.0)); vec2 xy = gl_FragCoord.xy / czm_viewport.zw * 2.0 - vec2(1.0); @@ -385,7 +386,7 @@ void main() vec3 direction = normalize(vec3(xy, -czm_currentFrustum.x)); czm_ray ray = czm_ray(vec3(0.0), direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, czm_ellipsoid_center, czm_ellipsoid_inverseRadii); vec3 ellipsoidPosition = czm_pointAlongRay(ray, intersection.start); ellipsoidPosition = (czm_inverseView * vec4(ellipsoidPosition, 1.0)).xyz; diff --git a/Source/Shaders/GlobeVS.glsl b/Source/Shaders/GlobeVS.glsl index 5099f15af85d..fc69a93eea2f 100644 --- a/Source/Shaders/GlobeVS.glsl +++ b/Source/Shaders/GlobeVS.glsl @@ -176,7 +176,8 @@ void main() #endif #ifdef APPLY_MATERIAL - float northPoleZ = czm_getWgs84EllipsoidEC().radii.z; + czm_getWgs84EllipsoidEC(); + float northPoleZ = czm_ellipsoid_radii.z; vec3 northPolePositionMC = vec3(0.0, 0.0, northPoleZ); vec3 ellipsoidNormal = normalize(v_positionMC); // For a sphere this is correct, but not generally for an ellipsoid. vec3 vectorEastMC = normalize(cross(northPolePositionMC - v_positionMC, ellipsoidNormal)); From 38bab8880d6097f01e919adbc2209bb651511713 Mon Sep 17 00:00:00 2001 From: Zhouhai Date: Wed, 19 Jun 2019 23:07:08 +0800 Subject: [PATCH 02/10] fix: 3dtile dark fix: 3dtile dark --- CONTRIBUTORS.md | 1 + Source/Scene/processPbrMaterials.js | 4 ++-- .../Functions/ellipsoidContainsPoint.glsl | 4 ++-- .../rayEllipsoidIntersectionInterval.glsl | 20 +++++++++---------- Source/Shaders/DepthPlaneFS.glsl | 9 +++++---- Source/Shaders/EllipsoidFS.glsl | 7 ++++--- Source/Shaders/GlobeFS.glsl | 10 ++++++---- Source/Shaders/GlobeVS.glsl | 3 ++- 8 files changed, 32 insertions(+), 26 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 070e4376d78f..66c029cf7a0a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -211,3 +211,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Trubie Turner](https://github.com/flexei) * [Merijn Wijngaard](https://github.com/mwijngaard) * [Dennis Adams](https://github.com/dennisadams) +* [Hai Zhou](https://github.com/verybigzhouhai) diff --git a/Source/Scene/processPbrMaterials.js b/Source/Scene/processPbrMaterials.js index b9eeb0af8f9d..ad58b415a499 100644 --- a/Source/Scene/processPbrMaterials.js +++ b/Source/Scene/processPbrMaterials.js @@ -740,9 +740,9 @@ define([ fragmentShader += ' vec3 r = normalize(czm_inverseViewRotation * normalize(reflect(v, n)));\n'; // Figure out if the reflection vector hits the ellipsoid - fragmentShader += ' czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC();\n'; + fragmentShader += ' vec3 ellipsoid_radii = vec3(6378137.0, 6378137.0, 6356752.314245);\n'; fragmentShader += ' float vertexRadius = length(positionWC);\n'; - fragmentShader += ' float horizonDotNadir = 1.0 - min(1.0, ellipsoid.radii.x / vertexRadius);\n'; + fragmentShader += ' float horizonDotNadir = 1.0 - min(1.0, ellipsoid_radii.x / vertexRadius);\n'; fragmentShader += ' float reflectionDotNadir = dot(r, normalize(positionWC));\n'; // Flipping the X vector is a cheap way to get the inverse of czm_temeToPseudoFixed, since that's a rotation about Z. fragmentShader += ' r.x = -r.x;\n'; diff --git a/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.glsl b/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.glsl index cc3e4efc3b38..0b3e8f237c8e 100644 --- a/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.glsl +++ b/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.glsl @@ -5,8 +5,8 @@ * @glslFunction * */ -bool czm_ellipsoidContainsPoint(czm_ellipsoid ellipsoid, vec3 point) +bool czm_ellipsoidContainsPoint(vec3 ellipsoid_inverseRadii, vec3 point) { - vec3 scaled = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz; + vec3 scaled = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz; return (dot(scaled, scaled) <= 1.0); } diff --git a/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl b/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl index b1bea1a33495..29086ab9363a 100644 --- a/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl +++ b/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl @@ -4,17 +4,17 @@ * @name czm_rayEllipsoidIntersectionInterval * @glslFunction */ -czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, czm_ellipsoid ellipsoid) +czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 ellipsoid_center, vec3 ellipsoid_inverseRadii) { // ray and ellipsoid center in eye coordinates. radii in model coordinates. - vec3 q = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz; - vec3 w = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz; - - q = q - ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ellipsoid.center, 1.0)).xyz; - + vec3 q = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz; + vec3 w = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz; + + q = q - ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ellipsoid_center, 1.0)).xyz; + float q2 = dot(q, q); float qw = dot(q, w); - + if (q2 > 1.0) // Outside ellipsoid. { if (qw >= 0.0) // Looking outward or tangent (0 intersections). @@ -27,11 +27,11 @@ czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, czm_ellipsoid e float difference = q2 - 1.0; // Positively valued. float w2 = dot(w, w); float product = w2 * difference; - + if (qw2 < product) // Imaginary roots (0 intersections). { - return czm_emptyRaySegment; - } + return czm_emptyRaySegment; + } else if (qw2 > product) // Distinct roots (2 intersections). { float discriminant = qw * qw - product; diff --git a/Source/Shaders/DepthPlaneFS.glsl b/Source/Shaders/DepthPlaneFS.glsl index 41385729ae4b..9b6f2c62eb96 100644 --- a/Source/Shaders/DepthPlaneFS.glsl +++ b/Source/Shaders/DepthPlaneFS.glsl @@ -2,13 +2,14 @@ varying vec4 positionEC; void main() { - // TODO: make arbitrary ellipsoid - czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); - vec3 direction = normalize(positionEC.xyz); czm_ray ray = czm_ray(vec3(0.0), direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); + vec3 ellipsoid_center = czm_view[3].xyz; + vec3 ellipsoid_radii = vec3(6378137.0, 6378137.0, 6356752.314245); + vec3 ellipsoid_inverseRadii = vec3(1.0 / ellipsoid_radii.x, 1.0 / ellipsoid_radii.y, 1.0 / ellipsoid_radii.z); + + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, ellipsoid_inverseRadii); if (!czm_isEmpty(intersection)) { gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); diff --git a/Source/Shaders/EllipsoidFS.glsl b/Source/Shaders/EllipsoidFS.glsl index d028e502b96d..e7e5fbe1c267 100644 --- a/Source/Shaders/EllipsoidFS.glsl +++ b/Source/Shaders/EllipsoidFS.glsl @@ -72,10 +72,11 @@ void main() } // March ray forward to intersection with larger sphere and find - // actual intersection point with ellipsoid. - czm_ellipsoid ellipsoid = czm_ellipsoidNew(ellipsoidCenter, u_radii); czm_ray ray = czm_ray(t * direction, direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); + + vec3 ellipsoid_inverseRadii = vec3(1.0 / u_radii.x, 1.0 / u_radii.y, 1.0 / u_radii.z); + + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoidCenter, ellipsoid_inverseRadii); if (czm_isEmpty(intersection)) { diff --git a/Source/Shaders/GlobeFS.glsl b/Source/Shaders/GlobeFS.glsl index ed6085494247..efd65ceb2274 100644 --- a/Source/Shaders/GlobeFS.glsl +++ b/Source/Shaders/GlobeFS.glsl @@ -278,7 +278,7 @@ void main() float fadeOutDist = u_lightingFadeDistance.x; float fadeInDist = u_lightingFadeDistance.y; if (czm_sceneMode != czm_sceneMode3D) { - vec3 radii = czm_getWgs84EllipsoidEC().radii; + vec3 radii = vec3(6378137.0, 6378137.0, 6356752.314245); float maxRadii = max(radii.x, max(radii.y, radii.z)); fadeOutDist -= maxRadii; fadeInDist -= maxRadii; @@ -376,8 +376,6 @@ void main() } #if defined(PER_FRAGMENT_GROUND_ATMOSPHERE) && (defined(ENABLE_DAYNIGHT_SHADING) || defined(ENABLE_VERTEX_LIGHTING)) - czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); - float mpp = czm_metersPerPixel(vec4(0.0, 0.0, -czm_currentFrustum.x, 1.0)); vec2 xy = gl_FragCoord.xy / czm_viewport.zw * 2.0 - vec2(1.0); xy *= czm_viewport.zw * mpp * 0.5; @@ -385,7 +383,11 @@ void main() vec3 direction = normalize(vec3(xy, -czm_currentFrustum.x)); czm_ray ray = czm_ray(vec3(0.0), direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); + vec3 ellipsoid_center = czm_view[3].xyz; + vec3 ellipsoid_radii = vec3(6378137.0, 6378137.0, 6356752.314245); + vec3 ellipsoid_inverseRadii = vec3(1.0 / ellipsoid_radii.x, 1.0 / ellipsoid_radii.y, 1.0 / ellipsoid_radii.z); + + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, ellipsoid_inverseRadii); vec3 ellipsoidPosition = czm_pointAlongRay(ray, intersection.start); ellipsoidPosition = (czm_inverseView * vec4(ellipsoidPosition, 1.0)).xyz; diff --git a/Source/Shaders/GlobeVS.glsl b/Source/Shaders/GlobeVS.glsl index 5099f15af85d..96fb6ed6da18 100644 --- a/Source/Shaders/GlobeVS.glsl +++ b/Source/Shaders/GlobeVS.glsl @@ -176,7 +176,8 @@ void main() #endif #ifdef APPLY_MATERIAL - float northPoleZ = czm_getWgs84EllipsoidEC().radii.z; + vec3 ellipsoid_radii = vec3(6378137.0, 6378137.0, 6356752.314245); + float northPoleZ = ellipsoid_radii.z; vec3 northPolePositionMC = vec3(0.0, 0.0, northPoleZ); vec3 ellipsoidNormal = normalize(v_positionMC); // For a sphere this is correct, but not generally for an ellipsoid. vec3 vectorEastMC = normalize(cross(northPolePositionMC - v_positionMC, ellipsoidNormal)); From b2588e4023ec0f4d0a5d4d3347877709f18e961d Mon Sep 17 00:00:00 2001 From: Zhouhai Date: Wed, 19 Jun 2019 23:09:09 +0800 Subject: [PATCH 03/10] Revert "Solve struct ellipsoid caused the model to dark" This reverts commit d6f91aaf6338e996c794b1aadcd84b26bcd8ba9d. --- CONTRIBUTORS.md | 1 - Source/Scene/processPbrMaterials.js | 4 ++-- .../Builtin/Functions/ellipsoidNew.glsl | 6 ++--- .../Functions/getWgs84EllipsoidEC.glsl | 10 ++++----- .../rayEllipsoidIntersectionInterval.glsl | 22 +++++++++---------- Source/Shaders/Builtin/Structs/ellipsoid.glsl | 20 ++++++++++------- Source/Shaders/DepthPlaneFS.glsl | 4 ++-- Source/Shaders/EllipsoidFS.glsl | 4 ++-- Source/Shaders/GlobeFS.glsl | 7 +++--- Source/Shaders/GlobeVS.glsl | 3 +-- 10 files changed, 39 insertions(+), 42 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 66c029cf7a0a..070e4376d78f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -211,4 +211,3 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Trubie Turner](https://github.com/flexei) * [Merijn Wijngaard](https://github.com/mwijngaard) * [Dennis Adams](https://github.com/dennisadams) -* [Hai Zhou](https://github.com/verybigzhouhai) diff --git a/Source/Scene/processPbrMaterials.js b/Source/Scene/processPbrMaterials.js index 5d322756f140..b9eeb0af8f9d 100644 --- a/Source/Scene/processPbrMaterials.js +++ b/Source/Scene/processPbrMaterials.js @@ -740,9 +740,9 @@ define([ fragmentShader += ' vec3 r = normalize(czm_inverseViewRotation * normalize(reflect(v, n)));\n'; // Figure out if the reflection vector hits the ellipsoid - fragmentShader += ' czm_getWgs84EllipsoidEC();\n'; + fragmentShader += ' czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC();\n'; fragmentShader += ' float vertexRadius = length(positionWC);\n'; - fragmentShader += ' float horizonDotNadir = 1.0 - min(1.0, czm_ellipsoid_radii.x / vertexRadius);\n'; + fragmentShader += ' float horizonDotNadir = 1.0 - min(1.0, ellipsoid.radii.x / vertexRadius);\n'; fragmentShader += ' float reflectionDotNadir = dot(r, normalize(positionWC));\n'; // Flipping the X vector is a cheap way to get the inverse of czm_temeToPseudoFixed, since that's a rotation about Z. fragmentShader += ' r.x = -r.x;\n'; diff --git a/Source/Shaders/Builtin/Functions/ellipsoidNew.glsl b/Source/Shaders/Builtin/Functions/ellipsoidNew.glsl index 57f3f576bf99..b1bd61fce129 100644 --- a/Source/Shaders/Builtin/Functions/ellipsoidNew.glsl +++ b/Source/Shaders/Builtin/Functions/ellipsoidNew.glsl @@ -9,8 +9,6 @@ czm_ellipsoid czm_ellipsoidNew(vec3 center, vec3 radii) { vec3 inverseRadii = vec3(1.0 / radii.x, 1.0 / radii.y, 1.0 / radii.z); vec3 inverseRadiiSquared = inverseRadii * inverseRadii; - czm_ellipsoid_center = center; - czm_ellipsoid_radii = radii; - czm_ellipsoid_inverseRadii = inverseRadii; - czm_ellipsoid_inverseRadiiSquared = inverseRadiiSquared; + czm_ellipsoid temp = czm_ellipsoid(center, radii, inverseRadii, inverseRadiiSquared); + return temp; } diff --git a/Source/Shaders/Builtin/Functions/getWgs84EllipsoidEC.glsl b/Source/Shaders/Builtin/Functions/getWgs84EllipsoidEC.glsl index 56f6ea1ba8bc..204e9f31a63b 100644 --- a/Source/Shaders/Builtin/Functions/getWgs84EllipsoidEC.glsl +++ b/Source/Shaders/Builtin/Functions/getWgs84EllipsoidEC.glsl @@ -4,20 +4,18 @@ * @name czm_getWgs84EllipsoidEC * @glslFunction * + * @returns {czm_ellipsoid} The WGS84 ellipsoid, with its center at the origin of world coordinates, in eye coordinates. * * @see Ellipsoid.WGS84 * * @example - * czm_getWgs84EllipsoidEC(); + * czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); */ czm_ellipsoid czm_getWgs84EllipsoidEC() { vec3 radii = vec3(6378137.0, 6378137.0, 6356752.314245); vec3 inverseRadii = vec3(1.0 / radii.x, 1.0 / radii.y, 1.0 / radii.z); vec3 inverseRadiiSquared = inverseRadii * inverseRadii; - czm_ellipsoid_center = czm_view[3].xyz; - czm_ellipsoid_radii = radii; - czm_ellipsoid_inverseRadii = inverseRadii; - czm_ellipsoid_inverseRadiiSquared = inverseRadiiSquared; - + czm_ellipsoid temp = czm_ellipsoid(czm_view[3].xyz, radii, inverseRadii, inverseRadiiSquared); + return temp; } diff --git a/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl b/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl index b776888e449e..b1bea1a33495 100644 --- a/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl +++ b/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl @@ -4,17 +4,17 @@ * @name czm_rayEllipsoidIntersectionInterval * @glslFunction */ -czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 center, vec3 inverseRadii) +czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, czm_ellipsoid ellipsoid) { - // ray and ellipsoid center in eye coordinates. radii in model coordinates. - vec3 q = inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz; - vec3 w = inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz; - - q = q - inverseRadii * (czm_inverseModelView * vec4(center, 1.0)).xyz; - + // ray and ellipsoid center in eye coordinates. radii in model coordinates. + vec3 q = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz; + vec3 w = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz; + + q = q - ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ellipsoid.center, 1.0)).xyz; + float q2 = dot(q, q); float qw = dot(q, w); - + if (q2 > 1.0) // Outside ellipsoid. { if (qw >= 0.0) // Looking outward or tangent (0 intersections). @@ -27,11 +27,11 @@ czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 center, ve float difference = q2 - 1.0; // Positively valued. float w2 = dot(w, w); float product = w2 * difference; - + if (qw2 < product) // Imaginary roots (0 intersections). { - return czm_emptyRaySegment; - } + return czm_emptyRaySegment; + } else if (qw2 > product) // Distinct roots (2 intersections). { float discriminant = qw * qw - product; diff --git a/Source/Shaders/Builtin/Structs/ellipsoid.glsl b/Source/Shaders/Builtin/Structs/ellipsoid.glsl index 62e3854426db..c4bf84a440c0 100644 --- a/Source/Shaders/Builtin/Structs/ellipsoid.glsl +++ b/Source/Shaders/Builtin/Structs/ellipsoid.glsl @@ -1,8 +1,12 @@ -/** -* -struct ellipsoid -*/ -vec3 czm_ellipsoid_center; -vec3 czm_ellipsoid_radii; -vec3 czm_ellipsoid_inverseRadii; -vec3 czm_ellipsoid_inverseRadiiSquared; +/** DOC_TBA + * + * @name czm_ellipsoid + * @glslStruct + */ +struct czm_ellipsoid +{ + vec3 center; + vec3 radii; + vec3 inverseRadii; + vec3 inverseRadiiSquared; +}; diff --git a/Source/Shaders/DepthPlaneFS.glsl b/Source/Shaders/DepthPlaneFS.glsl index aa4036e0a5e8..41385729ae4b 100644 --- a/Source/Shaders/DepthPlaneFS.glsl +++ b/Source/Shaders/DepthPlaneFS.glsl @@ -3,12 +3,12 @@ varying vec4 positionEC; void main() { // TODO: make arbitrary ellipsoid - czm_getWgs84EllipsoidEC(); + czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); vec3 direction = normalize(positionEC.xyz); czm_ray ray = czm_ray(vec3(0.0), direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, czm_ellipsoid_center, czm_ellipsoid_inverseRadii); + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); if (!czm_isEmpty(intersection)) { gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); diff --git a/Source/Shaders/EllipsoidFS.glsl b/Source/Shaders/EllipsoidFS.glsl index f742acca4038..d028e502b96d 100644 --- a/Source/Shaders/EllipsoidFS.glsl +++ b/Source/Shaders/EllipsoidFS.glsl @@ -73,9 +73,9 @@ void main() // March ray forward to intersection with larger sphere and find // actual intersection point with ellipsoid. - czm_ellipsoidNew(ellipsoidCenter, u_radii); + czm_ellipsoid ellipsoid = czm_ellipsoidNew(ellipsoidCenter, u_radii); czm_ray ray = czm_ray(t * direction, direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, czm_ellipsoid_center, czm_ellipsoid_inverseRadii); + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); if (czm_isEmpty(intersection)) { diff --git a/Source/Shaders/GlobeFS.glsl b/Source/Shaders/GlobeFS.glsl index 1953abced014..ed6085494247 100644 --- a/Source/Shaders/GlobeFS.glsl +++ b/Source/Shaders/GlobeFS.glsl @@ -278,8 +278,7 @@ void main() float fadeOutDist = u_lightingFadeDistance.x; float fadeInDist = u_lightingFadeDistance.y; if (czm_sceneMode != czm_sceneMode3D) { - czm_getWgs84EllipsoidEC(); - vec3 radii = czm_ellipsoid_radii; + vec3 radii = czm_getWgs84EllipsoidEC().radii; float maxRadii = max(radii.x, max(radii.y, radii.z)); fadeOutDist -= maxRadii; fadeInDist -= maxRadii; @@ -377,7 +376,7 @@ void main() } #if defined(PER_FRAGMENT_GROUND_ATMOSPHERE) && (defined(ENABLE_DAYNIGHT_SHADING) || defined(ENABLE_VERTEX_LIGHTING)) - czm_getWgs84EllipsoidEC(); + czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); float mpp = czm_metersPerPixel(vec4(0.0, 0.0, -czm_currentFrustum.x, 1.0)); vec2 xy = gl_FragCoord.xy / czm_viewport.zw * 2.0 - vec2(1.0); @@ -386,7 +385,7 @@ void main() vec3 direction = normalize(vec3(xy, -czm_currentFrustum.x)); czm_ray ray = czm_ray(vec3(0.0), direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, czm_ellipsoid_center, czm_ellipsoid_inverseRadii); + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); vec3 ellipsoidPosition = czm_pointAlongRay(ray, intersection.start); ellipsoidPosition = (czm_inverseView * vec4(ellipsoidPosition, 1.0)).xyz; diff --git a/Source/Shaders/GlobeVS.glsl b/Source/Shaders/GlobeVS.glsl index fc69a93eea2f..5099f15af85d 100644 --- a/Source/Shaders/GlobeVS.glsl +++ b/Source/Shaders/GlobeVS.glsl @@ -176,8 +176,7 @@ void main() #endif #ifdef APPLY_MATERIAL - czm_getWgs84EllipsoidEC(); - float northPoleZ = czm_ellipsoid_radii.z; + float northPoleZ = czm_getWgs84EllipsoidEC().radii.z; vec3 northPolePositionMC = vec3(0.0, 0.0, northPoleZ); vec3 ellipsoidNormal = normalize(v_positionMC); // For a sphere this is correct, but not generally for an ellipsoid. vec3 vectorEastMC = normalize(cross(northPolePositionMC - v_positionMC, ellipsoidNormal)); From df7d2d1be8e630a9deb909e855d021fecea94031 Mon Sep 17 00:00:00 2001 From: Zhouhai Date: Wed, 26 Jun 2019 10:47:42 +0800 Subject: [PATCH 04/10] remove czm_ellipsoid struct remove function czm_getWgs84EllipsoidEC remove struct czm_ellipsoid add Constant czm_ellipsoid_radii add Constant czm_ellipsoid_inverseRadii --- Source/Scene/processPbrMaterials.js | 3 +-- .../Constants/ellipsoidInverseRadii.glsl | 7 +++++++ .../Builtin/Constants/ellipsoidRadii.glsl | 7 +++++++ .../Functions/ellipsoidContainsPoint.glsl | 4 ++-- .../rayEllipsoidIntersectionInterval.glsl | 20 +++++++++---------- Source/Shaders/DepthPlaneFS.glsl | 7 +++---- Source/Shaders/EllipsoidFS.glsl | 7 ++++--- Source/Shaders/GlobeFS.glsl | 8 ++++---- Source/Shaders/GlobeVS.glsl | 2 +- 9 files changed, 39 insertions(+), 26 deletions(-) create mode 100644 Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl create mode 100644 Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl diff --git a/Source/Scene/processPbrMaterials.js b/Source/Scene/processPbrMaterials.js index b9eeb0af8f9d..f0bedc90cb8e 100644 --- a/Source/Scene/processPbrMaterials.js +++ b/Source/Scene/processPbrMaterials.js @@ -740,9 +740,8 @@ define([ fragmentShader += ' vec3 r = normalize(czm_inverseViewRotation * normalize(reflect(v, n)));\n'; // Figure out if the reflection vector hits the ellipsoid - fragmentShader += ' czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC();\n'; fragmentShader += ' float vertexRadius = length(positionWC);\n'; - fragmentShader += ' float horizonDotNadir = 1.0 - min(1.0, ellipsoid.radii.x / vertexRadius);\n'; + fragmentShader += ' float horizonDotNadir = 1.0 - min(1.0, czm_ellipsoid_radii.x / vertexRadius);\n'; fragmentShader += ' float reflectionDotNadir = dot(r, normalize(positionWC));\n'; // Flipping the X vector is a cheap way to get the inverse of czm_temeToPseudoFixed, since that's a rotation about Z. fragmentShader += ' r.x = -r.x;\n'; diff --git a/Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl b/Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl new file mode 100644 index 000000000000..69edbdb94a4e --- /dev/null +++ b/Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl @@ -0,0 +1,7 @@ +/** + * 0.1 + * + * @name czm_ellipsoid_inverseradii + * @glslConstant + */ +const vec3 czm_ellipsoid_inverseRadii = vec3(1.0 / 6378137.0, 1.0 / 6378137.0, 1.0 / 6356752.314245); diff --git a/Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl b/Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl new file mode 100644 index 000000000000..789d4e99f9d3 --- /dev/null +++ b/Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl @@ -0,0 +1,7 @@ +/** + * 0.1 + * + * @name czm_ellipsoid_radii + * @glslConstant + */ +const vec3 czm_ellipsoid_radii = vec3(6378137.0, 6378137.0, 6356752.314245); diff --git a/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.glsl b/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.glsl index cc3e4efc3b38..0b3e8f237c8e 100644 --- a/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.glsl +++ b/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.glsl @@ -5,8 +5,8 @@ * @glslFunction * */ -bool czm_ellipsoidContainsPoint(czm_ellipsoid ellipsoid, vec3 point) +bool czm_ellipsoidContainsPoint(vec3 ellipsoid_inverseRadii, vec3 point) { - vec3 scaled = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz; + vec3 scaled = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz; return (dot(scaled, scaled) <= 1.0); } diff --git a/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl b/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl index b1bea1a33495..29086ab9363a 100644 --- a/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl +++ b/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl @@ -4,17 +4,17 @@ * @name czm_rayEllipsoidIntersectionInterval * @glslFunction */ -czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, czm_ellipsoid ellipsoid) +czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 ellipsoid_center, vec3 ellipsoid_inverseRadii) { // ray and ellipsoid center in eye coordinates. radii in model coordinates. - vec3 q = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz; - vec3 w = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz; - - q = q - ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ellipsoid.center, 1.0)).xyz; - + vec3 q = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz; + vec3 w = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz; + + q = q - ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ellipsoid_center, 1.0)).xyz; + float q2 = dot(q, q); float qw = dot(q, w); - + if (q2 > 1.0) // Outside ellipsoid. { if (qw >= 0.0) // Looking outward or tangent (0 intersections). @@ -27,11 +27,11 @@ czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, czm_ellipsoid e float difference = q2 - 1.0; // Positively valued. float w2 = dot(w, w); float product = w2 * difference; - + if (qw2 < product) // Imaginary roots (0 intersections). { - return czm_emptyRaySegment; - } + return czm_emptyRaySegment; + } else if (qw2 > product) // Distinct roots (2 intersections). { float discriminant = qw * qw - product; diff --git a/Source/Shaders/DepthPlaneFS.glsl b/Source/Shaders/DepthPlaneFS.glsl index 41385729ae4b..17606633e9c3 100644 --- a/Source/Shaders/DepthPlaneFS.glsl +++ b/Source/Shaders/DepthPlaneFS.glsl @@ -2,13 +2,12 @@ varying vec4 positionEC; void main() { - // TODO: make arbitrary ellipsoid - czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); - vec3 direction = normalize(positionEC.xyz); czm_ray ray = czm_ray(vec3(0.0), direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); + vec3 ellipsoid_center = czm_view[3].xyz; + + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, czm_ellipsoid_inverseRadii); if (!czm_isEmpty(intersection)) { gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); diff --git a/Source/Shaders/EllipsoidFS.glsl b/Source/Shaders/EllipsoidFS.glsl index d028e502b96d..e7e5fbe1c267 100644 --- a/Source/Shaders/EllipsoidFS.glsl +++ b/Source/Shaders/EllipsoidFS.glsl @@ -72,10 +72,11 @@ void main() } // March ray forward to intersection with larger sphere and find - // actual intersection point with ellipsoid. - czm_ellipsoid ellipsoid = czm_ellipsoidNew(ellipsoidCenter, u_radii); czm_ray ray = czm_ray(t * direction, direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); + + vec3 ellipsoid_inverseRadii = vec3(1.0 / u_radii.x, 1.0 / u_radii.y, 1.0 / u_radii.z); + + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoidCenter, ellipsoid_inverseRadii); if (czm_isEmpty(intersection)) { diff --git a/Source/Shaders/GlobeFS.glsl b/Source/Shaders/GlobeFS.glsl index ed6085494247..293488fb66e7 100644 --- a/Source/Shaders/GlobeFS.glsl +++ b/Source/Shaders/GlobeFS.glsl @@ -278,7 +278,7 @@ void main() float fadeOutDist = u_lightingFadeDistance.x; float fadeInDist = u_lightingFadeDistance.y; if (czm_sceneMode != czm_sceneMode3D) { - vec3 radii = czm_getWgs84EllipsoidEC().radii; + vec3 radii = czm_ellipsoid_radii; float maxRadii = max(radii.x, max(radii.y, radii.z)); fadeOutDist -= maxRadii; fadeInDist -= maxRadii; @@ -376,8 +376,6 @@ void main() } #if defined(PER_FRAGMENT_GROUND_ATMOSPHERE) && (defined(ENABLE_DAYNIGHT_SHADING) || defined(ENABLE_VERTEX_LIGHTING)) - czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); - float mpp = czm_metersPerPixel(vec4(0.0, 0.0, -czm_currentFrustum.x, 1.0)); vec2 xy = gl_FragCoord.xy / czm_viewport.zw * 2.0 - vec2(1.0); xy *= czm_viewport.zw * mpp * 0.5; @@ -385,7 +383,9 @@ void main() vec3 direction = normalize(vec3(xy, -czm_currentFrustum.x)); czm_ray ray = czm_ray(vec3(0.0), direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); + vec3 ellipsoid_center = czm_view[3].xyz; + + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, czm_ellipsoid_inverseRadii); vec3 ellipsoidPosition = czm_pointAlongRay(ray, intersection.start); ellipsoidPosition = (czm_inverseView * vec4(ellipsoidPosition, 1.0)).xyz; diff --git a/Source/Shaders/GlobeVS.glsl b/Source/Shaders/GlobeVS.glsl index 5099f15af85d..51f815bf50a9 100644 --- a/Source/Shaders/GlobeVS.glsl +++ b/Source/Shaders/GlobeVS.glsl @@ -176,7 +176,7 @@ void main() #endif #ifdef APPLY_MATERIAL - float northPoleZ = czm_getWgs84EllipsoidEC().radii.z; + float northPoleZ = czm_ellipsoid_radii.z; vec3 northPolePositionMC = vec3(0.0, 0.0, northPoleZ); vec3 ellipsoidNormal = normalize(v_positionMC); // For a sphere this is correct, but not generally for an ellipsoid. vec3 vectorEastMC = normalize(cross(northPolePositionMC - v_positionMC, ellipsoidNormal)); From b47e8aba137e60affaf3ecca44e148379d0df929 Mon Sep 17 00:00:00 2001 From: Zhouhai Date: Wed, 26 Jun 2019 10:50:36 +0800 Subject: [PATCH 05/10] Delete unused files Delete unused files --- .../Functions/getWgs84EllipsoidEC.glsl | 21 ------------------- Source/Shaders/Builtin/Structs/ellipsoid.glsl | 12 ----------- 2 files changed, 33 deletions(-) delete mode 100644 Source/Shaders/Builtin/Functions/getWgs84EllipsoidEC.glsl delete mode 100644 Source/Shaders/Builtin/Structs/ellipsoid.glsl diff --git a/Source/Shaders/Builtin/Functions/getWgs84EllipsoidEC.glsl b/Source/Shaders/Builtin/Functions/getWgs84EllipsoidEC.glsl deleted file mode 100644 index 204e9f31a63b..000000000000 --- a/Source/Shaders/Builtin/Functions/getWgs84EllipsoidEC.glsl +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Returns the WGS84 ellipsoid, with its center at the origin of world coordinates, in eye coordinates. - * - * @name czm_getWgs84EllipsoidEC - * @glslFunction - * - * @returns {czm_ellipsoid} The WGS84 ellipsoid, with its center at the origin of world coordinates, in eye coordinates. - * - * @see Ellipsoid.WGS84 - * - * @example - * czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); - */ -czm_ellipsoid czm_getWgs84EllipsoidEC() -{ - vec3 radii = vec3(6378137.0, 6378137.0, 6356752.314245); - vec3 inverseRadii = vec3(1.0 / radii.x, 1.0 / radii.y, 1.0 / radii.z); - vec3 inverseRadiiSquared = inverseRadii * inverseRadii; - czm_ellipsoid temp = czm_ellipsoid(czm_view[3].xyz, radii, inverseRadii, inverseRadiiSquared); - return temp; -} diff --git a/Source/Shaders/Builtin/Structs/ellipsoid.glsl b/Source/Shaders/Builtin/Structs/ellipsoid.glsl deleted file mode 100644 index c4bf84a440c0..000000000000 --- a/Source/Shaders/Builtin/Structs/ellipsoid.glsl +++ /dev/null @@ -1,12 +0,0 @@ -/** DOC_TBA - * - * @name czm_ellipsoid - * @glslStruct - */ -struct czm_ellipsoid -{ - vec3 center; - vec3 radii; - vec3 inverseRadii; - vec3 inverseRadiiSquared; -}; From a63512f76ced81161e10889a4d69712ffd5326a5 Mon Sep 17 00:00:00 2001 From: Zhouhai Date: Wed, 26 Jun 2019 10:53:23 +0800 Subject: [PATCH 06/10] Update CONTRIBUTORS.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 070e4376d78f..66c029cf7a0a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -211,3 +211,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Trubie Turner](https://github.com/flexei) * [Merijn Wijngaard](https://github.com/mwijngaard) * [Dennis Adams](https://github.com/dennisadams) +* [Hai Zhou](https://github.com/verybigzhouhai) From ad6c45c421a29fff0cd89aedecea9f686c8a7ba3 Mon Sep 17 00:00:00 2001 From: Zhouhai Date: Wed, 26 Jun 2019 10:54:09 +0800 Subject: [PATCH 07/10] Revert "Merge pull request #1 from verybigzhouhai/3dtile-dark01" This reverts commit f3836852010c5abb1c99d294caff545f9f00fadc, reversing changes made to b2588e4023ec0f4d0a5d4d3347877709f18e961d. --- CONTRIBUTORS.md | 1 - Source/Scene/processPbrMaterials.js | 4 ++-- .../Functions/ellipsoidContainsPoint.glsl | 4 ++-- .../rayEllipsoidIntersectionInterval.glsl | 20 +++++++++---------- Source/Shaders/DepthPlaneFS.glsl | 9 ++++----- Source/Shaders/EllipsoidFS.glsl | 7 +++---- Source/Shaders/GlobeFS.glsl | 10 ++++------ Source/Shaders/GlobeVS.glsl | 3 +-- 8 files changed, 26 insertions(+), 32 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 66c029cf7a0a..070e4376d78f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -211,4 +211,3 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Trubie Turner](https://github.com/flexei) * [Merijn Wijngaard](https://github.com/mwijngaard) * [Dennis Adams](https://github.com/dennisadams) -* [Hai Zhou](https://github.com/verybigzhouhai) diff --git a/Source/Scene/processPbrMaterials.js b/Source/Scene/processPbrMaterials.js index ad58b415a499..b9eeb0af8f9d 100644 --- a/Source/Scene/processPbrMaterials.js +++ b/Source/Scene/processPbrMaterials.js @@ -740,9 +740,9 @@ define([ fragmentShader += ' vec3 r = normalize(czm_inverseViewRotation * normalize(reflect(v, n)));\n'; // Figure out if the reflection vector hits the ellipsoid - fragmentShader += ' vec3 ellipsoid_radii = vec3(6378137.0, 6378137.0, 6356752.314245);\n'; + fragmentShader += ' czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC();\n'; fragmentShader += ' float vertexRadius = length(positionWC);\n'; - fragmentShader += ' float horizonDotNadir = 1.0 - min(1.0, ellipsoid_radii.x / vertexRadius);\n'; + fragmentShader += ' float horizonDotNadir = 1.0 - min(1.0, ellipsoid.radii.x / vertexRadius);\n'; fragmentShader += ' float reflectionDotNadir = dot(r, normalize(positionWC));\n'; // Flipping the X vector is a cheap way to get the inverse of czm_temeToPseudoFixed, since that's a rotation about Z. fragmentShader += ' r.x = -r.x;\n'; diff --git a/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.glsl b/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.glsl index 0b3e8f237c8e..cc3e4efc3b38 100644 --- a/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.glsl +++ b/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.glsl @@ -5,8 +5,8 @@ * @glslFunction * */ -bool czm_ellipsoidContainsPoint(vec3 ellipsoid_inverseRadii, vec3 point) +bool czm_ellipsoidContainsPoint(czm_ellipsoid ellipsoid, vec3 point) { - vec3 scaled = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz; + vec3 scaled = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz; return (dot(scaled, scaled) <= 1.0); } diff --git a/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl b/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl index 29086ab9363a..b1bea1a33495 100644 --- a/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl +++ b/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.glsl @@ -4,17 +4,17 @@ * @name czm_rayEllipsoidIntersectionInterval * @glslFunction */ -czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 ellipsoid_center, vec3 ellipsoid_inverseRadii) +czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, czm_ellipsoid ellipsoid) { // ray and ellipsoid center in eye coordinates. radii in model coordinates. - vec3 q = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz; - vec3 w = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz; - - q = q - ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ellipsoid_center, 1.0)).xyz; - + vec3 q = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz; + vec3 w = ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz; + + q = q - ellipsoid.inverseRadii * (czm_inverseModelView * vec4(ellipsoid.center, 1.0)).xyz; + float q2 = dot(q, q); float qw = dot(q, w); - + if (q2 > 1.0) // Outside ellipsoid. { if (qw >= 0.0) // Looking outward or tangent (0 intersections). @@ -27,11 +27,11 @@ czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 ellipsoid_ float difference = q2 - 1.0; // Positively valued. float w2 = dot(w, w); float product = w2 * difference; - + if (qw2 < product) // Imaginary roots (0 intersections). { - return czm_emptyRaySegment; - } + return czm_emptyRaySegment; + } else if (qw2 > product) // Distinct roots (2 intersections). { float discriminant = qw * qw - product; diff --git a/Source/Shaders/DepthPlaneFS.glsl b/Source/Shaders/DepthPlaneFS.glsl index 9b6f2c62eb96..41385729ae4b 100644 --- a/Source/Shaders/DepthPlaneFS.glsl +++ b/Source/Shaders/DepthPlaneFS.glsl @@ -2,14 +2,13 @@ varying vec4 positionEC; void main() { + // TODO: make arbitrary ellipsoid + czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); + vec3 direction = normalize(positionEC.xyz); czm_ray ray = czm_ray(vec3(0.0), direction); - vec3 ellipsoid_center = czm_view[3].xyz; - vec3 ellipsoid_radii = vec3(6378137.0, 6378137.0, 6356752.314245); - vec3 ellipsoid_inverseRadii = vec3(1.0 / ellipsoid_radii.x, 1.0 / ellipsoid_radii.y, 1.0 / ellipsoid_radii.z); - - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, ellipsoid_inverseRadii); + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); if (!czm_isEmpty(intersection)) { gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); diff --git a/Source/Shaders/EllipsoidFS.glsl b/Source/Shaders/EllipsoidFS.glsl index e7e5fbe1c267..d028e502b96d 100644 --- a/Source/Shaders/EllipsoidFS.glsl +++ b/Source/Shaders/EllipsoidFS.glsl @@ -72,11 +72,10 @@ void main() } // March ray forward to intersection with larger sphere and find + // actual intersection point with ellipsoid. + czm_ellipsoid ellipsoid = czm_ellipsoidNew(ellipsoidCenter, u_radii); czm_ray ray = czm_ray(t * direction, direction); - - vec3 ellipsoid_inverseRadii = vec3(1.0 / u_radii.x, 1.0 / u_radii.y, 1.0 / u_radii.z); - - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoidCenter, ellipsoid_inverseRadii); + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); if (czm_isEmpty(intersection)) { diff --git a/Source/Shaders/GlobeFS.glsl b/Source/Shaders/GlobeFS.glsl index efd65ceb2274..ed6085494247 100644 --- a/Source/Shaders/GlobeFS.glsl +++ b/Source/Shaders/GlobeFS.glsl @@ -278,7 +278,7 @@ void main() float fadeOutDist = u_lightingFadeDistance.x; float fadeInDist = u_lightingFadeDistance.y; if (czm_sceneMode != czm_sceneMode3D) { - vec3 radii = vec3(6378137.0, 6378137.0, 6356752.314245); + vec3 radii = czm_getWgs84EllipsoidEC().radii; float maxRadii = max(radii.x, max(radii.y, radii.z)); fadeOutDist -= maxRadii; fadeInDist -= maxRadii; @@ -376,6 +376,8 @@ void main() } #if defined(PER_FRAGMENT_GROUND_ATMOSPHERE) && (defined(ENABLE_DAYNIGHT_SHADING) || defined(ENABLE_VERTEX_LIGHTING)) + czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); + float mpp = czm_metersPerPixel(vec4(0.0, 0.0, -czm_currentFrustum.x, 1.0)); vec2 xy = gl_FragCoord.xy / czm_viewport.zw * 2.0 - vec2(1.0); xy *= czm_viewport.zw * mpp * 0.5; @@ -383,11 +385,7 @@ void main() vec3 direction = normalize(vec3(xy, -czm_currentFrustum.x)); czm_ray ray = czm_ray(vec3(0.0), direction); - vec3 ellipsoid_center = czm_view[3].xyz; - vec3 ellipsoid_radii = vec3(6378137.0, 6378137.0, 6356752.314245); - vec3 ellipsoid_inverseRadii = vec3(1.0 / ellipsoid_radii.x, 1.0 / ellipsoid_radii.y, 1.0 / ellipsoid_radii.z); - - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, ellipsoid_inverseRadii); + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); vec3 ellipsoidPosition = czm_pointAlongRay(ray, intersection.start); ellipsoidPosition = (czm_inverseView * vec4(ellipsoidPosition, 1.0)).xyz; diff --git a/Source/Shaders/GlobeVS.glsl b/Source/Shaders/GlobeVS.glsl index 96fb6ed6da18..5099f15af85d 100644 --- a/Source/Shaders/GlobeVS.glsl +++ b/Source/Shaders/GlobeVS.glsl @@ -176,8 +176,7 @@ void main() #endif #ifdef APPLY_MATERIAL - vec3 ellipsoid_radii = vec3(6378137.0, 6378137.0, 6356752.314245); - float northPoleZ = ellipsoid_radii.z; + float northPoleZ = czm_getWgs84EllipsoidEC().radii.z; vec3 northPolePositionMC = vec3(0.0, 0.0, northPoleZ); vec3 ellipsoidNormal = normalize(v_positionMC); // For a sphere this is correct, but not generally for an ellipsoid. vec3 vectorEastMC = normalize(cross(northPolePositionMC - v_positionMC, ellipsoidNormal)); From 9424353a278e5741f4185ec2cacb127784cbb057 Mon Sep 17 00:00:00 2001 From: Zhouhai Date: Wed, 26 Jun 2019 11:45:59 +0800 Subject: [PATCH 08/10] Delete ellipsoidNew.glsl --- Source/Shaders/Builtin/Functions/ellipsoidNew.glsl | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 Source/Shaders/Builtin/Functions/ellipsoidNew.glsl diff --git a/Source/Shaders/Builtin/Functions/ellipsoidNew.glsl b/Source/Shaders/Builtin/Functions/ellipsoidNew.glsl deleted file mode 100644 index b1bd61fce129..000000000000 --- a/Source/Shaders/Builtin/Functions/ellipsoidNew.glsl +++ /dev/null @@ -1,14 +0,0 @@ -/** - * DOC_TBA - * - * @name czm_ellipsoidNew - * @glslFunction - * - */ -czm_ellipsoid czm_ellipsoidNew(vec3 center, vec3 radii) -{ - vec3 inverseRadii = vec3(1.0 / radii.x, 1.0 / radii.y, 1.0 / radii.z); - vec3 inverseRadiiSquared = inverseRadii * inverseRadii; - czm_ellipsoid temp = czm_ellipsoid(center, radii, inverseRadii, inverseRadiiSquared); - return temp; -} From 5151cac995a5fe604935aa2e5e15bed4782291d4 Mon Sep 17 00:00:00 2001 From: Zhouhai Date: Wed, 26 Jun 2019 16:14:47 +0800 Subject: [PATCH 09/10] modify Constant Name modify constant name --- Source/Scene/processPbrMaterials.js | 2 +- Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl | 4 ++-- Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl | 4 ++-- Source/Shaders/DepthPlaneFS.glsl | 2 +- Source/Shaders/GlobeFS.glsl | 4 ++-- Source/Shaders/GlobeVS.glsl | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Scene/processPbrMaterials.js b/Source/Scene/processPbrMaterials.js index f0bedc90cb8e..b61e97ac8b29 100644 --- a/Source/Scene/processPbrMaterials.js +++ b/Source/Scene/processPbrMaterials.js @@ -741,7 +741,7 @@ define([ fragmentShader += ' vec3 r = normalize(czm_inverseViewRotation * normalize(reflect(v, n)));\n'; // Figure out if the reflection vector hits the ellipsoid fragmentShader += ' float vertexRadius = length(positionWC);\n'; - fragmentShader += ' float horizonDotNadir = 1.0 - min(1.0, czm_ellipsoid_radii.x / vertexRadius);\n'; + fragmentShader += ' float horizonDotNadir = 1.0 - min(1.0, czm_ellipsoidRadii.x / vertexRadius);\n'; fragmentShader += ' float reflectionDotNadir = dot(r, normalize(positionWC));\n'; // Flipping the X vector is a cheap way to get the inverse of czm_temeToPseudoFixed, since that's a rotation about Z. fragmentShader += ' r.x = -r.x;\n'; diff --git a/Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl b/Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl index 69edbdb94a4e..82c3a20e9219 100644 --- a/Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl +++ b/Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl @@ -1,7 +1,7 @@ /** * 0.1 * - * @name czm_ellipsoid_inverseradii + * @name czm_ellipsoidInverseRadii * @glslConstant */ -const vec3 czm_ellipsoid_inverseRadii = vec3(1.0 / 6378137.0, 1.0 / 6378137.0, 1.0 / 6356752.314245); +const vec3 czm_ellipsoidInverseRadii = vec3(1.0 / 6378137.0, 1.0 / 6378137.0, 1.0 / 6356752.314245); diff --git a/Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl b/Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl index 789d4e99f9d3..10b96e272c12 100644 --- a/Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl +++ b/Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl @@ -1,7 +1,7 @@ /** * 0.1 * - * @name czm_ellipsoid_radii + * @name czm_ellipsoidRadii * @glslConstant */ -const vec3 czm_ellipsoid_radii = vec3(6378137.0, 6378137.0, 6356752.314245); +const vec3 czm_ellipsoidRadii = vec3(6378137.0, 6378137.0, 6356752.314245); diff --git a/Source/Shaders/DepthPlaneFS.glsl b/Source/Shaders/DepthPlaneFS.glsl index 17606633e9c3..10c3ca2a0722 100644 --- a/Source/Shaders/DepthPlaneFS.glsl +++ b/Source/Shaders/DepthPlaneFS.glsl @@ -7,7 +7,7 @@ void main() vec3 ellipsoid_center = czm_view[3].xyz; - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, czm_ellipsoid_inverseRadii); + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, czm_ellipsoidInverseRadii); if (!czm_isEmpty(intersection)) { gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); diff --git a/Source/Shaders/GlobeFS.glsl b/Source/Shaders/GlobeFS.glsl index 293488fb66e7..59907afb4063 100644 --- a/Source/Shaders/GlobeFS.glsl +++ b/Source/Shaders/GlobeFS.glsl @@ -278,7 +278,7 @@ void main() float fadeOutDist = u_lightingFadeDistance.x; float fadeInDist = u_lightingFadeDistance.y; if (czm_sceneMode != czm_sceneMode3D) { - vec3 radii = czm_ellipsoid_radii; + vec3 radii = czm_ellipsoidRadii; float maxRadii = max(radii.x, max(radii.y, radii.z)); fadeOutDist -= maxRadii; fadeInDist -= maxRadii; @@ -385,7 +385,7 @@ void main() vec3 ellipsoid_center = czm_view[3].xyz; - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, czm_ellipsoid_inverseRadii); + czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, czm_ellipsoidInverseRadii); vec3 ellipsoidPosition = czm_pointAlongRay(ray, intersection.start); ellipsoidPosition = (czm_inverseView * vec4(ellipsoidPosition, 1.0)).xyz; diff --git a/Source/Shaders/GlobeVS.glsl b/Source/Shaders/GlobeVS.glsl index 51f815bf50a9..684321547163 100644 --- a/Source/Shaders/GlobeVS.glsl +++ b/Source/Shaders/GlobeVS.glsl @@ -176,7 +176,7 @@ void main() #endif #ifdef APPLY_MATERIAL - float northPoleZ = czm_ellipsoid_radii.z; + float northPoleZ = czm_ellipsoidRadii.z; vec3 northPolePositionMC = vec3(0.0, 0.0, northPoleZ); vec3 ellipsoidNormal = normalize(v_positionMC); // For a sphere this is correct, but not generally for an ellipsoid. vec3 vectorEastMC = normalize(cross(northPolePositionMC - v_positionMC, ellipsoidNormal)); From 63ec778e0c85a63ba05d162757b994c7d875581c Mon Sep 17 00:00:00 2001 From: Zhouhai Date: Fri, 28 Jun 2019 09:21:33 +0800 Subject: [PATCH 10/10] add note and update CHANGES.md add note and update CHANGES.md --- CHANGES.md | 1 + Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl | 2 +- Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8cb37d09b292..796056691710 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ Change Log * Fixed a bug where billboards were not pickable when zoomed out completely in 2D View. [#7908](https://github.com/AnalyticalGraphicsInc/cesium/pull/7908) * Fixed polyline colors when `scene.highDynamicRange` is enabled. [#7924](https://github.com/AnalyticalGraphicsInc/cesium/pull/7924) * Fixed a bug in the inspector where the min/max height values of a picked tile were undefined. [#7904](https://github.com/AnalyticalGraphicsInc/cesium/pull/7904) +* Fixed a bug that caused 3D models to appear darker on Android devices. [#7944](https://github.com/AnalyticalGraphicsInc/cesium/pull/7944) ### 1.58.1 - 2018-06-03 _This is an npm-only release to fix a publishing issue_ diff --git a/Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl b/Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl index 82c3a20e9219..1350a9a8ded8 100644 --- a/Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl +++ b/Source/Shaders/Builtin/Constants/ellipsoidInverseRadii.glsl @@ -1,5 +1,5 @@ /** - * 0.1 + * The reciprocal of the radius of the WGS84 ellipsoid. * * @name czm_ellipsoidInverseRadii * @glslConstant diff --git a/Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl b/Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl index 10b96e272c12..01574c8b1f1c 100644 --- a/Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl +++ b/Source/Shaders/Builtin/Constants/ellipsoidRadii.glsl @@ -1,5 +1,5 @@ /** - * 0.1 + * The radius of the WGS84 ellipsoid. * * @name czm_ellipsoidRadii * @glslConstant