babylon.backgroundMaterial.min.js 29 KB

1
  1. var __extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])};return function(n,r){function i(){this.constructor=n}e(n,r),n.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}})(),__decorate=this&&this.__decorate||function(e,n,r,i){var o,t=arguments.length,a=t<3?n:null===i?i=Object.getOwnPropertyDescriptor(n,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,n,r,i);else for(var f=e.length-1;f>=0;f--)(o=e[f])&&(a=(t<3?o(a):t>3?o(n,r,a):o(n,r))||a);return t>3&&a&&Object.defineProperty(n,r,a),a},BABYLON;!(function(e){var n=(function(e){function n(){var n=e.call(this)||this;return n.DIFFUSE=!1,n.DIFFUSEDIRECTUV=0,n.GAMMADIFFUSE=!1,n.DIFFUSEHASALPHA=!1,n.OPACITYFRESNEL=!1,n.REFLECTIONBLUR=!1,n.REFLECTIONFRESNEL=!1,n.REFLECTIONFALLOFF=!1,n.TEXTURELODSUPPORT=!1,n.PREMULTIPLYALPHA=!1,n.USERGBCOLOR=!1,n.IMAGEPROCESSING=!1,n.VIGNETTE=!1,n.VIGNETTEBLENDMODEMULTIPLY=!1,n.VIGNETTEBLENDMODEOPAQUE=!1,n.TONEMAPPING=!1,n.CONTRAST=!1,n.COLORCURVES=!1,n.COLORGRADING=!1,n.COLORGRADING3D=!1,n.SAMPLER3DGREENDEPTH=!1,n.SAMPLER3DBGRMAP=!1,n.IMAGEPROCESSINGPOSTPROCESS=!1,n.EXPOSURE=!1,n.REFLECTION=!1,n.REFLECTIONMAP_3D=!1,n.REFLECTIONMAP_SPHERICAL=!1,n.REFLECTIONMAP_PLANAR=!1,n.REFLECTIONMAP_CUBIC=!1,n.REFLECTIONMAP_PROJECTION=!1,n.REFLECTIONMAP_SKYBOX=!1,n.REFLECTIONMAP_EXPLICIT=!1,n.REFLECTIONMAP_EQUIRECTANGULAR=!1,n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,n.INVERTCUBICMAP=!1,n.REFLECTIONMAP_OPPOSITEZ=!1,n.LODINREFLECTIONALPHA=!1,n.GAMMAREFLECTION=!1,n.MAINUV1=!1,n.MAINUV2=!1,n.UV1=!1,n.UV2=!1,n.CLIPPLANE=!1,n.POINTSIZE=!1,n.FOG=!1,n.NORMAL=!1,n.NUM_BONE_INFLUENCERS=0,n.BonesPerMesh=0,n.INSTANCES=!1,n.SHADOWFLOAT=!1,n.rebuild(),n}return __extends(n,e),n})(e.MaterialDefines),r=(function(r){function i(n,i){var o=r.call(this,n,i)||this;return o.primaryColor=e.Color3.White(),o.primaryLevel=1,o.secondaryColor=e.Color3.Gray(),o.secondaryLevel=1,o.tertiaryColor=e.Color3.Black(),o.tertiaryLevel=1,o.reflectionTexture=null,o.reflectionBlur=0,o.diffuseTexture=null,o._shadowLights=null,o.shadowLights=null,o.shadowBlurScale=1,o.shadowLevel=0,o.sceneCenter=e.Vector3.Zero(),o.opacityFresnel=!0,o.reflectionFresnel=!1,o.reflectionFalloffDistance=0,o.reflectionAmount=1,o.reflectionReflectance0=.05,o.reflectionReflectance90=.5,o.useRGBColor=!0,o._maxSimultaneousLights=4,o.maxSimultaneousLights=4,o._imageProcessingObserver=null,o._renderTargets=new e.SmartArray(16),o._reflectionControls=e.Vector4.Zero(),o._attachImageProcessingConfiguration(null),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),o._diffuseTexture&&o._diffuseTexture.isRenderTarget&&o._renderTargets.push(o._diffuseTexture),o._reflectionTexture&&o._reflectionTexture.isRenderTarget&&o._renderTargets.push(o._reflectionTexture),o._renderTargets},o}return __extends(i,r),i.prototype._attachImageProcessingConfiguration=function(e){var n=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){n._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(i.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),i.prototype.needAlphaTesting=function(){return!1},i.prototype.needAlphaBlending=function(){return this.alpha<0||null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha},i.prototype.isReadyForSubMesh=function(r,i,o){var t=this;if(void 0===o&&(o=!1),i.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;i._materialDefines||(i._materialDefines=new n);var a=this.getScene(),f=i._materialDefines;if(!this.checkReadyOnEveryCall&&i.effect&&f._renderId===a.getRenderId())return!0;var l=a.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(a,r,f,!1,this._maxSimultaneousLights),f._needNormals=!0,f._areTexturesDirty){if(f._needUVs=!1,a.texturesEnabled){if(a.getEngine().getCaps().textureLOD&&(f.TEXTURELODSUPPORT=!0),this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._diffuseTexture,f,"DIFFUSE"),f.DIFFUSEHASALPHA=this._diffuseTexture.hasAlpha,f.GAMMADIFFUSE=this._diffuseTexture.gammaSpace,f.OPACITYFRESNEL=this._opacityFresnel}else f.DIFFUSE=!1,f.DIFFUSEHASALPHA=!1,f.GAMMADIFFUSE=!1,f.OPACITYFRESNEL=!1;var s=this._reflectionTexture;if(s&&e.StandardMaterial.ReflectionTextureEnabled){if(!s.isReadyOrNotBlocking())return!1;switch(f.REFLECTION=!0,f.GAMMAREFLECTION=s.gammaSpace,f.REFLECTIONBLUR=this._reflectionBlur>0,f.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!s.invertZ:s.invertZ,f.LODINREFLECTIONALPHA=s.lodLevelInAlpha,s.coordinatesMode===e.Texture.INVCUBIC_MODE&&(f.INVERTCUBICMAP=!0),f.REFLECTIONMAP_3D=s.isCube,s.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:f.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:f.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:f.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:f.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:f.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:f.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:f.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:f.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:f.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0}this.reflectionFresnel?(f.REFLECTIONFRESNEL=!0,f.REFLECTIONFALLOFF=this.reflectionFalloffDistance>0,this._reflectionControls.x=this.reflectionAmount,this._reflectionControls.y=this.reflectionReflectance0,this._reflectionControls.z=this.reflectionReflectance90,this._reflectionControls.w=this.reflectionFalloffDistance):(f.REFLECTIONFRESNEL=!1,f.REFLECTIONFALLOFF=!1)}else f.REFLECTION=!1,f.REFLECTIONFALLOFF=!1,f.REFLECTIONBLUR=!1,f.REFLECTIONMAP_3D=!1,f.REFLECTIONMAP_SPHERICAL=!1,f.REFLECTIONMAP_PLANAR=!1,f.REFLECTIONMAP_CUBIC=!1,f.REFLECTIONMAP_PROJECTION=!1,f.REFLECTIONMAP_SKYBOX=!1,f.REFLECTIONMAP_EXPLICIT=!1,f.REFLECTIONMAP_EQUIRECTANGULAR=!1,f.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,f.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,f.INVERTCUBICMAP=!1,f.REFLECTIONMAP_OPPOSITEZ=!1,f.LODINREFLECTIONALPHA=!1,f.GAMMAREFLECTION=!1}f.PREMULTIPLYALPHA=this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED||this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF,f.USERGBCOLOR=this._useRGBColor}if(f._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(f)}if(e.MaterialHelper.PrepareDefinesForMisc(r,a,!1,this.pointsCloud,this.fogEnabled,f),e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,l,f,o,!1),e.MaterialHelper.PrepareDefinesForAttributes(r,f,!1,!0,!1)&&r&&(a.getEngine().getCaps().standardDerivatives||r.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(r.createNormals(!0),e.Tools.Warn("BackgroundMaterial: Normals have been created for the mesh: "+r.name))),f.isDirty){f.markAsProcessed(),a.resetCachedMaterial();var c=new e.EffectFallbacks;f.FOG&&c.addFallback(0,"FOG"),f.POINTSIZE&&c.addFallback(1,"POINTSIZE"),e.MaterialHelper.HandleFallbacksForShadows(f,c,this._maxSimultaneousLights),f.NUM_BONE_INFLUENCERS>0&&c.addCPUSkinningFallback(0,r);var d=[e.VertexBuffer.PositionKind];f.NORMAL&&d.push(e.VertexBuffer.NormalKind),f.UV1&&d.push(e.VertexBuffer.UVKind),f.UV2&&d.push(e.VertexBuffer.UV2Kind),e.MaterialHelper.PrepareAttributesForBones(d,r,f,c),e.MaterialHelper.PrepareAttributesForInstances(d,f);var u=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","vClipPlane","mBones","vPrimaryColor","vSecondaryColor","vTertiaryColor","vReflectionInfos","reflectionMatrix","vReflectionMicrosurfaceInfos","shadowLevel","alpha","vBackgroundCenter","vReflectionControl","vDiffuseInfos","diffuseMatrix"],E=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],_=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(u,f),e.ImageProcessingConfiguration.PrepareSamplers(E,f),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:_,samplers:E,defines:f,maxSimultaneousLights:this._maxSimultaneousLights});var m=function(e){t.onCompiled&&t.onCompiled(e),t.bindSceneUniformBuffer(e,a.getSceneUniformBuffer())},p=f.toString();i.setEffect(a.getEngine().createEffect("background",{attributes:d,uniformsNames:u,uniformBuffersNames:_,samplers:E,defines:p,fallbacks:c,onCompiled:m,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},l),f),this.buildUniformLayout()}return!(!i.effect||!i.effect.isReady())&&(f._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},i.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vPrimaryColor",4),this._uniformBuffer.addUniform("vSecondaryColor",4),this._uniformBuffer.addUniform("vTertiaryColor",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.addUniform("shadowLevel",1),this._uniformBuffer.addUniform("alpha",1),this._uniformBuffer.addUniform("vBackgroundCenter",3),this._uniformBuffer.addUniform("vReflectionControl",4),this._uniformBuffer.create()},i.prototype.unbind=function(){this._diffuseTexture&&this._diffuseTexture.isRenderTarget&&this._uniformBuffer.setTexture("diffuseSampler",null),this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),r.prototype.unbind.call(this)},i.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},i.prototype.bindForSubMesh=function(n,r,i){var o=this.getScene(),t=i._materialDefines;if(t){var a=i.effect;if(a){this._activeEffect=a,this.bindOnlyWorldMatrix(n),e.MaterialHelper.BindBonesParameters(r,this._activeEffect);var f=this._mustRebind(o,a,r.visibility);if(f){this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a);var l=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync||(o.texturesEnabled&&(this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),e.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),l&&e.StandardMaterial.ReflectionTextureEnabled&&(this._uniformBuffer.updateMatrix("reflectionMatrix",l.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",l.level,this._reflectionBlur),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",l.getSize().width,l.lodGenerationScale,l.lodGenerationOffset))),this.shadowLevel>0&&this._uniformBuffer.updateFloat("shadowLevel",this.shadowLevel),this._uniformBuffer.updateFloat("alpha",this.alpha),this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryColor,this._primaryLevel),this._uniformBuffer.updateColor4("vSecondaryColor",this._secondaryColor,this._secondaryLevel),this._uniformBuffer.updateColor4("vTertiaryColor",this._tertiaryColor,this._tertiaryLevel)),o.texturesEnabled&&(this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),l&&e.StandardMaterial.ReflectionTextureEnabled&&(t.REFLECTIONBLUR&&t.TEXTURELODSUPPORT?this._uniformBuffer.setTexture("reflectionSampler",l):t.REFLECTIONBLUR?(this._uniformBuffer.setTexture("reflectionSampler",l._lodTextureMid||l),this._uniformBuffer.setTexture("reflectionSamplerLow",l._lodTextureLow||l),this._uniformBuffer.setTexture("reflectionSamplerHigh",l._lodTextureHigh||l)):this._uniformBuffer.setTexture("reflectionSampler",l),t.REFLECTIONFRESNEL&&(this._uniformBuffer.updateFloat3("vBackgroundCenter",this.sceneCenter.x,this.sceneCenter.y,this.sceneCenter.z),this._uniformBuffer.updateFloat4("vReflectionControl",this._reflectionControls.x,this._reflectionControls.y,this._reflectionControls.z,this._reflectionControls.w)))),e.MaterialHelper.BindClipPlane(this._activeEffect,o),e.MaterialHelper.BindEyePosition(a,o)}!f&&this.isFrozen||(o.lightsEnabled&&e.MaterialHelper.BindLights(o,r,this._activeEffect,t,this._maxSimultaneousLights,!1),this.bindView(a),e.MaterialHelper.BindFogParameters(o,r,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(r)}}},i.prototype.dispose=function(e,n){void 0===e&&(e=!1),void 0===n&&(n=!1),n&&(this.diffuseTexture&&this.diffuseTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e)},i.prototype.clone=function(n){var r=this;return e.SerializationHelper.Clone((function(){return new i(n,r.getScene())}),this)},i.prototype.serialize=function(){var n=e.SerializationHelper.Serialize(this);return n.customType="BABYLON.BackgroundMaterial",n},i.prototype.getClassName=function(){return"BackgroundMaterial"},i.Parse=function(n,r,o){return e.SerializationHelper.Parse((function(){return new i(n.name,r)}),n,r,o)},__decorate([e.serializeAsColor3()],i.prototype,"_primaryColor",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"primaryColor",void 0),__decorate([e.serialize()],i.prototype,"_primaryLevel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"primaryLevel",void 0),__decorate([e.serializeAsColor3()],i.prototype,"_secondaryColor",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"secondaryColor",void 0),__decorate([e.serialize()],i.prototype,"_secondaryLevel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"secondaryLevel",void 0),__decorate([e.serializeAsColor3()],i.prototype,"_tertiaryColor",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"tertiaryColor",void 0),__decorate([e.serialize()],i.prototype,"_tertiaryLevel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"tertiaryLevel",void 0),__decorate([e.serializeAsTexture()],i.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionTexture",void 0),__decorate([e.serialize()],i.prototype,"_reflectionBlur",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionBlur",void 0),__decorate([e.serializeAsTexture()],i.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"shadowLights",void 0),__decorate([e.serialize()],i.prototype,"_shadowBlurScale",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"shadowBlurScale",void 0),__decorate([e.serialize()],i.prototype,"_shadowLevel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"shadowLevel",void 0),__decorate([e.serializeAsVector3()],i.prototype,"_sceneCenter",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"sceneCenter",void 0),__decorate([e.serialize()],i.prototype,"_opacityFresnel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityFresnel",void 0),__decorate([e.serialize()],i.prototype,"_reflectionFresnel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionFresnel",void 0),__decorate([e.serialize()],i.prototype,"_reflectionFalloffDistance",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionFalloffDistance",void 0),__decorate([e.serialize()],i.prototype,"_reflectionAmount",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionAmount",void 0),__decorate([e.serialize()],i.prototype,"_reflectionReflectance0",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionReflectance0",void 0),__decorate([e.serialize()],i.prototype,"_reflectionReflectance90",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionReflectance90",void 0),__decorate([e.serialize()],i.prototype,"_useRGBColor",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useRGBColor",void 0),__decorate([e.serialize()],i.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serializeAsImageProcessingConfiguration()],i.prototype,"_imageProcessingConfiguration",void 0),i})(e.PushMaterial);e.BackgroundMaterial=r})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.backgroundVertexShader="precision highp float;\n#include<__decl__backgroundVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2; \n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif \n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0 \nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n",BABYLON.Effect.ShadersStore.backgroundPixelShader="#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2; \n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<helperFunctions>\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n\nvec3 reflectionColor=vec3(1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\n\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD).rgb;\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD,0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec3 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords).rgb;\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords).rgb,\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords).rgb,\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample.rgb;\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor=toLinearSpace(reflectionColor.rgb);\n#endif\n\nreflectionColor*=vReflectionInfos.x;\n#endif\n\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\nvec3 finalColor=colorBase.r*vPrimaryColor.rgb*vPrimaryColor.a;\nfinalColor+=colorBase.g*vSecondaryColor.rgb*vSecondaryColor.a;\nfinalColor+=colorBase.b*vTertiaryColor.rgb*vTertiaryColor.a;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(clamp(VdotN,0.0,1.0),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-clamp(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w,0.0,1.0);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor,clamp(reflectionAmount,0.,1.));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=clamp(viewAngleToFloor/startAngle,0.0,1.0);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\ngl_FragColor=color;\n}",BABYLON.Effect.IncludesShadersStore.backgroundFragmentDeclaration=" uniform vec4 vPrimaryColor;\nuniform vec4 vSecondaryColor;\nuniform vec4 vTertiaryColor;\nuniform float shadowLevel;\nuniform float alpha;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif",BABYLON.Effect.IncludesShadersStore.backgroundUboDeclaration="layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vSecondaryColor;\nuniform vec4 vTertiaryColor;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};",BABYLON.Effect.IncludesShadersStore.backgroundVertexDeclaration="uniform mat4 view;\nuniform mat4 viewProjection;\nuniform float shadowLevel;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif";