From 24ff46babea55032ce44373b603c76e4bb122961 Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Fri, 20 Oct 2017 13:28:32 -0400 Subject: [PATCH 01/31] Added material support to the globe --- Apps/Sandcastle/gallery/Globe Materials.html | 220 ++++++++++++++++++ Apps/Sandcastle/gallery/Globe Materials.jpg | Bin 0 -> 20762 bytes Source/Scene/Globe.js | 59 ++++- Source/Scene/GlobeSurfaceShaderSet.js | 12 +- Source/Scene/GlobeSurfaceTileProvider.js | 6 + Source/Scene/Material.js | 86 +++++++ .../Builtin/Structs/materialInput.glsl | 4 + Source/Shaders/GlobeFS.glsl | 12 + Source/Shaders/GlobeVS.glsl | 7 + .../Materials/ElevationContourMaterial.glsl | 16 ++ .../Materials/ElevationRampMaterial.glsl | 13 ++ Source/Shaders/Materials/SlopeMaterial.glsl | 6 + .../Shaders/Materials/SlopeRampMaterial.glsl | 25 ++ 13 files changed, 455 insertions(+), 11 deletions(-) create mode 100644 Apps/Sandcastle/gallery/Globe Materials.html create mode 100644 Apps/Sandcastle/gallery/Globe Materials.jpg create mode 100644 Source/Shaders/Materials/ElevationContourMaterial.glsl create mode 100644 Source/Shaders/Materials/ElevationRampMaterial.glsl create mode 100644 Source/Shaders/Materials/SlopeMaterial.glsl create mode 100644 Source/Shaders/Materials/SlopeRampMaterial.glsl diff --git a/Apps/Sandcastle/gallery/Globe Materials.html b/Apps/Sandcastle/gallery/Globe Materials.html new file mode 100644 index 000000000000..2f4635ce76b4 --- /dev/null +++ b/Apps/Sandcastle/gallery/Globe Materials.html @@ -0,0 +1,220 @@ + + + + + + + + + Cesium Demo + + + + + + +
+

Loading...

+
+
+
+
+
+ + + + + + +
Contour Spacing + +
+
+ + + diff --git a/Apps/Sandcastle/gallery/Globe Materials.jpg b/Apps/Sandcastle/gallery/Globe Materials.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8669e3b9739b9cfb4bde75e61394b336570b3752 GIT binary patch literal 20762 zcmbTdbyQnV^e-B`c%itqXesVaT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*#PGv|+s`t7#4uiV^N$$4*UB<41^bx^Ue?z>Jg!N4or^{zux@lDmXl^V$;vs*&u zDC22Zh1VC9QUW8(=WPV3hr0P|3sM~K=+q-YOW?sGHL8REjeQ#`&UP3&z zdz?C{AKhMn4#4N@>Em8C)aCK6yhZeqNq2Aziy#0f#&)S+Oas%QJ^Pea*m*x@=hpA= zdLMAGw7#`Mk1FNmrKkAdr7yk7yY9ML%G+NJyeM@a5!l(qGeX-A_fkj72Ij}P0RDBc zsc9DH;|;yH?>1W74ZDatLEhYbJ^g*CqP(gUn zQ1M*;GVveUrgvGPSYd^f1@e(qQZdK(S8qMePkQ<*_Eh*iZ>oGzwXwbOW`g9lOK+?D~UBJuP!vzxspqJR=91T z2Ey(c#&BxI{{X|^4(q#r;TbxGrNcw!vRdpKD+(o&Y^=h?;{oeX_SG?k+k(qHiA&%t|1CDz(V zXLwsY zKPrxZb6r=5uKwGiTiL9VWngt;>72+0_H2XPf;k)yUTC7eGlp|)U3$E=r+sa*{{SQU yFUS7?33yY7@PAmz@Se&}3A;|C*V0pIdL?3S_*j~k_iTUfz@myP^s67k=l|L2cEu_H literal 0 HcmV?d00001 diff --git a/Source/Scene/Globe.js b/Source/Scene/Globe.js index 8a351098c7b9..bf1ec692eced 100644 --- a/Source/Scene/Globe.js +++ b/Source/Scene/Globe.js @@ -24,6 +24,7 @@ define([ './GlobeSurfaceShaderSet', './GlobeSurfaceTileProvider', './ImageryLayerCollection', + './Material', './QuadtreePrimitive', './SceneMode', './ShadowMode' @@ -53,6 +54,7 @@ define([ GlobeSurfaceShaderSet, GlobeSurfaceTileProvider, ImageryLayerCollection, + Material, QuadtreePrimitive, SceneMode, ShadowMode) { @@ -79,14 +81,9 @@ define([ this._imageryLayerCollection = imageryLayerCollection; this._surfaceShaderSet = new GlobeSurfaceShaderSet(); + this._material = undefined; - this._surfaceShaderSet.baseVertexShaderSource = new ShaderSource({ - sources : [GroundAtmosphere, GlobeVS] - }); - - this._surfaceShaderSet.baseFragmentShaderSource = new ShaderSource({ - sources : [GlobeFS] - }); + this.dirtyShaders(); this._surface = new QuadtreePrimitive({ tileProvider : new GlobeSurfaceTileProvider({ @@ -276,6 +273,24 @@ define([ get: function() { return this._surface.tileLoadProgressEvent; } + }, + + /** + * Gets or sets the material appearance of the Globe. This can be one of several built-in {@link Material} objects or a custom material, scripted with + * {@link https://github.com/AnalyticalGraphicsInc/cesium/wiki/Fabric|Fabric}. + * @memberof Globe.prototype + * @type {Material} + */ + material: { + get: function() { + return this._material; + }, + set: function(material) { + if (this._material !== material) { + this._material = material; + this.dirtyShaders(); + } + } } }); @@ -525,6 +540,10 @@ define([ return; } + if (this._material) { + this._material.update(frameState.context); + } + var surface = this._surface; var pass = frameState.passes; @@ -550,6 +569,32 @@ define([ } }; + /** + * @private + */ + Globe.prototype.dirtyShaders = function() { + this._surfaceShaderSet.baseVertexShaderSource = new ShaderSource({ + sources : [GroundAtmosphere, GlobeVS] + }); + + var fragmentSources = []; + var fragmentDefines = []; + if (this._material) { + fragmentSources.push(this._material.shaderSource); + fragmentDefines.push("APPLY_MATERIAL"); + + // Set the material uniform map to the materials + this._surface._tileProvider.uniformMap = this._material._uniforms; + } + fragmentSources.push(GlobeFS); + + this._surfaceShaderSet.baseFragmentShaderSource = new ShaderSource({ + sources : fragmentSources, + defines: fragmentDefines + }); + this._surfaceShaderSet.material = this._material; + }; + /** * Returns true if this object was destroyed; otherwise, false. *

diff --git a/Source/Scene/GlobeSurfaceShaderSet.js b/Source/Scene/GlobeSurfaceShaderSet.js index 2442df1a5efb..abcdc95ae404 100644 --- a/Source/Scene/GlobeSurfaceShaderSet.js +++ b/Source/Scene/GlobeSurfaceShaderSet.js @@ -12,10 +12,11 @@ define([ SceneMode) { 'use strict'; - function GlobeSurfaceShader(numberOfDayTextures, flags, shaderProgram) { + function GlobeSurfaceShader(numberOfDayTextures, flags, material, shaderProgram) { this.numberOfDayTextures = numberOfDayTextures; this.flags = flags; this.shaderProgram = shaderProgram; + this.material = material; } /** @@ -30,6 +31,8 @@ define([ this._shadersByTexturesFlags = []; this._pickShaderPrograms = []; + + this.material = undefined; } function getPositionMode(sceneMode) { @@ -92,7 +95,8 @@ define([ var surfaceShader = surfaceTile.surfaceShader; if (defined(surfaceShader) && surfaceShader.numberOfDayTextures === numberOfDayTextures && - surfaceShader.flags === flags) { + surfaceShader.flags === flags && + surfaceShader.material === this.material) { return surfaceShader.shaderProgram; } @@ -104,7 +108,7 @@ define([ } surfaceShader = shadersByFlags[flags]; - if (!defined(surfaceShader)) { + if (!defined(surfaceShader) || surfaceShader.material !== this.material) { // Cache miss - we've never seen this combination of numberOfDayTextures and flags before. var vs = this.baseVertexShaderSource.clone(); var fs = this.baseFragmentShaderSource.clone(); @@ -199,7 +203,7 @@ define([ attributeLocations : terrainEncoding.getAttributeLocations() }); - surfaceShader = shadersByFlags[flags] = new GlobeSurfaceShader(numberOfDayTextures, flags, shader); + surfaceShader = shadersByFlags[flags] = new GlobeSurfaceShader(numberOfDayTextures, flags, this.material, shader); } surfaceTile.surfaceShader = surfaceShader; diff --git a/Source/Scene/GlobeSurfaceTileProvider.js b/Source/Scene/GlobeSurfaceTileProvider.js index 00c047e2b83d..c7107ead82b6 100644 --- a/Source/Scene/GlobeSurfaceTileProvider.js +++ b/Source/Scene/GlobeSurfaceTileProvider.js @@ -6,6 +6,7 @@ define([ '../Core/Cartesian4', '../Core/Color', '../Core/ColorGeometryInstanceAttribute', + '../Core/combine', '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', @@ -50,6 +51,7 @@ define([ Cartesian4, Color, ColorGeometryInstanceAttribute, + combine, defaultValue, defined, defineProperties, @@ -1259,6 +1261,10 @@ define([ uniformMapProperties.minMaxHeight.y = encoding.maximumHeight; Matrix4.clone(encoding.matrix, uniformMapProperties.scaleAndBias); + if (tileProvider.uniformMap) { + uniformMap = combine(uniformMap, tileProvider.uniformMap); + } + command.shaderProgram = tileProvider._surfaceShaderSet.getShaderProgram(frameState, surfaceTile, numberOfDayTextures, applyBrightness, applyContrast, applyHue, applySaturation, applyGamma, applyAlpha, applySplit, showReflectiveOcean, showOceanWaves, tileProvider.enableLighting, hasVertexNormals, useWebMercatorProjection, applyFog); command.castShadows = castShadows; command.receiveShadows = receiveShadows; diff --git a/Source/Scene/Material.js b/Source/Scene/Material.js index 5f5f53e2b430..ca593a63d09a 100644 --- a/Source/Scene/Material.js +++ b/Source/Scene/Material.js @@ -21,6 +21,8 @@ define([ '../Shaders/Materials/BumpMapMaterial', '../Shaders/Materials/CheckerboardMaterial', '../Shaders/Materials/DotMaterial', + '../Shaders/Materials/ElevationContourMaterial', + '../Shaders/Materials/ElevationRampMaterial', '../Shaders/Materials/FadeMaterial', '../Shaders/Materials/GridMaterial', '../Shaders/Materials/NormalMapMaterial', @@ -29,6 +31,8 @@ define([ '../Shaders/Materials/PolylineGlowMaterial', '../Shaders/Materials/PolylineOutlineMaterial', '../Shaders/Materials/RimLightingMaterial', + '../Shaders/Materials/SlopeMaterial', + '../Shaders/Materials/SlopeRampMaterial', '../Shaders/Materials/StripeMaterial', '../Shaders/Materials/Water', '../ThirdParty/when' @@ -55,6 +59,8 @@ define([ BumpMapMaterial, CheckerboardMaterial, DotMaterial, + ElevationContourMaterial, + ElevationRampMaterial, FadeMaterial, GridMaterial, NormalMapMaterial, @@ -63,6 +69,8 @@ define([ PolylineGlowMaterial, PolylineOutlineMaterial, RimLightingMaterial, + SlopeMaterial, + SlopeRampMaterial, StripeMaterial, WaterMaterial, when) { @@ -226,8 +234,21 @@ define([ *
  • outlineColor: diffuse color and alpha for the outline.
  • *
  • outlineWidth: width of the outline in pixels.
  • * + *
  • ElevationContour
  • + *
      + *
    • color: color and alpha for the contour line.
    • + *
    • spacing: spacing for contour lines in meters.
    • + *
    + *
  • ElevationRamp
  • + *
      + *
    • image: color ramp image to use for coloring the terrain.
    • + *
    • minHeight: minimum height for the ramp.
    • + *
    • maxHeight: maximum height for the ramp.
    • + *
    * * + + * * @alias Material * @@ -1470,5 +1491,70 @@ define([ } }); + /** + * Gets the name of the elevation contour material. + * @type {String} + * @readonly + */ + Material.ElevationContourType = 'ElevationContour'; + Material._materialCache.addMaterial(Material.ElevationContourType, { + fabric : { + type : Material.ElevationContourType, + uniforms : { + spacing: 100.0, + color: new Color(1.0, 0.0, 0.0, 1.0) + }, + source : ElevationContourMaterial + }, + translucent : false + }); + + /** + * Gets the name of the elevation contour material. + * @type {String} + * @readonly + */ + Material.ElevationRampType = 'ElevationRamp'; + Material._materialCache.addMaterial(Material.ElevationRampType, { + fabric : { + type : Material.ElevationRampType, + uniforms : { + image: Material.DefaultImageId, + minHeight: 0.0, + maxHeight: 10000.0 + }, + source : ElevationRampMaterial + }, + translucent : false + }); + + /** + * Gets the name of the slope material. + * @type {String} + * @readonly + */ + Material.SlopeMaterialType = 'Slope'; + Material._materialCache.addMaterial(Material.SlopeMaterialType, { + fabric : { + type : Material.SlopeMaterialType, + source : SlopeMaterial + }, + translucent : false + }); + + /** + * Gets the name of the slope ramp material. + * @type {String} + * @readonly + */ + Material.SlopeRampMaterialType = 'SlopeRamp'; + Material._materialCache.addMaterial(Material.SlopeRampMaterialType, { + fabric : { + type : Material.SlopeRampMaterialType, + source : SlopeRampMaterial + }, + translucent : false + }); + return Material; }); diff --git a/Source/Shaders/Builtin/Structs/materialInput.glsl b/Source/Shaders/Builtin/Structs/materialInput.glsl index 4329dda238c7..321a82b4959b 100644 --- a/Source/Shaders/Builtin/Structs/materialInput.glsl +++ b/Source/Shaders/Builtin/Structs/materialInput.glsl @@ -10,6 +10,8 @@ * @property {vec3} normalEC Unperturbed surface normal in eye coordinates. * @property {mat3} tangentToEyeMatrix Matrix for converting a tangent space normal to eye space. * @property {vec3} positionToEyeEC Vector from the fragment to the eye in eye coordinates. The magnitude is the distance in meters from the fragment to the eye. + * @property {float} height The height of the terrain. Only available for globe materials. + * @property {float} slope The slope of the terrain normalized from 0 to 1. Only available for globe materials. */ struct czm_materialInput { @@ -19,4 +21,6 @@ struct czm_materialInput vec3 normalEC; mat3 tangentToEyeMatrix; vec3 positionToEyeEC; + float height; + float slope; }; diff --git a/Source/Shaders/GlobeFS.glsl b/Source/Shaders/GlobeFS.glsl index 34f8bc02c4ca..daa73bfd16b3 100644 --- a/Source/Shaders/GlobeFS.glsl +++ b/Source/Shaders/GlobeFS.glsl @@ -57,6 +57,8 @@ varying vec3 v_positionEC; varying vec3 v_textureCoordinates; varying vec3 v_normalMC; varying vec3 v_normalEC; +varying float v_height; +varying float v_slope; #ifdef FOG varying float v_distance; @@ -180,6 +182,16 @@ void main() } #endif +#ifdef APPLY_MATERIAL + czm_materialInput materialInput; + materialInput.st = v_textureCoordinates.st; + materialInput.normalEC = normalize(v_normalEC); + materialInput.slope = v_slope; + materialInput.height = v_height; + czm_material material = czm_getMaterial(materialInput); + color.xyz = mix(color.xyz, material.diffuse, material.alpha); +#endif + #ifdef ENABLE_VERTEX_LIGHTING float diffuseIntensity = clamp(czm_getLambertDiffuse(czm_sunDirectionEC, normalize(v_normalEC)) * 0.9 + 0.3, 0.0, 1.0); vec4 finalColor = vec4(color.rgb * diffuseIntensity, color.a); diff --git a/Source/Shaders/GlobeVS.glsl b/Source/Shaders/GlobeVS.glsl index a9cbc9ed2382..cfff78756d7f 100644 --- a/Source/Shaders/GlobeVS.glsl +++ b/Source/Shaders/GlobeVS.glsl @@ -21,6 +21,8 @@ varying vec3 v_positionEC; varying vec3 v_textureCoordinates; varying vec3 v_normalMC; varying vec3 v_normalEC; +varying float v_slope; +varying float v_height; #ifdef FOG varying float v_distance; @@ -167,4 +169,9 @@ void main() v_rayleighColor = atmosColor.rayleigh; v_distance = length((czm_modelView3D * vec4(position3DWC, 1.0)).xyz); #endif + + vec3 finalNormal = normalize(v_normalMC); + vec3 worldNormal = normalize(v_positionMC.xyz); + v_slope = abs(dot(worldNormal, finalNormal)); + v_height = height; } diff --git a/Source/Shaders/Materials/ElevationContourMaterial.glsl b/Source/Shaders/Materials/ElevationContourMaterial.glsl new file mode 100644 index 000000000000..abdf962f288a --- /dev/null +++ b/Source/Shaders/Materials/ElevationContourMaterial.glsl @@ -0,0 +1,16 @@ +uniform vec4 color; + +czm_material czm_getMaterial(czm_materialInput materialInput) +{ + czm_material material = czm_getDefaultMaterial(materialInput); + + if (fract(materialInput.height / spacing) < 0.1 ) { + material.diffuse = color.rgb; + material.alpha = color.a; + } + else { + material.alpha = 0.0; + } + + return material; +} \ No newline at end of file diff --git a/Source/Shaders/Materials/ElevationRampMaterial.glsl b/Source/Shaders/Materials/ElevationRampMaterial.glsl new file mode 100644 index 000000000000..94db4faf683d --- /dev/null +++ b/Source/Shaders/Materials/ElevationRampMaterial.glsl @@ -0,0 +1,13 @@ +uniform sampler2D image; +uniform float minHeight; +uniform float maxHeight; + +czm_material czm_getMaterial(czm_materialInput materialInput) +{ + czm_material material = czm_getDefaultMaterial(materialInput); + float scaledHeight = clamp((materialInput.height - minHeight) / (maxHeight - minHeight), 0.0, 1.0); + vec4 rampColor = texture2D(image, vec2(scaledHeight, 0.5)); + material.diffuse = rampColor.rgb; + material.alpha = rampColor.a; + return material; +} \ No newline at end of file diff --git a/Source/Shaders/Materials/SlopeMaterial.glsl b/Source/Shaders/Materials/SlopeMaterial.glsl new file mode 100644 index 000000000000..3082ed0875bc --- /dev/null +++ b/Source/Shaders/Materials/SlopeMaterial.glsl @@ -0,0 +1,6 @@ +czm_material czm_getMaterial(czm_materialInput materialInput) +{ + czm_material material = czm_getDefaultMaterial(materialInput); + material.diffuse = mix(vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0), materialInput.slope); + return material; +} \ No newline at end of file diff --git a/Source/Shaders/Materials/SlopeRampMaterial.glsl b/Source/Shaders/Materials/SlopeRampMaterial.glsl new file mode 100644 index 000000000000..79c325f876c5 --- /dev/null +++ b/Source/Shaders/Materials/SlopeRampMaterial.glsl @@ -0,0 +1,25 @@ +czm_material czm_getMaterial(czm_materialInput materialInput) +{ + czm_material material = czm_getDefaultMaterial(materialInput); + + material.alpha = 0.0; + + if (materialInput.slope < 0.1) { + material.diffuse = vec3(1.0, 0.0, 0.0); + material.alpha = 1.0; + } + else if (materialInput.slope < 0.25) { + material.diffuse = vec3(0.0, 1.0, 0.0); + material.alpha = 1.0; + } + else if (materialInput.slope < 0.5) { + material.diffuse = vec3(0.0, 1.0, 1.0); + material.alpha = 1.0; + } + else if (materialInput.slope < 0.75) { + material.diffuse = vec3(0.0, 0.0, 1.0); + material.alpha = 1.0; + } + + return material; +} \ No newline at end of file From 4e3ae37656556759e43df9f29bc87bc7638d2005 Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Fri, 20 Oct 2017 13:59:44 -0400 Subject: [PATCH 02/31] Removed SlopeMaterial shader in favor of the SlopeRampMaterial which now uses a color ramp image --- Apps/Sandcastle/gallery/Globe Materials.html | 6 +--- Source/Scene/Material.js | 28 ++++++------------- Source/Shaders/Materials/SlopeMaterial.glsl | 6 ---- .../Shaders/Materials/SlopeRampMaterial.glsl | 25 ++++------------- 4 files changed, 15 insertions(+), 50 deletions(-) delete mode 100644 Source/Shaders/Materials/SlopeMaterial.glsl diff --git a/Apps/Sandcastle/gallery/Globe Materials.html b/Apps/Sandcastle/gallery/Globe Materials.html index 2f4635ce76b4..524d9854a9fe 100644 --- a/Apps/Sandcastle/gallery/Globe Materials.html +++ b/Apps/Sandcastle/gallery/Globe Materials.html @@ -191,11 +191,7 @@ text : 'Slope Color Ramp Material', onselect : function() { viewer.scene.globe.material = Cesium.Material.fromType('SlopeRamp'); - } -}, { - text : 'Slope Shading Material', - onselect : function() { - viewer.scene.globe.material = Cesium.Material.fromType('Slope'); + viewer.scene.globe.material.uniforms.image = getColorRamp(); } }], 'materialMenu'); diff --git a/Source/Scene/Material.js b/Source/Scene/Material.js index ca593a63d09a..18491460d254 100644 --- a/Source/Scene/Material.js +++ b/Source/Scene/Material.js @@ -31,7 +31,6 @@ define([ '../Shaders/Materials/PolylineGlowMaterial', '../Shaders/Materials/PolylineOutlineMaterial', '../Shaders/Materials/RimLightingMaterial', - '../Shaders/Materials/SlopeMaterial', '../Shaders/Materials/SlopeRampMaterial', '../Shaders/Materials/StripeMaterial', '../Shaders/Materials/Water', @@ -69,7 +68,6 @@ define([ PolylineGlowMaterial, PolylineOutlineMaterial, RimLightingMaterial, - SlopeMaterial, SlopeRampMaterial, StripeMaterial, WaterMaterial, @@ -245,10 +243,13 @@ define([ *
  • minHeight: minimum height for the ramp.
  • *
  • maxHeight: maximum height for the ramp.
  • * + *
  • SlopeRamp
  • + *
      + *
    • image: color ramp image to use for coloring the terrain.
    • + *
    + * * * - - * * @alias Material * @@ -1521,27 +1522,13 @@ define([ uniforms : { image: Material.DefaultImageId, minHeight: 0.0, - maxHeight: 10000.0 + maxHeight: 10000.0, }, source : ElevationRampMaterial }, translucent : false }); - /** - * Gets the name of the slope material. - * @type {String} - * @readonly - */ - Material.SlopeMaterialType = 'Slope'; - Material._materialCache.addMaterial(Material.SlopeMaterialType, { - fabric : { - type : Material.SlopeMaterialType, - source : SlopeMaterial - }, - translucent : false - }); - /** * Gets the name of the slope ramp material. * @type {String} @@ -1551,6 +1538,9 @@ define([ Material._materialCache.addMaterial(Material.SlopeRampMaterialType, { fabric : { type : Material.SlopeRampMaterialType, + uniforms : { + image: Material.DefaultImageId + }, source : SlopeRampMaterial }, translucent : false diff --git a/Source/Shaders/Materials/SlopeMaterial.glsl b/Source/Shaders/Materials/SlopeMaterial.glsl deleted file mode 100644 index 3082ed0875bc..000000000000 --- a/Source/Shaders/Materials/SlopeMaterial.glsl +++ /dev/null @@ -1,6 +0,0 @@ -czm_material czm_getMaterial(czm_materialInput materialInput) -{ - czm_material material = czm_getDefaultMaterial(materialInput); - material.diffuse = mix(vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0), materialInput.slope); - return material; -} \ No newline at end of file diff --git a/Source/Shaders/Materials/SlopeRampMaterial.glsl b/Source/Shaders/Materials/SlopeRampMaterial.glsl index 79c325f876c5..0f537273f21e 100644 --- a/Source/Shaders/Materials/SlopeRampMaterial.glsl +++ b/Source/Shaders/Materials/SlopeRampMaterial.glsl @@ -1,25 +1,10 @@ +uniform sampler2D image; + czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); - - material.alpha = 0.0; - - if (materialInput.slope < 0.1) { - material.diffuse = vec3(1.0, 0.0, 0.0); - material.alpha = 1.0; - } - else if (materialInput.slope < 0.25) { - material.diffuse = vec3(0.0, 1.0, 0.0); - material.alpha = 1.0; - } - else if (materialInput.slope < 0.5) { - material.diffuse = vec3(0.0, 1.0, 1.0); - material.alpha = 1.0; - } - else if (materialInput.slope < 0.75) { - material.diffuse = vec3(0.0, 0.0, 1.0); - material.alpha = 1.0; - } - + vec4 rampColor = texture2D(image, vec2(materialInput.slope, 0.5)); + material.diffuse = rampColor.rgb; + material.alpha = rampColor.a; return material; } \ No newline at end of file From 6c2d17ceea989ce09abce1291677f0086a5dc238 Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Fri, 20 Oct 2017 14:53:41 -0400 Subject: [PATCH 03/31] Got rid of multiple enableLighting calls --- Apps/Sandcastle/gallery/Globe Materials.html | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Apps/Sandcastle/gallery/Globe Materials.html b/Apps/Sandcastle/gallery/Globe Materials.html index 524d9854a9fe..aa137a940a3e 100644 --- a/Apps/Sandcastle/gallery/Globe Materials.html +++ b/Apps/Sandcastle/gallery/Globe Materials.html @@ -42,17 +42,13 @@ 'use strict'; //Sandcastle_Begin var viewer = new Cesium.Viewer('cesiumContainer'); - -// set lighting to true -viewer.scene.globe.enableLighting = true; - var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({ url : 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles', requestWaterMask : true, requestVertexNormals : true }); viewer.terrainProvider = cesiumTerrainProviderMeshes; -// Enable lighting so the normal flows through the shader + viewer.scene.globe.enableLighting = true; // The viewModel tracks the state of our mini application. @@ -102,7 +98,6 @@ text : 'CesiumTerrainProvider - STK World Terrain', onselect : function() { viewer.terrainProvider = cesiumTerrainProviderMeshes; - viewer.scene.globe.enableLighting = true; } }, { text : 'CesiumTerrainProvider - STK World Terrain - no effects', @@ -118,7 +113,6 @@ url : 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles', requestVertexNormals : true }); - viewer.scene.globe.enableLighting = true; } }, { text : 'CesiumTerrainProvider - STK World Terrain w/ Water', From ce71917669c09fed907bc61d0ea4ccafa73121d3 Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Fri, 20 Oct 2017 14:54:14 -0400 Subject: [PATCH 04/31] Unsetting uniformMap if there is no material --- Source/Scene/Globe.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Scene/Globe.js b/Source/Scene/Globe.js index bf1ec692eced..f3100d3e4896 100644 --- a/Source/Scene/Globe.js +++ b/Source/Scene/Globe.js @@ -83,8 +83,6 @@ define([ this._surfaceShaderSet = new GlobeSurfaceShaderSet(); this._material = undefined; - this.dirtyShaders(); - this._surface = new QuadtreePrimitive({ tileProvider : new GlobeSurfaceTileProvider({ terrainProvider : terrainProvider, @@ -96,6 +94,8 @@ define([ this._terrainProvider = terrainProvider; this._terrainProviderChanged = new Event(); + this.dirtyShaders(); + /** * Determines if the globe will be shown. * @@ -586,6 +586,9 @@ define([ // Set the material uniform map to the materials this._surface._tileProvider.uniformMap = this._material._uniforms; } + else { + this._surface._tileProvider.uniformMap = undefined; + } fragmentSources.push(GlobeFS); this._surfaceShaderSet.baseFragmentShaderSource = new ShaderSource({ From a2152cc1225b04d1fc100a98055b2aa2009e7c3f Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Fri, 20 Oct 2017 14:54:25 -0400 Subject: [PATCH 05/31] Updated CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index bbe0639f423f..1df6016482e1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Change Log * Added support for the layer.json `parentUrl` property in `CesiumTerrainProvider` to allow for compositing of tilesets. * Fixed a bug that caused KML ground overlays to appear distorted when rotation was applied. [#5914](https://github.com/AnalyticalGraphicsInc/cesium/issues/5914) * Adds `invertClassification` and `invertClassificationColor` to `Scene`. When `invertClassification` is `true`, any 3D Tiles geometry that is not classified by a `ClassificationPrimitive` or `GroundPrimitive` will have its color multiplied by `invertClassificationColor`. [#5836](https://github.com/AnalyticalGraphicsInc/cesium/pull/5836) +* Adds Material support to Globe. ### 1.38 - 2017-10-02 From 5139bad745cf40821ab758a47f5e5d724f4c02ae Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Fri, 20 Oct 2017 15:02:56 -0400 Subject: [PATCH 06/31] Updated CHANGES.md with PR reference --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 1df6016482e1..4fd83eca65de 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,7 +6,7 @@ Change Log * Added support for the layer.json `parentUrl` property in `CesiumTerrainProvider` to allow for compositing of tilesets. * Fixed a bug that caused KML ground overlays to appear distorted when rotation was applied. [#5914](https://github.com/AnalyticalGraphicsInc/cesium/issues/5914) * Adds `invertClassification` and `invertClassificationColor` to `Scene`. When `invertClassification` is `true`, any 3D Tiles geometry that is not classified by a `ClassificationPrimitive` or `GroundPrimitive` will have its color multiplied by `invertClassificationColor`. [#5836](https://github.com/AnalyticalGraphicsInc/cesium/pull/5836) -* Adds Material support to Globe. +* Adds Material support to Globe. [#5919](https://github.com/AnalyticalGraphicsInc/cesium/pull/5919) ### 1.38 - 2017-10-02 From 29d4ae26fd41642eee5345e7c41b456df1fda424 Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Fri, 20 Oct 2017 15:12:52 -0400 Subject: [PATCH 07/31] Fix eslint warning --- Source/Scene/Globe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Scene/Globe.js b/Source/Scene/Globe.js index f3100d3e4896..d6a914fefa2e 100644 --- a/Source/Scene/Globe.js +++ b/Source/Scene/Globe.js @@ -581,7 +581,7 @@ define([ var fragmentDefines = []; if (this._material) { fragmentSources.push(this._material.shaderSource); - fragmentDefines.push("APPLY_MATERIAL"); + fragmentDefines.push('APPLY_MATERIAL'); // Set the material uniform map to the materials this._surface._tileProvider.uniformMap = this._material._uniforms; From 60c0121ed2b257e6bd5ff7dadffeb0ff4335ff7c Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Fri, 3 Nov 2017 16:36:30 -0400 Subject: [PATCH 08/31] Style tweaks --- Apps/Sandcastle/gallery/Globe Materials.html | 11 +++-------- CHANGES.md | 5 ++++- Source/Scene/Globe.js | 3 +-- Source/Scene/GlobeSurfaceShaderSet.js | 2 +- Source/Scene/GlobeSurfaceTileProvider.js | 2 +- .../Shaders/Materials/ElevationContourMaterial.glsl | 12 +++++++----- Source/Shaders/Materials/ElevationRampMaterial.glsl | 2 +- Source/Shaders/Materials/SlopeRampMaterial.glsl | 2 +- 8 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Apps/Sandcastle/gallery/Globe Materials.html b/Apps/Sandcastle/gallery/Globe Materials.html index aa137a940a3e..68b860fe57eb 100644 --- a/Apps/Sandcastle/gallery/Globe Materials.html +++ b/Apps/Sandcastle/gallery/Globe Materials.html @@ -4,8 +4,8 @@ - - + + Cesium Demo @@ -31,7 +31,7 @@ Contour Spacing - + @@ -64,16 +64,11 @@ var grd = ctx.createLinearGradient(0, 0, 100, 0); grd.addColorStop(0, "black"); - grd.addColorStop(0.25, "red"); - grd.addColorStop(0.5, "blue"); - grd.addColorStop(0.75, "green"); - grd.addColorStop(1.0, "white"); - ctx.fillStyle = grd; ctx.fillRect(0, 0, 100, 1); return ramp; diff --git a/CHANGES.md b/CHANGES.md index a82d8cb704d3..410231383d4e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,10 @@ Change Log ========== +### 1.40 - 2017-12-01 + +* Adds Material support to Globe. [#5919](https://github.com/AnalyticalGraphicsInc/cesium/pull/5919) + ### 1.39 - 2017-11-01 * Added support for right-to-left language detection in labels, currently Hebrew and Arabic are supported. To enable it, set `Cesium.Label.enableRightToLeftDetection = true` at the beginning of your application. [#5771](https://github.com/AnalyticalGraphicsInc/cesium/pull/5771) @@ -15,7 +19,6 @@ Change Log * Added `eyeSeparation` and `focalLength` properties to `Scene` to configure VR settings. [#5917](https://github.com/AnalyticalGraphicsInc/cesium/pull/5917) * Added `customTags` property to the UrlTemplateImageryProvider to allow custom keywords in the template URL. [#5696](https://github.com/AnalyticalGraphicsInc/cesium/pull/5696) * Improved CZML Reference Properties example [#5754](https://github.com/AnalyticalGraphicsInc/cesium/pull/5754) -* Adds Material support to Globe. [#5919](https://github.com/AnalyticalGraphicsInc/cesium/pull/5919) * Fixed bug with placemarks in imported KML: placemarks with no specified icon would be displayed with default icon. [#5819](https://github.com/AnalyticalGraphicsInc/cesium/issues/5819) * Fixed flickering artifacts on tilesets with thin walls. [#5940](https://github.com/AnalyticalGraphicsInc/cesium/pull/5940) * Fixed bright fog when terrain lighting is enabled and added `Fog.minimumBrightness` to affect how bright the fog will be when in complete darkness. [#5934](https://github.com/AnalyticalGraphicsInc/cesium/pull/5934) diff --git a/Source/Scene/Globe.js b/Source/Scene/Globe.js index d6a914fefa2e..0620db6d063f 100644 --- a/Source/Scene/Globe.js +++ b/Source/Scene/Globe.js @@ -585,8 +585,7 @@ define([ // Set the material uniform map to the materials this._surface._tileProvider.uniformMap = this._material._uniforms; - } - else { + } else { this._surface._tileProvider.uniformMap = undefined; } fragmentSources.push(GlobeFS); diff --git a/Source/Scene/GlobeSurfaceShaderSet.js b/Source/Scene/GlobeSurfaceShaderSet.js index abcdc95ae404..56e4f586b452 100644 --- a/Source/Scene/GlobeSurfaceShaderSet.js +++ b/Source/Scene/GlobeSurfaceShaderSet.js @@ -15,8 +15,8 @@ define([ function GlobeSurfaceShader(numberOfDayTextures, flags, material, shaderProgram) { this.numberOfDayTextures = numberOfDayTextures; this.flags = flags; - this.shaderProgram = shaderProgram; this.material = material; + this.shaderProgram = shaderProgram; } /** diff --git a/Source/Scene/GlobeSurfaceTileProvider.js b/Source/Scene/GlobeSurfaceTileProvider.js index da6054fbe634..9af1dc43b76a 100644 --- a/Source/Scene/GlobeSurfaceTileProvider.js +++ b/Source/Scene/GlobeSurfaceTileProvider.js @@ -1265,7 +1265,7 @@ define([ Matrix4.clone(encoding.matrix, uniformMapProperties.scaleAndBias); if (tileProvider.uniformMap) { - uniformMap = combine(uniformMap, tileProvider.uniformMap); + uniformMap = combine(uniformMap, tileProvider.uniformMap); } command.shaderProgram = tileProvider._surfaceShaderSet.getShaderProgram(frameState, surfaceTile, numberOfDayTextures, applyBrightness, applyContrast, applyHue, applySaturation, applyGamma, applyAlpha, applySplit, showReflectiveOcean, showOceanWaves, tileProvider.enableLighting, hasVertexNormals, useWebMercatorProjection, applyFog); diff --git a/Source/Shaders/Materials/ElevationContourMaterial.glsl b/Source/Shaders/Materials/ElevationContourMaterial.glsl index abdf962f288a..d9ee1c27bff6 100644 --- a/Source/Shaders/Materials/ElevationContourMaterial.glsl +++ b/Source/Shaders/Materials/ElevationContourMaterial.glsl @@ -4,13 +4,15 @@ czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); - if (fract(materialInput.height / spacing) < 0.1 ) { - material.diffuse = color.rgb; - material.alpha = color.a; + if (fract(materialInput.height / spacing) < 0.1) + { + material.diffuse = color.rgb; + material.alpha = color.a; } - else { + else + { material.alpha = 0.0; } return material; -} \ No newline at end of file +} diff --git a/Source/Shaders/Materials/ElevationRampMaterial.glsl b/Source/Shaders/Materials/ElevationRampMaterial.glsl index 94db4faf683d..6f3a674401c6 100644 --- a/Source/Shaders/Materials/ElevationRampMaterial.glsl +++ b/Source/Shaders/Materials/ElevationRampMaterial.glsl @@ -10,4 +10,4 @@ czm_material czm_getMaterial(czm_materialInput materialInput) material.diffuse = rampColor.rgb; material.alpha = rampColor.a; return material; -} \ No newline at end of file +} diff --git a/Source/Shaders/Materials/SlopeRampMaterial.glsl b/Source/Shaders/Materials/SlopeRampMaterial.glsl index 0f537273f21e..14e30a9086bb 100644 --- a/Source/Shaders/Materials/SlopeRampMaterial.glsl +++ b/Source/Shaders/Materials/SlopeRampMaterial.glsl @@ -7,4 +7,4 @@ czm_material czm_getMaterial(czm_materialInput materialInput) material.diffuse = rampColor.rgb; material.alpha = rampColor.a; return material; -} \ No newline at end of file +} From cbcaea100e4adb707016212ea863d4d90e230faf Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Mon, 13 Nov 2017 10:29:13 -0500 Subject: [PATCH 09/31] Setting initial time in Globe Materials demo to make lighting look decent on first view of Mt Everest --- Apps/Sandcastle/gallery/Globe Materials.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Apps/Sandcastle/gallery/Globe Materials.html b/Apps/Sandcastle/gallery/Globe Materials.html index 68b860fe57eb..fafae78e2bb1 100644 --- a/Apps/Sandcastle/gallery/Globe Materials.html +++ b/Apps/Sandcastle/gallery/Globe Materials.html @@ -51,6 +51,9 @@ viewer.scene.globe.enableLighting = true; +// Set the clock so the lighting looks good on the initial viewpoint. +viewer.clockViewModel.currentTime = Cesium.JulianDate.fromDate(new Date(2017, 8, 22, 0, 0, 0)); + // The viewModel tracks the state of our mini application. var viewModel = { spacing: 100.0 From cff763d7f634308da76859761ef24430f1b3caa6 Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Mon, 13 Nov 2017 10:30:45 -0500 Subject: [PATCH 10/31] Using defined to check for material in Globe --- Source/Scene/Globe.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Scene/Globe.js b/Source/Scene/Globe.js index 0620db6d063f..c9a407ca23f7 100644 --- a/Source/Scene/Globe.js +++ b/Source/Scene/Globe.js @@ -540,7 +540,7 @@ define([ return; } - if (this._material) { + if (defined(this._material)) { this._material.update(frameState.context); } @@ -579,7 +579,7 @@ define([ var fragmentSources = []; var fragmentDefines = []; - if (this._material) { + if (defined(this._material)) { fragmentSources.push(this._material.shaderSource); fragmentDefines.push('APPLY_MATERIAL'); From 5c619a9a345b9d854cf860c9e78fd703f4fcf264 Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Mon, 13 Nov 2017 10:32:49 -0500 Subject: [PATCH 11/31] Using defined to check for uniformMap --- Source/Scene/GlobeSurfaceTileProvider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Scene/GlobeSurfaceTileProvider.js b/Source/Scene/GlobeSurfaceTileProvider.js index 9af1dc43b76a..83d188d4c5b5 100644 --- a/Source/Scene/GlobeSurfaceTileProvider.js +++ b/Source/Scene/GlobeSurfaceTileProvider.js @@ -1264,7 +1264,7 @@ define([ uniformMapProperties.minMaxHeight.y = encoding.maximumHeight; Matrix4.clone(encoding.matrix, uniformMapProperties.scaleAndBias); - if (tileProvider.uniformMap) { + if (defined(tileProvider.uniformMap)) { uniformMap = combine(uniformMap, tileProvider.uniformMap); } From 7493d7c5657ea4f1a86d554d930ebc83a396c4b9 Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Mon, 13 Nov 2017 11:04:36 -0500 Subject: [PATCH 12/31] Wrapping slope and height and globe shaders with APPLY_MATERIAL ifdef. --- Source/Scene/Globe.js | 14 ++++++++------ Source/Shaders/GlobeFS.glsl | 3 +++ Source/Shaders/GlobeVS.glsl | 5 +++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Source/Scene/Globe.js b/Source/Scene/Globe.js index c9a407ca23f7..3e18bfdbfa73 100644 --- a/Source/Scene/Globe.js +++ b/Source/Scene/Globe.js @@ -573,15 +573,12 @@ define([ * @private */ Globe.prototype.dirtyShaders = function() { - this._surfaceShaderSet.baseVertexShaderSource = new ShaderSource({ - sources : [GroundAtmosphere, GlobeVS] - }); + var defines = []; var fragmentSources = []; - var fragmentDefines = []; if (defined(this._material)) { fragmentSources.push(this._material.shaderSource); - fragmentDefines.push('APPLY_MATERIAL'); + defines.push('APPLY_MATERIAL'); // Set the material uniform map to the materials this._surface._tileProvider.uniformMap = this._material._uniforms; @@ -590,9 +587,14 @@ define([ } fragmentSources.push(GlobeFS); + this._surfaceShaderSet.baseVertexShaderSource = new ShaderSource({ + sources : [GroundAtmosphere, GlobeVS], + defines: defines + }); + this._surfaceShaderSet.baseFragmentShaderSource = new ShaderSource({ sources : fragmentSources, - defines: fragmentDefines + defines: defines }); this._surfaceShaderSet.material = this._material; }; diff --git a/Source/Shaders/GlobeFS.glsl b/Source/Shaders/GlobeFS.glsl index de834ea8ca47..fe4c9c82b6d4 100644 --- a/Source/Shaders/GlobeFS.glsl +++ b/Source/Shaders/GlobeFS.glsl @@ -61,8 +61,11 @@ varying vec3 v_positionEC; varying vec3 v_textureCoordinates; varying vec3 v_normalMC; varying vec3 v_normalEC; + +#ifdef APPLY_MATERIAL varying float v_height; varying float v_slope; +#endif #ifdef FOG varying float v_distance; diff --git a/Source/Shaders/GlobeVS.glsl b/Source/Shaders/GlobeVS.glsl index cfff78756d7f..73fdefc4b781 100644 --- a/Source/Shaders/GlobeVS.glsl +++ b/Source/Shaders/GlobeVS.glsl @@ -21,8 +21,11 @@ varying vec3 v_positionEC; varying vec3 v_textureCoordinates; varying vec3 v_normalMC; varying vec3 v_normalEC; + +#ifdef APPLY_MATERIAL varying float v_slope; varying float v_height; +#endif #ifdef FOG varying float v_distance; @@ -170,8 +173,10 @@ void main() v_distance = length((czm_modelView3D * vec4(position3DWC, 1.0)).xyz); #endif +#ifdef APPLY_MATERIAL vec3 finalNormal = normalize(v_normalMC); vec3 worldNormal = normalize(v_positionMC.xyz); v_slope = abs(dot(worldNormal, finalNormal)); v_height = height; +#endif } From 5e4aab68a79ac2e80b8dbec96a11a8484e0a8690 Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Mon, 13 Nov 2017 11:09:10 -0500 Subject: [PATCH 13/31] Renamed minHeight/maxHeight => minimumHeight/maximumHeight in ElevationRampMaterial --- Source/Scene/Material.js | 8 ++++---- Source/Shaders/Materials/ElevationRampMaterial.glsl | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Scene/Material.js b/Source/Scene/Material.js index 18491460d254..67719c0e5992 100644 --- a/Source/Scene/Material.js +++ b/Source/Scene/Material.js @@ -240,8 +240,8 @@ define([ *
  • ElevationRamp
  • *
      *
    • image: color ramp image to use for coloring the terrain.
    • - *
    • minHeight: minimum height for the ramp.
    • - *
    • maxHeight: maximum height for the ramp.
    • + *
    • minimumHeight: minimum height for the ramp.
    • + *
    • maximumHeight: maximum height for the ramp.
    • *
    *
  • SlopeRamp
  • *
      @@ -1521,8 +1521,8 @@ define([ type : Material.ElevationRampType, uniforms : { image: Material.DefaultImageId, - minHeight: 0.0, - maxHeight: 10000.0, + minimumHeight: 0.0, + maximumHeight: 10000.0 }, source : ElevationRampMaterial }, diff --git a/Source/Shaders/Materials/ElevationRampMaterial.glsl b/Source/Shaders/Materials/ElevationRampMaterial.glsl index 6f3a674401c6..36c017422175 100644 --- a/Source/Shaders/Materials/ElevationRampMaterial.glsl +++ b/Source/Shaders/Materials/ElevationRampMaterial.glsl @@ -1,11 +1,11 @@ uniform sampler2D image; -uniform float minHeight; -uniform float maxHeight; +uniform float minimumHeight; +uniform float maximumHeight; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); - float scaledHeight = clamp((materialInput.height - minHeight) / (maxHeight - minHeight), 0.0, 1.0); + float scaledHeight = clamp((materialInput.height - minimumHeight) / (maximumHeight - minimumHeight), 0.0, 1.0); vec4 rampColor = texture2D(image, vec2(scaledHeight, 0.5)); material.diffuse = rampColor.rgb; material.alpha = rampColor.a; From c045a6cae5cb3f5b2b92d16a0b48ae53c8ff4406 Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Mon, 13 Nov 2017 14:40:49 -0500 Subject: [PATCH 14/31] Added lineThickness uniform to ElevationContourMaterial Added implementation of screen space partial derivatives for contour lines to make them look nicer. Source/Shaders/Materials/ElevationContourMaterial.glsl --- Source/Scene/Material.js | 4 ++- .../Materials/ElevationContourMaterial.glsl | 27 ++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Source/Scene/Material.js b/Source/Scene/Material.js index 67719c0e5992..7e2e3ed21a7e 100644 --- a/Source/Scene/Material.js +++ b/Source/Scene/Material.js @@ -236,6 +236,7 @@ define([ *
        *
      • color: color and alpha for the contour line.
      • *
      • spacing: spacing for contour lines in meters.
      • + *
      • lineThickness: Number specifying the thickness of the grid lines in pixels.
      • *
      *
    • ElevationRamp
    • *
        @@ -1503,7 +1504,8 @@ define([ type : Material.ElevationContourType, uniforms : { spacing: 100.0, - color: new Color(1.0, 0.0, 0.0, 1.0) + color: new Color(1.0, 0.0, 0.0, 1.0), + lineThickness: 1.0 }, source : ElevationContourMaterial }, diff --git a/Source/Shaders/Materials/ElevationContourMaterial.glsl b/Source/Shaders/Materials/ElevationContourMaterial.glsl index d9ee1c27bff6..f37e37dba820 100644 --- a/Source/Shaders/Materials/ElevationContourMaterial.glsl +++ b/Source/Shaders/Materials/ElevationContourMaterial.glsl @@ -1,18 +1,27 @@ +#ifdef GL_OES_standard_derivatives + #extension GL_OES_standard_derivatives : enable +#endif + uniform vec4 color; +uniform float spacing; +uniform float lineThickness; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); - if (fract(materialInput.height / spacing) < 0.1) - { - material.diffuse = color.rgb; - material.alpha = color.a; - } - else - { - material.alpha = 0.0; - } + float distanceToContour = mod(materialInput.height, spacing); + +#ifdef GL_OES_standard_derivatives + float dxc = abs(dFdx(materialInput.height)); + float dyc = abs(dFdy(materialInput.height)); + float dF = max(dxc, dyc) * lineThickness; + material.alpha = (distanceToContour < dF) ? 1.0 : 0.0; +#else + material.alpha = (distanceToContour < (czm_resolutionScale * lineThickness)) ? 1.0 : 0.0; +#endif + + material.diffuse = color.rgb; return material; } From 8f4a8a1e0266db2b505e6697ebd89394678041e7 Mon Sep 17 00:00:00 2001 From: hpinkos Date: Fri, 17 Nov 2017 15:04:22 -0500 Subject: [PATCH 15/31] fancy sandcastle demo --- Apps/Sandcastle/gallery/Globe Materials.html | 321 ++++++++++++------- Apps/Sandcastle/gallery/Globe Materials.jpg | Bin 20762 -> 25677 bytes 2 files changed, 198 insertions(+), 123 deletions(-) diff --git a/Apps/Sandcastle/gallery/Globe Materials.html b/Apps/Sandcastle/gallery/Globe Materials.html index fafae78e2bb1..5e8b74782525 100644 --- a/Apps/Sandcastle/gallery/Globe Materials.html +++ b/Apps/Sandcastle/gallery/Globe Materials.html @@ -10,73 +10,150 @@

        Loading...

        -
        -
        -
        -
        - - - - - - -
        Contour Spacing - -
        +
        +
        + + + +
        +
        +
        + +
        +
        + Spacing m +
        +
        + Line Width px +
        +
        + +
        +