From 40a1c045fa7368f9bad4fe8c27baedf4ae4be757 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 31 Jul 2017 08:17:03 -0700 Subject: [PATCH] Small fixes throughout --- Source/Renderer/AutomaticUniforms.js | 10 +- Source/Renderer/UniformState.js | 8 +- Source/Scene/BrdfLutGenerator.js | 1 - Source/Scene/ClassificationPrimitive.js | 1 - Source/Scene/FrameState.js | 2 +- Source/Scene/Model.js | 315 +++++++++--------- Source/Scene/ModelAnimationCache.js | 1 - Source/Scene/Scene.js | 6 +- Source/Scene/TimeDynamicImagery.js | 1 - Source/ThirdParty/GltfPipeline/ForEach.js | 1 - Source/ThirdParty/GltfPipeline/addDefaults.js | 1 - .../GltfPipeline/addExtensionsRequired.js | 1 - .../GltfPipeline/addExtensionsUsed.js | 1 - .../GltfPipeline/addPipelineExtras.js | 1 - Source/ThirdParty/GltfPipeline/addToArray.js | 1 - .../byteLengthForComponentType.js | 1 - .../GltfPipeline/findAccessorMinMax.js | 1 - .../GltfPipeline/getAccessorByteStride.js | 1 - .../GltfPipeline/getJointCountForMaterials.js | 1 - Source/ThirdParty/GltfPipeline/getUniqueId.js | 1 - .../GltfPipeline/glslTypeToWebGLConstant.js | 1 - .../GltfPipeline/numberOfComponentsForType.js | 1 - .../GltfPipeline/parseBinaryGltf.js | 3 +- .../GltfPipeline/pbrToMaterialsCommon.js | 125 ------- .../processModelMaterialsCommon.js | 1 - .../processPbrMetallicRoughness.js | 5 +- .../GltfPipeline/removeExtensionsRequired.js | 1 - .../GltfPipeline/removeExtensionsUsed.js | 1 - .../GltfPipeline/removePipelineExtras.js | 1 - .../techniqueParameterForSemantic.js | 1 - .../ThirdParty/GltfPipeline/updateVersion.js | 1 - .../GltfPipeline/webGLConstantToGlslType.js | 1 - 32 files changed, 173 insertions(+), 325 deletions(-) delete mode 100644 Source/ThirdParty/GltfPipeline/pbrToMaterialsCommon.js diff --git a/Source/Renderer/AutomaticUniforms.js b/Source/Renderer/AutomaticUniforms.js index faa077b38888..89dafdc31d3e 100644 --- a/Source/Renderer/AutomaticUniforms.js +++ b/Source/Renderer/AutomaticUniforms.js @@ -1439,23 +1439,23 @@ define([ /** * An automatic GLSL uniform containing the BRDF look up texture used for image-based lighting computations. * - * @alias czm_brdfLUT + * @alias czm_brdfLut * @glslUniform * * @example * // GLSL declaration - * uniform sampler2D czm_brdfLUT; + * uniform sampler2D czm_brdfLut; * * // Example: For a given roughness and NdotV value, find the material's BRDF information in the red and green channels * float roughness = 0.5; * float NdotV = dot(normal, view); - * vec2 brdfLUT = texture2D(czm_brdfLUT, vec2(NdotV, 1.0 - roughness)).rg; + * vec2 brdfLut = texture2D(czm_brdfLut, vec2(NdotV, 1.0 - roughness)).rg; */ - czm_brdfLUT : new AutomaticUniform({ + czm_brdfLut : new AutomaticUniform({ size : 1, datatype : WebGLConstants.SAMPLER_2D, getValue : function(uniformState) { - return uniformState.brdfLUT; + return uniformState.brdfLut; } }), diff --git a/Source/Renderer/UniformState.js b/Source/Renderer/UniformState.js index 1642419fd36e..803e76c0afb9 100644 --- a/Source/Renderer/UniformState.js +++ b/Source/Renderer/UniformState.js @@ -152,7 +152,7 @@ define([ this._orthographicIn3D = false; this._backgroundColor = new Color(); - this._brdfLUT = new Sampler(); + this._brdfLut = new Sampler(); this._environmentMap = new Sampler(); this._fogDensity = undefined; @@ -806,9 +806,9 @@ define([ * @memberof UniformState.prototype * @type {Sampler} */ - brdfLUT : { + brdfLut : { get : function() { - return this._brdfLUT; + return this._brdfLut; } }, @@ -1002,7 +1002,7 @@ define([ setSunAndMoonDirections(this, frameState); - this._brdfLUT = frameState.brdfLUT.colorTexture; + this._brdfLut = frameState.brdfLutGenerator.colorTexture; this._environmentMap = frameState.environmentMap; diff --git a/Source/Scene/BrdfLutGenerator.js b/Source/Scene/BrdfLutGenerator.js index b65a2241d536..04ca2f7eb001 100644 --- a/Source/Scene/BrdfLutGenerator.js +++ b/Source/Scene/BrdfLutGenerator.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../Core/BoundingRectangle', '../Core/Color', diff --git a/Source/Scene/ClassificationPrimitive.js b/Source/Scene/ClassificationPrimitive.js index 86440fcecf86..ae0d0ef2f7fb 100644 --- a/Source/Scene/ClassificationPrimitive.js +++ b/Source/Scene/ClassificationPrimitive.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../Core/ColorGeometryInstanceAttribute', '../Core/defaultValue', diff --git a/Source/Scene/FrameState.js b/Source/Scene/FrameState.js index 71d2d45e9fef..89e9d1343059 100644 --- a/Source/Scene/FrameState.js +++ b/Source/Scene/FrameState.js @@ -42,7 +42,7 @@ define([ * The BRDF look up texture generator used for image-based lighting for PBR models * @type {BrdfLutGenerator} */ - this.brdfLUT = undefined; + this.brdfLutGenerator = undefined; /** * The environment map used for image-based lighting for PBR models diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index c10cda6773e1..9c133ba2dd87 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -1,155 +1,155 @@ define([ - '../Core/BoundingSphere', - '../Core/Cartesian2', - '../Core/Cartesian3', - '../Core/Cartesian4', - '../Core/Cartographic', - '../Core/clone', - '../Core/Color', - '../Core/combine', - '../Core/defaultValue', - '../Core/defined', - '../Core/defineProperties', - '../Core/destroyObject', - '../Core/DeveloperError', - '../Core/DistanceDisplayCondition', - '../Core/FeatureDetection', - '../Core/getAbsoluteUri', - '../Core/getBaseUri', - '../Core/getMagic', - '../Core/getStringFromTypedArray', - '../Core/IndexDatatype', - '../Core/joinUrls', - '../Core/loadArrayBuffer', - '../Core/loadCRN', - '../Core/loadImage', - '../Core/loadImageFromTypedArray', - '../Core/loadKTX', - '../Core/loadText', - '../Core/Math', - '../Core/Matrix2', - '../Core/Matrix3', - '../Core/Matrix4', - '../Core/PixelFormat', - '../Core/PrimitiveType', - '../Core/Quaternion', - '../Core/Queue', - '../Core/RuntimeError', - '../Core/Transforms', - '../Core/WebGLConstants', - '../Renderer/Buffer', - '../Renderer/BufferUsage', - '../Renderer/DrawCommand', - '../Renderer/Pass', - '../Renderer/RenderState', - '../Renderer/Sampler', - '../Renderer/ShaderProgram', - '../Renderer/ShaderSource', - '../Renderer/Texture', - '../Renderer/TextureMinificationFilter', - '../Renderer/TextureWrap', - '../Renderer/VertexArray', - '../ThirdParty/GltfPipeline/addDefaults', - '../ThirdParty/GltfPipeline/addPipelineExtras', - '../ThirdParty/GltfPipeline/ForEach', - '../ThirdParty/GltfPipeline/numberOfComponentsForType', - '../ThirdParty/GltfPipeline/parseBinaryGltf', - '../ThirdParty/GltfPipeline/processModelMaterialsCommon', - '../ThirdParty/GltfPipeline/processPbrMetallicRoughness', - '../ThirdParty/GltfPipeline/removePipelineExtras', - '../ThirdParty/GltfPipeline/updateVersion', - '../ThirdParty/Uri', - '../ThirdParty/when', - './AttributeType', - './Axis', - './BlendingState', - './ColorBlendMode', - './getAttributeOrUniformBySemantic', - './HeightReference', - './JobType', - './ModelAnimationCache', - './ModelAnimationCollection', - './ModelMaterial', - './ModelMesh', - './ModelNode', - './SceneMode', - './ShadowMode' -], function( - BoundingSphere, - Cartesian2, - Cartesian3, - Cartesian4, - Cartographic, - clone, - Color, - combine, - defaultValue, - defined, - defineProperties, - destroyObject, - DeveloperError, - DistanceDisplayCondition, - FeatureDetection, - getAbsoluteUri, - getBaseUri, - getMagic, - getStringFromTypedArray, - IndexDatatype, - joinUrls, - loadArrayBuffer, - loadCRN, - loadImage, - loadImageFromTypedArray, - loadKTX, - loadText, - CesiumMath, - Matrix2, - Matrix3, - Matrix4, - PixelFormat, - PrimitiveType, - Quaternion, - Queue, - RuntimeError, - Transforms, - WebGLConstants, - Buffer, - BufferUsage, - DrawCommand, - Pass, - RenderState, - Sampler, - ShaderProgram, - ShaderSource, - Texture, - TextureMinificationFilter, - TextureWrap, - VertexArray, - addDefaults, - addPipelineExtras, - ForEach, - numberOfComponentsForType, - parseBinaryGltf, - processModelMaterialsCommon, - processPbrMetallicRoughness, - removePipelineExtras, - updateVersion, - Uri, - when, - AttributeType, - Axis, - BlendingState, - ColorBlendMode, - getAttributeOrUniformBySemantic, - HeightReference, - JobType, - ModelAnimationCache, - ModelAnimationCollection, - ModelMaterial, - ModelMesh, - ModelNode, - SceneMode, - ShadowMode) { + '../Core/BoundingSphere', + '../Core/Cartesian2', + '../Core/Cartesian3', + '../Core/Cartesian4', + '../Core/Cartographic', + '../Core/clone', + '../Core/Color', + '../Core/combine', + '../Core/defaultValue', + '../Core/defined', + '../Core/defineProperties', + '../Core/destroyObject', + '../Core/DeveloperError', + '../Core/DistanceDisplayCondition', + '../Core/FeatureDetection', + '../Core/getAbsoluteUri', + '../Core/getBaseUri', + '../Core/getMagic', + '../Core/getStringFromTypedArray', + '../Core/IndexDatatype', + '../Core/joinUrls', + '../Core/loadArrayBuffer', + '../Core/loadCRN', + '../Core/loadImage', + '../Core/loadImageFromTypedArray', + '../Core/loadKTX', + '../Core/loadText', + '../Core/Math', + '../Core/Matrix2', + '../Core/Matrix3', + '../Core/Matrix4', + '../Core/PixelFormat', + '../Core/PrimitiveType', + '../Core/Quaternion', + '../Core/Queue', + '../Core/RuntimeError', + '../Core/Transforms', + '../Core/WebGLConstants', + '../Renderer/Buffer', + '../Renderer/BufferUsage', + '../Renderer/DrawCommand', + '../Renderer/Pass', + '../Renderer/RenderState', + '../Renderer/Sampler', + '../Renderer/ShaderProgram', + '../Renderer/ShaderSource', + '../Renderer/Texture', + '../Renderer/TextureMinificationFilter', + '../Renderer/TextureWrap', + '../Renderer/VertexArray', + '../ThirdParty/GltfPipeline/addDefaults', + '../ThirdParty/GltfPipeline/addPipelineExtras', + '../ThirdParty/GltfPipeline/ForEach', + '../ThirdParty/GltfPipeline/numberOfComponentsForType', + '../ThirdParty/GltfPipeline/parseBinaryGltf', + '../ThirdParty/GltfPipeline/processModelMaterialsCommon', + '../ThirdParty/GltfPipeline/processPbrMetallicRoughness', + '../ThirdParty/GltfPipeline/removePipelineExtras', + '../ThirdParty/GltfPipeline/updateVersion', + '../ThirdParty/Uri', + '../ThirdParty/when', + './AttributeType', + './Axis', + './BlendingState', + './ColorBlendMode', + './getAttributeOrUniformBySemantic', + './HeightReference', + './JobType', + './ModelAnimationCache', + './ModelAnimationCollection', + './ModelMaterial', + './ModelMesh', + './ModelNode', + './SceneMode', + './ShadowMode' + ], function( + BoundingSphere, + Cartesian2, + Cartesian3, + Cartesian4, + Cartographic, + clone, + Color, + combine, + defaultValue, + defined, + defineProperties, + destroyObject, + DeveloperError, + DistanceDisplayCondition, + FeatureDetection, + getAbsoluteUri, + getBaseUri, + getMagic, + getStringFromTypedArray, + IndexDatatype, + joinUrls, + loadArrayBuffer, + loadCRN, + loadImage, + loadImageFromTypedArray, + loadKTX, + loadText, + CesiumMath, + Matrix2, + Matrix3, + Matrix4, + PixelFormat, + PrimitiveType, + Quaternion, + Queue, + RuntimeError, + Transforms, + WebGLConstants, + Buffer, + BufferUsage, + DrawCommand, + Pass, + RenderState, + Sampler, + ShaderProgram, + ShaderSource, + Texture, + TextureMinificationFilter, + TextureWrap, + VertexArray, + addDefaults, + addPipelineExtras, + ForEach, + numberOfComponentsForType, + parseBinaryGltf, + processModelMaterialsCommon, + processPbrMetallicRoughness, + removePipelineExtras, + updateVersion, + Uri, + when, + AttributeType, + Axis, + BlendingState, + ColorBlendMode, + getAttributeOrUniformBySemantic, + HeightReference, + JobType, + ModelAnimationCache, + ModelAnimationCollection, + ModelMaterial, + ModelMesh, + ModelNode, + SceneMode, + ShadowMode) { 'use strict'; // Bail out if the browser doesn't support typed arrays, to prevent the setup function @@ -198,7 +198,6 @@ define([ } LoadResources.prototype.getBuffer = function(bufferView) { - bufferView.byteOffset = defaultValue(bufferView.byteOffset, 0); return getSubarray(this.buffers[bufferView.buffer], bufferView.byteOffset, bufferView.byteLength); }; @@ -4535,8 +4534,8 @@ define([ optimizeForCesium: true, addBatchIdToGeneratedShaders : this._addBatchIdToGeneratedShaders }; + frameState.brdfLutGenerator.update(frameState); updateVersion(this.gltf); - frameState.brdfLUT.update(frameState); checkSupportedExtensions(this); addPipelineExtras(this.gltf); addDefaults(this.gltf); @@ -4625,11 +4624,11 @@ define([ // Model's model matrix needs to be updated var modelTransformChanged = !Matrix4.equals(this._modelMatrix, modelMatrix) || - (this._scale !== this.scale) || - (this._minimumPixelSize !== this.minimumPixelSize) || (this.minimumPixelSize !== 0.0) || // Minimum pixel size changed or is enabled - (this._maximumScale !== this.maximumScale) || - (this._heightReference !== this.heightReference) || this._heightChanged || - modeChanged; + (this._scale !== this.scale) || + (this._minimumPixelSize !== this.minimumPixelSize) || (this.minimumPixelSize !== 0.0) || // Minimum pixel size changed or is enabled + (this._maximumScale !== this.maximumScale) || + (this._heightReference !== this.heightReference) || this._heightChanged || + modeChanged; if (modelTransformChanged || justLoaded) { Matrix4.clone(modelMatrix, this._modelMatrix); diff --git a/Source/Scene/ModelAnimationCache.js b/Source/Scene/ModelAnimationCache.js index 315922e33499..edcee52f8bfa 100644 --- a/Source/Scene/ModelAnimationCache.js +++ b/Source/Scene/ModelAnimationCache.js @@ -144,7 +144,6 @@ define([ } // GLTF_SPEC: Support more parameter types when glTF supports targeting materials. https://github.com/KhronosGroup/glTF/issues/142 } - // GLTF_SPEC: Support new interpolators. https://github.com/KhronosGroup/glTF/issues/156 if (defined(model.cacheKey)) { // Only cache when we can create a unique id diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 55a8cf6a0fa6..12ce46b1d4c0 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -631,7 +631,7 @@ define([ enabled : defaultValue(options.shadows, false) }); - this._brdfLUT = new BrdfLutGenerator(); + this._brdfLutGenerator = new BrdfLutGenerator(); this._environmentMap = context.defaultCubeMap; var that = this; @@ -1305,7 +1305,7 @@ define([ var frameState = scene._frameState; frameState.commandList.length = 0; frameState.shadowMaps.length = 0; - frameState.brdfLUT = scene._brdfLUT; + frameState.brdfLutGenerator = scene._brdfLutGenerator; frameState.environmentMap = scene._environmentMap; frameState.mode = scene._mode; frameState.morphTime = scene.morphTime; @@ -3355,7 +3355,7 @@ define([ this._depthPlane = this._depthPlane && this._depthPlane.destroy(); this._transitioner.destroy(); this._debugFrustumPlanes = this._debugFrustumPlanes && this._debugFrustumPlanes.destroy(); - this._brdfLUT = this._brdfLUT && this._brdfLUT.destroy(); + this._brdfLutGenerator = this._brdfLutGenerator && this._brdfLutGenerator.destroy(); this._environmentMap = this._environmentMap && this._environmentMap.destroy(); if (defined(this._globeDepth)) { diff --git a/Source/Scene/TimeDynamicImagery.js b/Source/Scene/TimeDynamicImagery.js index 8d2de9a10be4..f51f38657fc0 100644 --- a/Source/Scene/TimeDynamicImagery.js +++ b/Source/Scene/TimeDynamicImagery.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../Core/Check', '../Core/defaultValue', diff --git a/Source/ThirdParty/GltfPipeline/ForEach.js b/Source/ThirdParty/GltfPipeline/ForEach.js index 429d4bd618b5..814af92e5e7b 100644 --- a/Source/ThirdParty/GltfPipeline/ForEach.js +++ b/Source/ThirdParty/GltfPipeline/ForEach.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../../Core/defined' ], function( diff --git a/Source/ThirdParty/GltfPipeline/addDefaults.js b/Source/ThirdParty/GltfPipeline/addDefaults.js index c58701b24981..edb4f5d80ef9 100644 --- a/Source/ThirdParty/GltfPipeline/addDefaults.js +++ b/Source/ThirdParty/GltfPipeline/addDefaults.js @@ -1,4 +1,3 @@ -/*global define*/ define([ './addToArray', './ForEach', diff --git a/Source/ThirdParty/GltfPipeline/addExtensionsRequired.js b/Source/ThirdParty/GltfPipeline/addExtensionsRequired.js index 3f4222221418..49ec2de50fa6 100644 --- a/Source/ThirdParty/GltfPipeline/addExtensionsRequired.js +++ b/Source/ThirdParty/GltfPipeline/addExtensionsRequired.js @@ -1,4 +1,3 @@ -/*global define*/ define([ './addExtensionsUsed', '../../Core/defined' diff --git a/Source/ThirdParty/GltfPipeline/addExtensionsUsed.js b/Source/ThirdParty/GltfPipeline/addExtensionsUsed.js index 871cf5409c4b..6d8bed56db03 100644 --- a/Source/ThirdParty/GltfPipeline/addExtensionsUsed.js +++ b/Source/ThirdParty/GltfPipeline/addExtensionsUsed.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../../Core/defined' ], function( diff --git a/Source/ThirdParty/GltfPipeline/addPipelineExtras.js b/Source/ThirdParty/GltfPipeline/addPipelineExtras.js index 3bd94b399a98..26770de6b816 100644 --- a/Source/ThirdParty/GltfPipeline/addPipelineExtras.js +++ b/Source/ThirdParty/GltfPipeline/addPipelineExtras.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../../Core/defaultValue', '../../Core/defined' diff --git a/Source/ThirdParty/GltfPipeline/addToArray.js b/Source/ThirdParty/GltfPipeline/addToArray.js index 4242b4d89a3c..8559cb54288b 100644 --- a/Source/ThirdParty/GltfPipeline/addToArray.js +++ b/Source/ThirdParty/GltfPipeline/addToArray.js @@ -1,4 +1,3 @@ -/*global define*/ define([], function() { 'use strict'; diff --git a/Source/ThirdParty/GltfPipeline/byteLengthForComponentType.js b/Source/ThirdParty/GltfPipeline/byteLengthForComponentType.js index 7a339301134b..409bc740ad48 100644 --- a/Source/ThirdParty/GltfPipeline/byteLengthForComponentType.js +++ b/Source/ThirdParty/GltfPipeline/byteLengthForComponentType.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../../Core/WebGLConstants' ], function( diff --git a/Source/ThirdParty/GltfPipeline/findAccessorMinMax.js b/Source/ThirdParty/GltfPipeline/findAccessorMinMax.js index fd0253490e3c..3ebf53b24eb1 100644 --- a/Source/ThirdParty/GltfPipeline/findAccessorMinMax.js +++ b/Source/ThirdParty/GltfPipeline/findAccessorMinMax.js @@ -1,4 +1,3 @@ -/*global define*/ define([ './getAccessorByteStride', './numberOfComponentsForType', diff --git a/Source/ThirdParty/GltfPipeline/getAccessorByteStride.js b/Source/ThirdParty/GltfPipeline/getAccessorByteStride.js index 861b46cb8eeb..c9dbfe0f9fb4 100644 --- a/Source/ThirdParty/GltfPipeline/getAccessorByteStride.js +++ b/Source/ThirdParty/GltfPipeline/getAccessorByteStride.js @@ -1,4 +1,3 @@ -/*global define*/ define([ './byteLengthForComponentType', './numberOfComponentsForType', diff --git a/Source/ThirdParty/GltfPipeline/getJointCountForMaterials.js b/Source/ThirdParty/GltfPipeline/getJointCountForMaterials.js index 8f7b83f593a1..ba299be639e7 100644 --- a/Source/ThirdParty/GltfPipeline/getJointCountForMaterials.js +++ b/Source/ThirdParty/GltfPipeline/getJointCountForMaterials.js @@ -1,4 +1,3 @@ -/*global define*/ define([ './ForEach', '../../Core/defined' diff --git a/Source/ThirdParty/GltfPipeline/getUniqueId.js b/Source/ThirdParty/GltfPipeline/getUniqueId.js index 6bf084fbcb4d..59f7a36cdf5b 100644 --- a/Source/ThirdParty/GltfPipeline/getUniqueId.js +++ b/Source/ThirdParty/GltfPipeline/getUniqueId.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../../Core/defined' ], function( diff --git a/Source/ThirdParty/GltfPipeline/glslTypeToWebGLConstant.js b/Source/ThirdParty/GltfPipeline/glslTypeToWebGLConstant.js index 0c86844cbe22..f05c65a0c871 100644 --- a/Source/ThirdParty/GltfPipeline/glslTypeToWebGLConstant.js +++ b/Source/ThirdParty/GltfPipeline/glslTypeToWebGLConstant.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../../Core/WebGLConstants' ], function( diff --git a/Source/ThirdParty/GltfPipeline/numberOfComponentsForType.js b/Source/ThirdParty/GltfPipeline/numberOfComponentsForType.js index 2137ea0bddba..f87c62123c3b 100644 --- a/Source/ThirdParty/GltfPipeline/numberOfComponentsForType.js +++ b/Source/ThirdParty/GltfPipeline/numberOfComponentsForType.js @@ -1,4 +1,3 @@ -/*global define*/ define([], function() { 'use strict'; diff --git a/Source/ThirdParty/GltfPipeline/parseBinaryGltf.js b/Source/ThirdParty/GltfPipeline/parseBinaryGltf.js index 8a585a1b5519..aaa9f4459ede 100644 --- a/Source/ThirdParty/GltfPipeline/parseBinaryGltf.js +++ b/Source/ThirdParty/GltfPipeline/parseBinaryGltf.js @@ -1,5 +1,4 @@ -/*global define*/ -define([ +Fdefine([ './addPipelineExtras', './removeExtensionsUsed', './updateVersion', diff --git a/Source/ThirdParty/GltfPipeline/pbrToMaterialsCommon.js b/Source/ThirdParty/GltfPipeline/pbrToMaterialsCommon.js deleted file mode 100644 index bfd4543e7b79..000000000000 --- a/Source/ThirdParty/GltfPipeline/pbrToMaterialsCommon.js +++ /dev/null @@ -1,125 +0,0 @@ -/*global define*/ -define([ - './addExtensionsRequired', - './ForEach', - './getJointCountForMaterials', - './removeExtensionsUsed', - '../../Core/defined' - ], function( - addExtensionsRequired, - ForEach, - getJointCountForMaterials, - removeExtensionsUsed, - defined) { - 'use strict'; - - /** - * Convert PBR materials to use a KHR_materials_common BLINN shader. - * This is a lossy conversion, and as such should only be used for - * compatibility reasons. Normal texture and metallic roughness information - * will be lost, and some color or texture information may be lost. - * - * @param {Object} gltf A javascript object containing a glTF asset. - * @returns {Object} The glTF asset with materials converted to KHR_materials_common - */ - function pbrToMaterialsCommon(gltf) { - var materialJointCount = getJointCountForMaterials(gltf); - ForEach.material(gltf, function(material, materialId) { - var values = { - ambient : [ 0.0, 0.0, 0.0, 1.0 ], - diffuse : [ 0.0, 0.0, 0.0, 1.0 ], - emission : [ 0.0, 0.0, 0.0, 1.0 ], - specular : [ 0.0, 0.0, 0.0, 1.0], - shininess : [ 0.0 ] - }; - var pbrMetallicRoughness = material.pbrMetallicRoughness; - var isPBR = defined(pbrMetallicRoughness) || - (defined(material.extensions) && defined(material.extensions.KHR_materials_pbrSpecularGlossiness) || - defined(material.occlusionTexture) || - defined(material.emissiveFactor) || - defined(material.emissiveTexture) || - defined(material.doubleSided)); - - if (defined(pbrMetallicRoughness)) { - var baseColorFactor = pbrMetallicRoughness.baseColorFactor; - if (defined(baseColorFactor)) { - values.diffuse = baseColorFactor; - } - var baseColorTexture = pbrMetallicRoughness.baseColorTexture; - if (defined(baseColorTexture)) { - values.diffuse = [baseColorTexture.index]; - } - } - var extensions = material.extensions; - if (defined(extensions)) { - var pbrSpecularGlossiness = extensions.KHR_materials_pbrSpecularGlossiness; - if (defined(pbrSpecularGlossiness)) { - var diffuseFactor = pbrSpecularGlossiness.diffuseFactor; - // Use baseColorTexture if it was defined - if (defined(diffuseFactor) && values.diffuse.length > 1) { - values.diffuse = diffuseFactor; - } - // diffuseTexture should be used instead of baseColorTexture if defined - var diffuseTexture = pbrSpecularGlossiness.diffuseTexture; - if (defined(diffuseTexture)) { - values.diffuse = [diffuseTexture.index]; - } - var specularFactor = pbrSpecularGlossiness.specularFactor; - if (defined(specularFactor)) { - values.specular[0] = specularFactor[0]; - values.specular[1] = specularFactor[1]; - values.specular[2] = specularFactor[2]; - } - var glossinessFactor = pbrSpecularGlossiness.glossinessFactor; - if (defined(glossinessFactor)) { - values.shininess[0] = glossinessFactor; - } - var specularGlossinessTexture = pbrSpecularGlossiness.specularGlossinessTexture; - if (defined(specularGlossinessTexture)) { - values.specular = [specularGlossinessTexture.index]; - } - } - } - var occlusionTexture = material.occlusionTexture; - if (defined(occlusionTexture)) { - values.ambient = [occlusionTexture.index]; - } - var emissiveFactor = material.emissiveFactor; - if (defined(emissiveFactor)) { - values.emission[0] = emissiveFactor[0]; - values.emission[1] = emissiveFactor[1]; - values.emission[2] = emissiveFactor[2]; - } - var emissiveTexture = material.emissiveTexture; - if (defined(emissiveTexture)) { - values.emission = [emissiveTexture.index]; - } - var doubleSided = material.doubleSided; - if (isPBR) { - delete material.doubleSided; - delete material.emissiveFactor; - delete material.emissiveTexture; - delete material.normalTexture; - delete material.occlusionTexture; - delete material.pbrMetallicRoughness; - var materialsCommon = { - technique: 'BLINN', - values: values - }; - var jointCount = materialJointCount[materialId]; - if (defined(jointCount)) { - materialsCommon.jointCount = jointCount; - } - if (defined(doubleSided)) { - materialsCommon.doubleSided = doubleSided; - } - material.extensions = { - KHR_materials_common: materialsCommon - }; - addExtensionsRequired(gltf, 'KHR_materials_common'); - removeExtensionsUsed(gltf, 'KHR_materials_pbrSpecularGlossiness'); - } - }); - } - return pbrToMaterialsCommon; -}); diff --git a/Source/ThirdParty/GltfPipeline/processModelMaterialsCommon.js b/Source/ThirdParty/GltfPipeline/processModelMaterialsCommon.js index 7c71240c1afb..077430b9a32c 100644 --- a/Source/ThirdParty/GltfPipeline/processModelMaterialsCommon.js +++ b/Source/ThirdParty/GltfPipeline/processModelMaterialsCommon.js @@ -1,4 +1,3 @@ -/*global define*/ define([ './addToArray', './ForEach', diff --git a/Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js b/Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js index 01beebfa1ee5..2f772bef85ea 100644 --- a/Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js +++ b/Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js @@ -1,4 +1,3 @@ -/*global define*/ define([ './addToArray', './ForEach', @@ -559,8 +558,8 @@ define([ fragmentShader += ' specularIrradiance = mix(specularIrradiance, belowHorizonColor, smoothstep(aroundHorizon, farBelowHorizon, reflectionDotNadir) * inverseRoughness);\n'; fragmentShader += ' specularIrradiance = mix(specularIrradiance, nadirColor, smoothstep(farBelowHorizon, 1.0, reflectionDotNadir) * inverseRoughness);\n'; - fragmentShader += ' vec2 brdfLUT = texture2D(czm_brdfLUT, vec2(NdotV, 1.0 - roughness)).rg;\n'; - fragmentShader += ' vec3 IBLColor = (diffuseIrradiance * diffuseColor) + (specularIrradiance * (specularColor * brdfLUT.x + brdfLUT.y));\n'; + fragmentShader += ' vec2 brdfLut = texture2D(czm_brdfLut, vec2(NdotV, 1.0 - roughness)).rg;\n'; + fragmentShader += ' vec3 IBLColor = (diffuseIrradiance * diffuseColor) + (specularIrradiance * (specularColor * brdfLut.x + brdfLut.y));\n'; fragmentShader += ' color = color * lightScale + IBLColor;\n'; } diff --git a/Source/ThirdParty/GltfPipeline/removeExtensionsRequired.js b/Source/ThirdParty/GltfPipeline/removeExtensionsRequired.js index fce00276dc29..54d8002887bb 100644 --- a/Source/ThirdParty/GltfPipeline/removeExtensionsRequired.js +++ b/Source/ThirdParty/GltfPipeline/removeExtensionsRequired.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../../Core/defined' ], function( diff --git a/Source/ThirdParty/GltfPipeline/removeExtensionsUsed.js b/Source/ThirdParty/GltfPipeline/removeExtensionsUsed.js index 115bc780cd13..f3fc28de7bca 100644 --- a/Source/ThirdParty/GltfPipeline/removeExtensionsUsed.js +++ b/Source/ThirdParty/GltfPipeline/removeExtensionsUsed.js @@ -1,4 +1,3 @@ -/*global define*/ define([ './removeExtensionsRequired', '../../Core/defined' diff --git a/Source/ThirdParty/GltfPipeline/removePipelineExtras.js b/Source/ThirdParty/GltfPipeline/removePipelineExtras.js index f1b99a4a1b84..abe075ca8a75 100644 --- a/Source/ThirdParty/GltfPipeline/removePipelineExtras.js +++ b/Source/ThirdParty/GltfPipeline/removePipelineExtras.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../../Core/defined' ], function( diff --git a/Source/ThirdParty/GltfPipeline/techniqueParameterForSemantic.js b/Source/ThirdParty/GltfPipeline/techniqueParameterForSemantic.js index b9c8748d17c2..a0dc6adfe587 100644 --- a/Source/ThirdParty/GltfPipeline/techniqueParameterForSemantic.js +++ b/Source/ThirdParty/GltfPipeline/techniqueParameterForSemantic.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../../Core/defined' ], function( diff --git a/Source/ThirdParty/GltfPipeline/updateVersion.js b/Source/ThirdParty/GltfPipeline/updateVersion.js index 20d7e89ca310..f5e54930aff0 100644 --- a/Source/ThirdParty/GltfPipeline/updateVersion.js +++ b/Source/ThirdParty/GltfPipeline/updateVersion.js @@ -1,4 +1,3 @@ -/*global define*/ define([ './addExtensionsRequired', './addToArray', diff --git a/Source/ThirdParty/GltfPipeline/webGLConstantToGlslType.js b/Source/ThirdParty/GltfPipeline/webGLConstantToGlslType.js index f5f91f9fdd26..1a7a03716250 100644 --- a/Source/ThirdParty/GltfPipeline/webGLConstantToGlslType.js +++ b/Source/ThirdParty/GltfPipeline/webGLConstantToGlslType.js @@ -1,4 +1,3 @@ -/*global define*/ define([ '../../Core/WebGLConstants' ], function(