@babylonjs/materials 6.43.0 → 6.45.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cell/cellMaterial.js +13 -13
- package/cell/cellMaterial.js.map +1 -1
- package/fire/fireMaterial.js +8 -8
- package/fire/fireMaterial.js.map +1 -1
- package/fur/furMaterial.js +13 -13
- package/fur/furMaterial.js.map +1 -1
- package/gradient/gradientMaterial.js +13 -13
- package/gradient/gradientMaterial.js.map +1 -1
- package/grid/gridMaterial.js +7 -7
- package/grid/gridMaterial.js.map +1 -1
- package/lava/lavaMaterial.js +13 -13
- package/lava/lavaMaterial.js.map +1 -1
- package/mix/mixMaterial.js +13 -13
- package/mix/mixMaterial.js.map +1 -1
- package/normal/normalMaterial.js +13 -13
- package/normal/normalMaterial.js.map +1 -1
- package/package.json +2 -2
- package/shadowOnly/shadowOnlyMaterial.js +13 -13
- package/shadowOnly/shadowOnlyMaterial.js.map +1 -1
- package/simple/simpleMaterial.js +13 -13
- package/simple/simpleMaterial.js.map +1 -1
- package/sky/skyMaterial.js +5 -5
- package/sky/skyMaterial.js.map +1 -1
- package/terrain/terrainMaterial.js +13 -13
- package/terrain/terrainMaterial.js.map +1 -1
- package/triPlanar/triPlanarMaterial.js +13 -13
- package/triPlanar/triPlanarMaterial.js.map +1 -1
- package/water/waterMaterial.js +14 -14
- package/water/waterMaterial.js.map +1 -1
package/sky/skyMaterial.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"skyMaterial.js","sourceRoot":"","sources":["../../../../dev/materials/src/sky/skyMaterial.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,mBAAmB,EAAE,2CAA6B;AAE1F,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,6CAA+B;AAG7D,OAAO,EAAE,eAAe,EAAE,qDAAuC;AACjE,OAAO,EAAE,cAAc,EAAE,oDAAsC;AAC/D,OAAO,EAAE,YAAY,EAAE,kDAAoC;AAC3D,OAAO,EAAE,YAAY,EAAE,0CA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AI,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACxG,CAAC;CACJ;AApWU;IADN,SAAS,EAAE;8CACmB;AAMxB;IADN,SAAS,EAAE;8CACoB;AAMzB;IADN,SAAS,EAAE;6CACkB;AAMvB;IADN,SAAS,EAAE;mDAC0B;AAM/B;IADN,SAAS,EAAE;oDACyB;AAM9B;IADN,SAAS,EAAE;6CACkB;AAOvB;IADN,SAAS,EAAE;gDACsB;AAO3B;IADN,SAAS,EAAE;4CACkB;AAOvB;IADN,kBAAkB,EAAE;gDACgC;AAO9C;IADN,SAAS,EAAE;mDAC2B;AAOhC;IADN,kBAAkB,EAAE;iDACyB;AAMvC;IADN,kBAAkB,EAAE;uCACa;AAM3B;IADN,SAAS,EAAE;8CACsB;AAyRtC,aAAa,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { serializeAsVector3, serialize, SerializationHelper } from \"core/Misc/decorators\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Vector3, Quaternion } from \"core/Maths/math.vector\";\r\nimport type { IAnimatable } from \"core/Animations/animatable.interface\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { MaterialDefines } from \"core/Materials/materialDefines\";\r\nimport { MaterialHelper } from \"core/Materials/materialHelper\";\r\nimport { PushMaterial } from \"core/Materials/pushMaterial\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\n\r\nimport \"./sky.fragment\";\r\nimport \"./sky.vertex\";\r\nimport { EffectFallbacks } from \"core/Materials/effectFallbacks\";\r\nimport { addClipPlaneUniforms, bindClipPlane } from \"core/Materials/clipPlaneMaterialHelper\";\r\n\r\n/** @internal */\r\nclass SkyMaterialDefines extends MaterialDefines {\r\n public CLIPPLANE = false;\r\n public CLIPPLANE2 = false;\r\n public CLIPPLANE3 = false;\r\n public CLIPPLANE4 = false;\r\n public CLIPPLANE5 = false;\r\n public CLIPPLANE6 = false;\r\n public POINTSIZE = false;\r\n public FOG = false;\r\n public VERTEXCOLOR = false;\r\n public VERTEXALPHA = false;\r\n public IMAGEPROCESSINGPOSTPROCESS = false;\r\n public SKIPFINALCOLORCLAMP = false;\r\n public DITHER = false;\r\n public LOGARITHMICDEPTH = false;\r\n\r\n constructor() {\r\n super();\r\n this.rebuild();\r\n }\r\n}\r\n\r\n/**\r\n * This is the sky material which allows to create dynamic and texture free effects for skyboxes.\r\n * @see https://doc.babylonjs.com/toolsAndResources/assetLibraries/materialsLibrary/skyMat\r\n */\r\nexport class SkyMaterial extends PushMaterial {\r\n /**\r\n * Defines the overall luminance of sky in interval ]0, 1[.\r\n */\r\n @serialize()\r\n public luminance: number = 1.0;\r\n\r\n /**\r\n * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.\r\n */\r\n @serialize()\r\n public turbidity: number = 10.0;\r\n\r\n /**\r\n * Defines the sky appearance (light intensity).\r\n */\r\n @serialize()\r\n public rayleigh: number = 2.0;\r\n\r\n /**\r\n * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.\r\n */\r\n @serialize()\r\n public mieCoefficient: number = 0.005;\r\n\r\n /**\r\n * Defines the amount of haze particles following the Mie scattering theory.\r\n */\r\n @serialize()\r\n public mieDirectionalG: number = 0.8;\r\n\r\n /**\r\n * Defines the distance of the sun according to the active scene camera.\r\n */\r\n @serialize()\r\n public distance: number = 500;\r\n\r\n /**\r\n * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said\r\n * \"inclined\".\r\n */\r\n @serialize()\r\n public inclination: number = 0.49;\r\n\r\n /**\r\n * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between\r\n * an object direction and a reference direction.\r\n */\r\n @serialize()\r\n public azimuth: number = 0.25;\r\n\r\n /**\r\n * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then\r\n * the property is overridden by the inclination and the azimuth and can be read at any moment.\r\n */\r\n @serializeAsVector3()\r\n public sunPosition: Vector3 = new Vector3(0, 100, 0);\r\n\r\n /**\r\n * Defines if the sun position should be computed (inclination and azimuth) according to the given\r\n * .sunPosition property.\r\n */\r\n @serialize()\r\n public useSunPosition: boolean = false;\r\n\r\n /**\r\n * Defines an offset vector used to get a horizon offset.\r\n * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis\r\n */\r\n @serializeAsVector3()\r\n public cameraOffset: Vector3 = Vector3.Zero();\r\n\r\n /**\r\n * Defines the vector the skyMaterial should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())\r\n */\r\n @serializeAsVector3()\r\n public up: Vector3 = Vector3.Up();\r\n\r\n /**\r\n * Defines if sky should be dithered.\r\n */\r\n @serialize()\r\n public dithering: boolean = false;\r\n\r\n // Private members\r\n private _cameraPosition: Vector3 = Vector3.Zero();\r\n private _skyOrientation: Quaternion = new Quaternion();\r\n\r\n /**\r\n * Instantiates a new sky material.\r\n * This material allows to create dynamic and texture free\r\n * effects for skyboxes by taking care of the atmosphere state.\r\n * @see https://doc.babylonjs.com/toolsAndResources/assetLibraries/materialsLibrary/skyMat\r\n * @param name Define the name of the material in the scene\r\n * @param scene Define the scene the material belong to\r\n */\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n }\r\n\r\n /**\r\n * Specifies if the material will require alpha blending\r\n * @returns a boolean specifying if alpha blending is needed\r\n */\r\n public needAlphaBlending(): boolean {\r\n return this.alpha < 1.0;\r\n }\r\n\r\n /**\r\n * Specifies if this material should be rendered in alpha test mode\r\n * @returns false as the sky material doesn't need alpha testing.\r\n */\r\n public needAlphaTesting(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Get the texture used for alpha test purpose.\r\n * @returns null as the sky material has no texture.\r\n */\r\n public getAlphaTestTexture(): Nullable<BaseTexture> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Get if the submesh is ready to be used and all its information available.\r\n * Child classes can use it to update shaders\r\n * @param mesh defines the mesh to check\r\n * @param subMesh defines which submesh to check\r\n * @returns a boolean indicating that the submesh is ready or not\r\n */\r\n public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh): boolean {\r\n const drawWrapper = subMesh._drawWrapper;\r\n\r\n if (this.isFrozen) {\r\n if (drawWrapper.effect && drawWrapper._wasPreviouslyReady) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!subMesh.materialDefines) {\r\n subMesh.materialDefines = new SkyMaterialDefines();\r\n }\r\n\r\n const defines = <SkyMaterialDefines>subMesh.materialDefines;\r\n const scene = this.getScene();\r\n\r\n if (this._isReadyForSubMesh(subMesh)) {\r\n return true;\r\n }\r\n\r\n MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, false, defines);\r\n\r\n // Attribs\r\n MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, false);\r\n\r\n if (defines.IMAGEPROCESSINGPOSTPROCESS !== scene.imageProcessingConfiguration.applyByPostProcess) {\r\n defines.markAsMiscDirty();\r\n }\r\n\r\n if (defines.DITHER !== this.dithering) {\r\n defines.markAsMiscDirty();\r\n }\r\n\r\n // Get correct effect\r\n if (defines.isDirty) {\r\n defines.markAsProcessed();\r\n\r\n scene.resetCachedMaterial();\r\n\r\n // Fallbacks\r\n const fallbacks = new EffectFallbacks();\r\n if (defines.FOG) {\r\n fallbacks.addFallback(1, \"FOG\");\r\n }\r\n\r\n defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;\r\n defines.DITHER = this.dithering;\r\n\r\n //Attributes\r\n const attribs = [VertexBuffer.PositionKind];\r\n\r\n if (defines.VERTEXCOLOR) {\r\n attribs.push(VertexBuffer.ColorKind);\r\n }\r\n\r\n const shaderName = \"sky\";\r\n\r\n const uniforms = [\r\n \"world\",\r\n \"viewProjection\",\r\n \"view\",\r\n \"vFogInfos\",\r\n \"vFogColor\",\r\n \"logarithmicDepthConstant\",\r\n \"pointSize\",\r\n \"luminance\",\r\n \"turbidity\",\r\n \"rayleigh\",\r\n \"mieCoefficient\",\r\n \"mieDirectionalG\",\r\n \"sunPosition\",\r\n \"cameraPosition\",\r\n \"cameraOffset\",\r\n \"up\",\r\n ];\r\n addClipPlaneUniforms(uniforms);\r\n const join = defines.toString();\r\n subMesh.setEffect(scene.getEngine().createEffect(shaderName, attribs, uniforms, [], join, fallbacks, this.onCompiled, this.onError), defines, this._materialContext);\r\n }\r\n\r\n if (!subMesh.effect || !subMesh.effect.isReady()) {\r\n return false;\r\n }\r\n\r\n defines._renderId = scene.getRenderId();\r\n drawWrapper._wasPreviouslyReady = true;\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Binds the submesh to this material by preparing the effect and shader to draw\r\n * @param world defines the world transformation matrix\r\n * @param mesh defines the mesh containing the submesh\r\n * @param subMesh defines the submesh to bind the material to\r\n */\r\n public bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {\r\n const scene = this.getScene();\r\n\r\n const defines = <SkyMaterialDefines>subMesh.materialDefines;\r\n if (!defines) {\r\n return;\r\n }\r\n\r\n const effect = subMesh.effect;\r\n if (!effect) {\r\n return;\r\n }\r\n this._activeEffect = effect;\r\n\r\n // Matrices\r\n this.bindOnlyWorldMatrix(world);\r\n this._activeEffect.setMatrix(\"viewProjection\", scene.getTransformMatrix());\r\n\r\n if (this._mustRebind(scene, effect, subMesh)) {\r\n bindClipPlane(effect, this, scene);\r\n\r\n // Point size\r\n if (this.pointsCloud) {\r\n this._activeEffect.setFloat(\"pointSize\", this.pointSize);\r\n }\r\n\r\n // Log. depth\r\n if (this._useLogarithmicDepth) {\r\n MaterialHelper.BindLogDepth(defines, effect, scene);\r\n }\r\n }\r\n\r\n // View\r\n if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {\r\n this._activeEffect.setMatrix(\"view\", scene.getViewMatrix());\r\n }\r\n\r\n // Fog\r\n MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);\r\n\r\n // Sky\r\n const camera = scene.activeCamera;\r\n if (camera) {\r\n const cameraWorldMatrix = camera.getWorldMatrix();\r\n this._cameraPosition.x = cameraWorldMatrix.m[12];\r\n this._cameraPosition.y = cameraWorldMatrix.m[13];\r\n this._cameraPosition.z = cameraWorldMatrix.m[14];\r\n this._activeEffect.setVector3(\"cameraPosition\", this._cameraPosition);\r\n }\r\n\r\n this._activeEffect.setVector3(\"cameraOffset\", this.cameraOffset);\r\n\r\n this._activeEffect.setVector3(\"up\", this.up);\r\n\r\n if (this.luminance > 0) {\r\n this._activeEffect.setFloat(\"luminance\", this.luminance);\r\n }\r\n\r\n this._activeEffect.setFloat(\"turbidity\", this.turbidity);\r\n this._activeEffect.setFloat(\"rayleigh\", this.rayleigh);\r\n this._activeEffect.setFloat(\"mieCoefficient\", this.mieCoefficient);\r\n this._activeEffect.setFloat(\"mieDirectionalG\", this.mieDirectionalG);\r\n\r\n if (!this.useSunPosition) {\r\n const theta = Math.PI * (this.inclination - 0.5);\r\n const phi = 2 * Math.PI * (this.azimuth - 0.5);\r\n\r\n this.sunPosition.x = this.distance * Math.cos(phi) * Math.cos(theta);\r\n this.sunPosition.y = this.distance * Math.sin(-theta);\r\n this.sunPosition.z = this.distance * Math.sin(phi) * Math.cos(theta);\r\n\r\n Quaternion.FromUnitVectorsToRef(Vector3.UpReadOnly, this.up, this._skyOrientation);\r\n this.sunPosition.rotateByQuaternionToRef(this._skyOrientation, this.sunPosition);\r\n }\r\n\r\n this._activeEffect.setVector3(\"sunPosition\", this.sunPosition);\r\n\r\n this._afterBind(mesh, this._activeEffect, subMesh);\r\n }\r\n\r\n /**\r\n * Get the list of animatables in the material.\r\n * @returns the list of animatables object used in the material\r\n */\r\n public getAnimatables(): IAnimatable[] {\r\n return [];\r\n }\r\n\r\n /**\r\n * Disposes the material\r\n * @param forceDisposeEffect specifies if effects should be forcefully disposed\r\n */\r\n public dispose(forceDisposeEffect?: boolean): void {\r\n super.dispose(forceDisposeEffect);\r\n }\r\n\r\n /**\r\n * Makes a duplicate of the material, and gives it a new name\r\n * @param name defines the new name for the duplicated material\r\n * @returns the cloned material\r\n */\r\n public clone(name: string): SkyMaterial {\r\n return SerializationHelper.Clone<SkyMaterial>(() => new SkyMaterial(name, this.getScene()), this);\r\n }\r\n\r\n /**\r\n * Serializes this material in a JSON representation\r\n * @returns the serialized material object\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.customType = \"BABYLON.SkyMaterial\";\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Gets the current class name of the material e.g. \"SkyMaterial\"\r\n * Mainly use in serialization.\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"SkyMaterial\";\r\n }\r\n\r\n /**\r\n * Creates a sky material from parsed material data\r\n * @param source defines the JSON representation of the material\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @returns a new sky material\r\n */\r\n public static Parse(source: any, scene: Scene, rootUrl: string): SkyMaterial {\r\n return SerializationHelper.Parse(() => new SkyMaterial(source.name, scene), source, scene, rootUrl);\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SkyMaterial\", SkyMaterial);\r\n"]}
|
1
|
+
{"version":3,"file":"skyMaterial.js","sourceRoot":"","sources":["../../../../dev/materials/src/sky/skyMaterial.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,mBAAmB,EAAE,2CAA6B;AAE1F,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,6CAA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AC;IACzB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,MAAW,EAAE,KAAY,EAAE,OAAe;QAC1D,OAAO,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACxG,CAAC;CACJ;AApWU;IADN,SAAS,EAAE;8CACmB;AAMxB;IADN,SAAS,EAAE;8CACoB;AAMzB;IADN,SAAS,EAAE;6CACkB;AAMvB;IADN,SAAS,EAAE;mDAC0B;AAM/B;IADN,SAAS,EAAE;oDACyB;AAM9B;IADN,SAAS,EAAE;6CACkB;AAOvB;IADN,SAAS,EAAE;gDACsB;AAO3B;IADN,SAAS,EAAE;4CACkB;AAOvB;IADN,kBAAkB,EAAE;gDACgC;AAO9C;IADN,SAAS,EAAE;mDAC2B;AAOhC;IADN,kBAAkB,EAAE;iDACyB;AAMvC;IADN,kBAAkB,EAAE;uCACa;AAM3B;IADN,SAAS,EAAE;8CACsB;AAyRtC,aAAa,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { serializeAsVector3, serialize, SerializationHelper } from \"core/Misc/decorators\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Vector3, Quaternion } from \"core/Maths/math.vector\";\r\nimport type { IAnimatable } from \"core/Animations/animatable.interface\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { MaterialDefines } from \"core/Materials/materialDefines\";\r\nimport { PushMaterial } from \"core/Materials/pushMaterial\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\n\r\nimport \"./sky.fragment\";\r\nimport \"./sky.vertex\";\r\nimport { EffectFallbacks } from \"core/Materials/effectFallbacks\";\r\nimport { addClipPlaneUniforms, bindClipPlane } from \"core/Materials/clipPlaneMaterialHelper\";\r\nimport { BindFogParameters, BindLogDepth, PrepareDefinesForAttributes, PrepareDefinesForMisc } from \"core/Materials/materialHelper.functions\";\r\n\r\n/** @internal */\r\nclass SkyMaterialDefines extends MaterialDefines {\r\n public CLIPPLANE = false;\r\n public CLIPPLANE2 = false;\r\n public CLIPPLANE3 = false;\r\n public CLIPPLANE4 = false;\r\n public CLIPPLANE5 = false;\r\n public CLIPPLANE6 = false;\r\n public POINTSIZE = false;\r\n public FOG = false;\r\n public VERTEXCOLOR = false;\r\n public VERTEXALPHA = false;\r\n public IMAGEPROCESSINGPOSTPROCESS = false;\r\n public SKIPFINALCOLORCLAMP = false;\r\n public DITHER = false;\r\n public LOGARITHMICDEPTH = false;\r\n\r\n constructor() {\r\n super();\r\n this.rebuild();\r\n }\r\n}\r\n\r\n/**\r\n * This is the sky material which allows to create dynamic and texture free effects for skyboxes.\r\n * @see https://doc.babylonjs.com/toolsAndResources/assetLibraries/materialsLibrary/skyMat\r\n */\r\nexport class SkyMaterial extends PushMaterial {\r\n /**\r\n * Defines the overall luminance of sky in interval ]0, 1[.\r\n */\r\n @serialize()\r\n public luminance: number = 1.0;\r\n\r\n /**\r\n * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.\r\n */\r\n @serialize()\r\n public turbidity: number = 10.0;\r\n\r\n /**\r\n * Defines the sky appearance (light intensity).\r\n */\r\n @serialize()\r\n public rayleigh: number = 2.0;\r\n\r\n /**\r\n * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.\r\n */\r\n @serialize()\r\n public mieCoefficient: number = 0.005;\r\n\r\n /**\r\n * Defines the amount of haze particles following the Mie scattering theory.\r\n */\r\n @serialize()\r\n public mieDirectionalG: number = 0.8;\r\n\r\n /**\r\n * Defines the distance of the sun according to the active scene camera.\r\n */\r\n @serialize()\r\n public distance: number = 500;\r\n\r\n /**\r\n * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said\r\n * \"inclined\".\r\n */\r\n @serialize()\r\n public inclination: number = 0.49;\r\n\r\n /**\r\n * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between\r\n * an object direction and a reference direction.\r\n */\r\n @serialize()\r\n public azimuth: number = 0.25;\r\n\r\n /**\r\n * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then\r\n * the property is overridden by the inclination and the azimuth and can be read at any moment.\r\n */\r\n @serializeAsVector3()\r\n public sunPosition: Vector3 = new Vector3(0, 100, 0);\r\n\r\n /**\r\n * Defines if the sun position should be computed (inclination and azimuth) according to the given\r\n * .sunPosition property.\r\n */\r\n @serialize()\r\n public useSunPosition: boolean = false;\r\n\r\n /**\r\n * Defines an offset vector used to get a horizon offset.\r\n * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis\r\n */\r\n @serializeAsVector3()\r\n public cameraOffset: Vector3 = Vector3.Zero();\r\n\r\n /**\r\n * Defines the vector the skyMaterial should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())\r\n */\r\n @serializeAsVector3()\r\n public up: Vector3 = Vector3.Up();\r\n\r\n /**\r\n * Defines if sky should be dithered.\r\n */\r\n @serialize()\r\n public dithering: boolean = false;\r\n\r\n // Private members\r\n private _cameraPosition: Vector3 = Vector3.Zero();\r\n private _skyOrientation: Quaternion = new Quaternion();\r\n\r\n /**\r\n * Instantiates a new sky material.\r\n * This material allows to create dynamic and texture free\r\n * effects for skyboxes by taking care of the atmosphere state.\r\n * @see https://doc.babylonjs.com/toolsAndResources/assetLibraries/materialsLibrary/skyMat\r\n * @param name Define the name of the material in the scene\r\n * @param scene Define the scene the material belong to\r\n */\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n }\r\n\r\n /**\r\n * Specifies if the material will require alpha blending\r\n * @returns a boolean specifying if alpha blending is needed\r\n */\r\n public needAlphaBlending(): boolean {\r\n return this.alpha < 1.0;\r\n }\r\n\r\n /**\r\n * Specifies if this material should be rendered in alpha test mode\r\n * @returns false as the sky material doesn't need alpha testing.\r\n */\r\n public needAlphaTesting(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Get the texture used for alpha test purpose.\r\n * @returns null as the sky material has no texture.\r\n */\r\n public getAlphaTestTexture(): Nullable<BaseTexture> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Get if the submesh is ready to be used and all its information available.\r\n * Child classes can use it to update shaders\r\n * @param mesh defines the mesh to check\r\n * @param subMesh defines which submesh to check\r\n * @returns a boolean indicating that the submesh is ready or not\r\n */\r\n public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh): boolean {\r\n const drawWrapper = subMesh._drawWrapper;\r\n\r\n if (this.isFrozen) {\r\n if (drawWrapper.effect && drawWrapper._wasPreviouslyReady) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!subMesh.materialDefines) {\r\n subMesh.materialDefines = new SkyMaterialDefines();\r\n }\r\n\r\n const defines = <SkyMaterialDefines>subMesh.materialDefines;\r\n const scene = this.getScene();\r\n\r\n if (this._isReadyForSubMesh(subMesh)) {\r\n return true;\r\n }\r\n\r\n PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, false, defines);\r\n\r\n // Attribs\r\n PrepareDefinesForAttributes(mesh, defines, true, false);\r\n\r\n if (defines.IMAGEPROCESSINGPOSTPROCESS !== scene.imageProcessingConfiguration.applyByPostProcess) {\r\n defines.markAsMiscDirty();\r\n }\r\n\r\n if (defines.DITHER !== this.dithering) {\r\n defines.markAsMiscDirty();\r\n }\r\n\r\n // Get correct effect\r\n if (defines.isDirty) {\r\n defines.markAsProcessed();\r\n\r\n scene.resetCachedMaterial();\r\n\r\n // Fallbacks\r\n const fallbacks = new EffectFallbacks();\r\n if (defines.FOG) {\r\n fallbacks.addFallback(1, \"FOG\");\r\n }\r\n\r\n defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;\r\n defines.DITHER = this.dithering;\r\n\r\n //Attributes\r\n const attribs = [VertexBuffer.PositionKind];\r\n\r\n if (defines.VERTEXCOLOR) {\r\n attribs.push(VertexBuffer.ColorKind);\r\n }\r\n\r\n const shaderName = \"sky\";\r\n\r\n const uniforms = [\r\n \"world\",\r\n \"viewProjection\",\r\n \"view\",\r\n \"vFogInfos\",\r\n \"vFogColor\",\r\n \"logarithmicDepthConstant\",\r\n \"pointSize\",\r\n \"luminance\",\r\n \"turbidity\",\r\n \"rayleigh\",\r\n \"mieCoefficient\",\r\n \"mieDirectionalG\",\r\n \"sunPosition\",\r\n \"cameraPosition\",\r\n \"cameraOffset\",\r\n \"up\",\r\n ];\r\n addClipPlaneUniforms(uniforms);\r\n const join = defines.toString();\r\n subMesh.setEffect(scene.getEngine().createEffect(shaderName, attribs, uniforms, [], join, fallbacks, this.onCompiled, this.onError), defines, this._materialContext);\r\n }\r\n\r\n if (!subMesh.effect || !subMesh.effect.isReady()) {\r\n return false;\r\n }\r\n\r\n defines._renderId = scene.getRenderId();\r\n drawWrapper._wasPreviouslyReady = true;\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Binds the submesh to this material by preparing the effect and shader to draw\r\n * @param world defines the world transformation matrix\r\n * @param mesh defines the mesh containing the submesh\r\n * @param subMesh defines the submesh to bind the material to\r\n */\r\n public bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {\r\n const scene = this.getScene();\r\n\r\n const defines = <SkyMaterialDefines>subMesh.materialDefines;\r\n if (!defines) {\r\n return;\r\n }\r\n\r\n const effect = subMesh.effect;\r\n if (!effect) {\r\n return;\r\n }\r\n this._activeEffect = effect;\r\n\r\n // Matrices\r\n this.bindOnlyWorldMatrix(world);\r\n this._activeEffect.setMatrix(\"viewProjection\", scene.getTransformMatrix());\r\n\r\n if (this._mustRebind(scene, effect, subMesh)) {\r\n bindClipPlane(effect, this, scene);\r\n\r\n // Point size\r\n if (this.pointsCloud) {\r\n this._activeEffect.setFloat(\"pointSize\", this.pointSize);\r\n }\r\n\r\n // Log. depth\r\n if (this._useLogarithmicDepth) {\r\n BindLogDepth(defines, effect, scene);\r\n }\r\n }\r\n\r\n // View\r\n if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {\r\n this._activeEffect.setMatrix(\"view\", scene.getViewMatrix());\r\n }\r\n\r\n // Fog\r\n BindFogParameters(scene, mesh, this._activeEffect);\r\n\r\n // Sky\r\n const camera = scene.activeCamera;\r\n if (camera) {\r\n const cameraWorldMatrix = camera.getWorldMatrix();\r\n this._cameraPosition.x = cameraWorldMatrix.m[12];\r\n this._cameraPosition.y = cameraWorldMatrix.m[13];\r\n this._cameraPosition.z = cameraWorldMatrix.m[14];\r\n this._activeEffect.setVector3(\"cameraPosition\", this._cameraPosition);\r\n }\r\n\r\n this._activeEffect.setVector3(\"cameraOffset\", this.cameraOffset);\r\n\r\n this._activeEffect.setVector3(\"up\", this.up);\r\n\r\n if (this.luminance > 0) {\r\n this._activeEffect.setFloat(\"luminance\", this.luminance);\r\n }\r\n\r\n this._activeEffect.setFloat(\"turbidity\", this.turbidity);\r\n this._activeEffect.setFloat(\"rayleigh\", this.rayleigh);\r\n this._activeEffect.setFloat(\"mieCoefficient\", this.mieCoefficient);\r\n this._activeEffect.setFloat(\"mieDirectionalG\", this.mieDirectionalG);\r\n\r\n if (!this.useSunPosition) {\r\n const theta = Math.PI * (this.inclination - 0.5);\r\n const phi = 2 * Math.PI * (this.azimuth - 0.5);\r\n\r\n this.sunPosition.x = this.distance * Math.cos(phi) * Math.cos(theta);\r\n this.sunPosition.y = this.distance * Math.sin(-theta);\r\n this.sunPosition.z = this.distance * Math.sin(phi) * Math.cos(theta);\r\n\r\n Quaternion.FromUnitVectorsToRef(Vector3.UpReadOnly, this.up, this._skyOrientation);\r\n this.sunPosition.rotateByQuaternionToRef(this._skyOrientation, this.sunPosition);\r\n }\r\n\r\n this._activeEffect.setVector3(\"sunPosition\", this.sunPosition);\r\n\r\n this._afterBind(mesh, this._activeEffect, subMesh);\r\n }\r\n\r\n /**\r\n * Get the list of animatables in the material.\r\n * @returns the list of animatables object used in the material\r\n */\r\n public getAnimatables(): IAnimatable[] {\r\n return [];\r\n }\r\n\r\n /**\r\n * Disposes the material\r\n * @param forceDisposeEffect specifies if effects should be forcefully disposed\r\n */\r\n public dispose(forceDisposeEffect?: boolean): void {\r\n super.dispose(forceDisposeEffect);\r\n }\r\n\r\n /**\r\n * Makes a duplicate of the material, and gives it a new name\r\n * @param name defines the new name for the duplicated material\r\n * @returns the cloned material\r\n */\r\n public clone(name: string): SkyMaterial {\r\n return SerializationHelper.Clone<SkyMaterial>(() => new SkyMaterial(name, this.getScene()), this);\r\n }\r\n\r\n /**\r\n * Serializes this material in a JSON representation\r\n * @returns the serialized material object\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.customType = \"BABYLON.SkyMaterial\";\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Gets the current class name of the material e.g. \"SkyMaterial\"\r\n * Mainly use in serialization.\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"SkyMaterial\";\r\n }\r\n\r\n /**\r\n * Creates a sky material from parsed material data\r\n * @param source defines the JSON representation of the material\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @returns a new sky material\r\n */\r\n public static Parse(source: any, scene: Scene, rootUrl: string): SkyMaterial {\r\n return SerializationHelper.Parse(() => new SkyMaterial(source.name, scene), source, scene, rootUrl);\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SkyMaterial\", SkyMaterial);\r\n"]}
|
@@ -2,7 +2,6 @@ import { __decorate } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
3
3
|
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
4
4
|
import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
|
5
|
-
import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
|
6
5
|
import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
|
7
6
|
import { MaterialFlags } from "@babylonjs/core/Materials/materialFlags.js";
|
8
7
|
import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
@@ -12,6 +11,7 @@ import "./terrain.fragment.js";
|
|
12
11
|
import "./terrain.vertex.js";
|
13
12
|
import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
|
14
13
|
import { addClipPlaneUniforms, bindClipPlane } from "@babylonjs/core/Materials/clipPlaneMaterialHelper.js";
|
14
|
+
import { BindBonesParameters, BindFogParameters, BindLights, BindLogDepth, HandleFallbacksForShadows, PrepareAttributesForBones, PrepareAttributesForInstances, PrepareDefinesForAttributes, PrepareDefinesForFrameBoundValues, PrepareDefinesForLights, PrepareDefinesForMisc, PrepareUniformsAndSamplersList, } from "@babylonjs/core/Materials/materialHelper.functions.js";
|
15
15
|
class TerrainMaterialDefines extends MaterialDefines {
|
16
16
|
constructor() {
|
17
17
|
super();
|
@@ -111,13 +111,13 @@ export class TerrainMaterial extends PushMaterial {
|
|
111
111
|
}
|
112
112
|
}
|
113
113
|
// Misc.
|
114
|
-
|
114
|
+
PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
|
115
115
|
// Lights
|
116
|
-
defines._needNormals =
|
116
|
+
defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
|
117
117
|
// Values that need to be evaluated on every frame
|
118
|
-
|
118
|
+
PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);
|
119
119
|
// Attribs
|
120
|
-
|
120
|
+
PrepareDefinesForAttributes(mesh, defines, true, true);
|
121
121
|
// Get correct effect
|
122
122
|
if (defines.isDirty) {
|
123
123
|
defines.markAsProcessed();
|
@@ -127,7 +127,7 @@ export class TerrainMaterial extends PushMaterial {
|
|
127
127
|
if (defines.FOG) {
|
128
128
|
fallbacks.addFallback(1, "FOG");
|
129
129
|
}
|
130
|
-
|
130
|
+
HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
|
131
131
|
if (defines.NUM_BONE_INFLUENCERS > 0) {
|
132
132
|
fallbacks.addCPUSkinningFallback(0, mesh);
|
133
133
|
}
|
@@ -146,8 +146,8 @@ export class TerrainMaterial extends PushMaterial {
|
|
146
146
|
if (defines.VERTEXCOLOR) {
|
147
147
|
attribs.push(VertexBuffer.ColorKind);
|
148
148
|
}
|
149
|
-
|
150
|
-
|
149
|
+
PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
150
|
+
PrepareAttributesForInstances(attribs, defines);
|
151
151
|
// Legacy browser patch
|
152
152
|
const shaderName = "terrain";
|
153
153
|
const join = defines.toString();
|
@@ -181,7 +181,7 @@ export class TerrainMaterial extends PushMaterial {
|
|
181
181
|
];
|
182
182
|
const uniformBuffers = [];
|
183
183
|
addClipPlaneUniforms(uniforms);
|
184
|
-
|
184
|
+
PrepareUniformsAndSamplersList({
|
185
185
|
uniformsNames: uniforms,
|
186
186
|
uniformBuffersNames: uniformBuffers,
|
187
187
|
samplers: samplers,
|
@@ -223,7 +223,7 @@ export class TerrainMaterial extends PushMaterial {
|
|
223
223
|
this.bindOnlyWorldMatrix(world);
|
224
224
|
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
225
225
|
// Bones
|
226
|
-
|
226
|
+
BindBonesParameters(mesh, this._activeEffect);
|
227
227
|
if (this._mustRebind(scene, effect, subMesh)) {
|
228
228
|
// Textures
|
229
229
|
if (this.mixTexture) {
|
@@ -264,7 +264,7 @@ export class TerrainMaterial extends PushMaterial {
|
|
264
264
|
}
|
265
265
|
// Log. depth
|
266
266
|
if (this._useLogarithmicDepth) {
|
267
|
-
|
267
|
+
BindLogDepth(defines, effect, scene);
|
268
268
|
}
|
269
269
|
scene.bindEyePosition(effect);
|
270
270
|
}
|
@@ -273,14 +273,14 @@ export class TerrainMaterial extends PushMaterial {
|
|
273
273
|
this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
|
274
274
|
}
|
275
275
|
if (scene.lightsEnabled && !this.disableLighting) {
|
276
|
-
|
276
|
+
BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
|
277
277
|
}
|
278
278
|
// View
|
279
279
|
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
|
280
280
|
this._activeEffect.setMatrix("view", scene.getViewMatrix());
|
281
281
|
}
|
282
282
|
// Fog
|
283
|
-
|
283
|
+
BindFogParameters(scene, mesh, this._activeEffect);
|
284
284
|
this._afterBind(mesh, this._activeEffect, subMesh);
|
285
285
|
}
|
286
286
|
getAnimatables() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"terrainMaterial.js","sourceRoot":"","sources":["../../../../dev/materials/src/terrain/terrainMaterial.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,2CAA6B;AAE/H,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAK/C,OAAO,EAAE,eAAe,EAAE,qDAAuC;AACjE,OAAO,EAAE,cAAc,EAAE,oDAAsC;AAC/D,OAAO,EAAE,YAAY,EAAE,kDAAoC;AAC3D,OAAO,EAAE,aAAa,EAAE,mDAAqC;AAC7D,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAInD,OAAO,EAAE,KAAK,EAAE,iCAAmB;AACnC,OAAO,EAAE,aAAa,EAAE,0CA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DACJ;AAExB;IADN,gBAAgB,CAAC,kCAAkC,CAAC;qDACxB;AAGrB;IADP,kBAAkB,CAAC,cAAc,CAAC;sDACJ;AAExB;IADN,gBAAgB,CAAC,kCAAkC,CAAC;qDACxB;AAGrB;IADP,kBAAkB,CAAC,cAAc,CAAC;sDACJ;AAExB;IADN,gBAAgB,CAAC,kCAAkC,CAAC;qDACxB;AAGtB;IADN,iBAAiB,EAAE;qDACsB;AAGnC;IADN,iBAAiB,EAAE;sDACuB;AAGpC;IADN,SAAS,EAAE;sDACc;AAGlB;IADP,SAAS,CAAC,iBAAiB,CAAC;yDACI;AAE1B;IADN,gBAAgB,CAAC,gCAAgC,CAAC;wDACnB;AAGxB;IADP,SAAS,CAAC,uBAAuB,CAAC;+DACA;AAE5B;IADN,gBAAgB,CAAC,gCAAgC,CAAC;8DACd;AAuZzC,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper } from \"core/Misc/decorators\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport type { IAnimatable } from \"core/Animations/animatable.interface\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport type { IEffectCreationOptions } from \"core/Materials/effect\";\r\nimport { MaterialDefines } from \"core/Materials/materialDefines\";\r\nimport { MaterialHelper } from \"core/Materials/materialHelper\";\r\nimport { PushMaterial } from \"core/Materials/pushMaterial\";\r\nimport { MaterialFlags } from \"core/Materials/materialFlags\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\n\r\nimport \"./terrain.fragment\";\r\nimport \"./terrain.vertex\";\r\nimport { EffectFallbacks } from \"core/Materials/effectFallbacks\";\r\nimport { addClipPlaneUniforms, bindClipPlane } from \"core/Materials/clipPlaneMaterialHelper\";\r\n\r\nclass TerrainMaterialDefines extends MaterialDefines {\r\n public DIFFUSE = false;\r\n public BUMP = false;\r\n public CLIPPLANE = false;\r\n public CLIPPLANE2 = false;\r\n public CLIPPLANE3 = false;\r\n public CLIPPLANE4 = false;\r\n public CLIPPLANE5 = false;\r\n public CLIPPLANE6 = false;\r\n public ALPHATEST = false;\r\n public DEPTHPREPASS = false;\r\n public POINTSIZE = false;\r\n public FOG = false;\r\n public SPECULARTERM = false;\r\n public NORMAL = false;\r\n public UV1 = false;\r\n public UV2 = false;\r\n public VERTEXCOLOR = false;\r\n public VERTEXALPHA = false;\r\n public NUM_BONE_INFLUENCERS = 0;\r\n public BonesPerMesh = 0;\r\n public INSTANCES = false;\r\n public INSTANCESCOLOR = false;\r\n public IMAGEPROCESSINGPOSTPROCESS = false;\r\n public SKIPFINALCOLORCLAMP = false;\r\n public LOGARITHMICDEPTH = false;\r\n\r\n constructor() {\r\n super();\r\n this.rebuild();\r\n }\r\n}\r\n\r\nexport class TerrainMaterial extends PushMaterial {\r\n @serializeAsTexture(\"mixTexture\")\r\n private _mixTexture: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public mixTexture: BaseTexture;\r\n\r\n @serializeAsTexture(\"diffuseTexture1\")\r\n private _diffuseTexture1: Texture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public diffuseTexture1: Texture;\r\n\r\n @serializeAsTexture(\"diffuseTexture2\")\r\n private _diffuseTexture2: Texture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public diffuseTexture2: Texture;\r\n\r\n @serializeAsTexture(\"diffuseTexture3\")\r\n private _diffuseTexture3: Texture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public diffuseTexture3: Texture;\r\n\r\n @serializeAsTexture(\"bumpTexture1\")\r\n private _bumpTexture1: Texture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public bumpTexture1: Texture;\r\n\r\n @serializeAsTexture(\"bumpTexture2\")\r\n private _bumpTexture2: Texture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public bumpTexture2: Texture;\r\n\r\n @serializeAsTexture(\"bumpTexture3\")\r\n private _bumpTexture3: Texture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public bumpTexture3: Texture;\r\n\r\n @serializeAsColor3()\r\n public diffuseColor = new Color3(1, 1, 1);\r\n\r\n @serializeAsColor3()\r\n public specularColor = new Color3(0, 0, 0);\r\n\r\n @serialize()\r\n public specularPower = 64;\r\n\r\n @serialize(\"disableLighting\")\r\n private _disableLighting = false;\r\n @expandToProperty(\"_markAllSubMeshesAsLightsDirty\")\r\n public disableLighting: boolean;\r\n\r\n @serialize(\"maxSimultaneousLights\")\r\n private _maxSimultaneousLights = 4;\r\n @expandToProperty(\"_markAllSubMeshesAsLightsDirty\")\r\n public maxSimultaneousLights: number;\r\n\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n }\r\n\r\n public needAlphaBlending(): boolean {\r\n return this.alpha < 1.0;\r\n }\r\n\r\n public needAlphaTesting(): boolean {\r\n return false;\r\n }\r\n\r\n public getAlphaTestTexture(): Nullable<BaseTexture> {\r\n return null;\r\n }\r\n\r\n // Methods\r\n public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean {\r\n const drawWrapper = subMesh._drawWrapper;\r\n\r\n if (this.isFrozen) {\r\n if (drawWrapper.effect && drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!subMesh.materialDefines) {\r\n subMesh.materialDefines = new TerrainMaterialDefines();\r\n }\r\n\r\n const defines = <TerrainMaterialDefines>subMesh.materialDefines;\r\n const scene = this.getScene();\r\n\r\n if (this._isReadyForSubMesh(subMesh)) {\r\n return true;\r\n }\r\n\r\n const engine = scene.getEngine();\r\n\r\n // Textures\r\n if (scene.texturesEnabled) {\r\n if (!this.mixTexture || !this.mixTexture.isReady()) {\r\n return false;\r\n }\r\n\r\n defines._needUVs = true;\r\n\r\n if (MaterialFlags.DiffuseTextureEnabled) {\r\n if (!this.diffuseTexture1 || !this.diffuseTexture1.isReady()) {\r\n return false;\r\n }\r\n if (!this.diffuseTexture2 || !this.diffuseTexture2.isReady()) {\r\n return false;\r\n }\r\n if (!this.diffuseTexture3 || !this.diffuseTexture3.isReady()) {\r\n return false;\r\n }\r\n\r\n defines.DIFFUSE = true;\r\n }\r\n\r\n if (this.bumpTexture1 && this.bumpTexture2 && this.bumpTexture3 && MaterialFlags.BumpTextureEnabled) {\r\n if (!this.bumpTexture1.isReady()) {\r\n return false;\r\n }\r\n if (!this.bumpTexture2.isReady()) {\r\n return false;\r\n }\r\n if (!this.bumpTexture3.isReady()) {\r\n return false;\r\n }\r\n\r\n defines._needNormals = true;\r\n defines.BUMP = true;\r\n }\r\n }\r\n\r\n // Misc.\r\n MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);\r\n\r\n // Lights\r\n defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);\r\n\r\n // Values that need to be evaluated on every frame\r\n MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);\r\n\r\n // Attribs\r\n MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);\r\n\r\n // Get correct effect\r\n if (defines.isDirty) {\r\n defines.markAsProcessed();\r\n scene.resetCachedMaterial();\r\n\r\n // Fallbacks\r\n const fallbacks = new EffectFallbacks();\r\n if (defines.FOG) {\r\n fallbacks.addFallback(1, \"FOG\");\r\n }\r\n\r\n MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);\r\n\r\n if (defines.NUM_BONE_INFLUENCERS > 0) {\r\n fallbacks.addCPUSkinningFallback(0, mesh);\r\n }\r\n\r\n defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;\r\n\r\n //Attributes\r\n const attribs = [VertexBuffer.PositionKind];\r\n\r\n if (defines.NORMAL) {\r\n attribs.push(VertexBuffer.NormalKind);\r\n }\r\n\r\n if (defines.UV1) {\r\n attribs.push(VertexBuffer.UVKind);\r\n }\r\n\r\n if (defines.UV2) {\r\n attribs.push(VertexBuffer.UV2Kind);\r\n }\r\n\r\n if (defines.VERTEXCOLOR) {\r\n attribs.push(VertexBuffer.ColorKind);\r\n }\r\n\r\n MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);\r\n MaterialHelper.PrepareAttributesForInstances(attribs, defines);\r\n\r\n // Legacy browser patch\r\n const shaderName = \"terrain\";\r\n const join = defines.toString();\r\n const uniforms = [\r\n \"world\",\r\n \"view\",\r\n \"viewProjection\",\r\n \"vEyePosition\",\r\n \"vLightsType\",\r\n \"vDiffuseColor\",\r\n \"vSpecularColor\",\r\n \"vFogInfos\",\r\n \"vFogColor\",\r\n \"pointSize\",\r\n \"vTextureInfos\",\r\n \"mBones\",\r\n \"textureMatrix\",\r\n \"diffuse1Infos\",\r\n \"diffuse2Infos\",\r\n \"diffuse3Infos\",\r\n ];\r\n const samplers = [\r\n \"textureSampler\",\r\n \"diffuse1Sampler\",\r\n \"diffuse2Sampler\",\r\n \"diffuse3Sampler\",\r\n \"bump1Sampler\",\r\n \"bump2Sampler\",\r\n \"bump3Sampler\",\r\n \"logarithmicDepthConstant\",\r\n ];\r\n\r\n const uniformBuffers: string[] = [];\r\n\r\n addClipPlaneUniforms(uniforms);\r\n\r\n MaterialHelper.PrepareUniformsAndSamplersList(<IEffectCreationOptions>{\r\n uniformsNames: uniforms,\r\n uniformBuffersNames: uniformBuffers,\r\n samplers: samplers,\r\n defines: defines,\r\n maxSimultaneousLights: this.maxSimultaneousLights,\r\n });\r\n\r\n subMesh.setEffect(\r\n scene.getEngine().createEffect(\r\n shaderName,\r\n <IEffectCreationOptions>{\r\n attributes: attribs,\r\n uniformsNames: uniforms,\r\n uniformBuffersNames: uniformBuffers,\r\n samplers: samplers,\r\n defines: join,\r\n fallbacks: fallbacks,\r\n onCompiled: this.onCompiled,\r\n onError: this.onError,\r\n indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },\r\n },\r\n engine\r\n ),\r\n defines,\r\n this._materialContext\r\n );\r\n }\r\n if (!subMesh.effect || !subMesh.effect.isReady()) {\r\n return false;\r\n }\r\n\r\n defines._renderId = scene.getRenderId();\r\n drawWrapper._wasPreviouslyReady = true;\r\n drawWrapper._wasPreviouslyUsingInstances = !!useInstances;\r\n\r\n return true;\r\n }\r\n\r\n public bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {\r\n const scene = this.getScene();\r\n\r\n const defines = <TerrainMaterialDefines>subMesh.materialDefines;\r\n if (!defines) {\r\n return;\r\n }\r\n\r\n const effect = subMesh.effect;\r\n if (!effect) {\r\n return;\r\n }\r\n this._activeEffect = effect;\r\n\r\n // Matrices\r\n this.bindOnlyWorldMatrix(world);\r\n this._activeEffect.setMatrix(\"viewProjection\", scene.getTransformMatrix());\r\n\r\n // Bones\r\n MaterialHelper.BindBonesParameters(mesh, this._activeEffect);\r\n\r\n if (this._mustRebind(scene, effect, subMesh)) {\r\n // Textures\r\n if (this.mixTexture) {\r\n this._activeEffect.setTexture(\"textureSampler\", this._mixTexture);\r\n this._activeEffect.setFloat2(\"vTextureInfos\", this._mixTexture.coordinatesIndex, this._mixTexture.level);\r\n this._activeEffect.setMatrix(\"textureMatrix\", this._mixTexture.getTextureMatrix());\r\n\r\n if (MaterialFlags.DiffuseTextureEnabled) {\r\n if (this._diffuseTexture1) {\r\n this._activeEffect.setTexture(\"diffuse1Sampler\", this._diffuseTexture1);\r\n this._activeEffect.setFloat2(\"diffuse1Infos\", this._diffuseTexture1.uScale, this._diffuseTexture1.vScale);\r\n }\r\n if (this._diffuseTexture2) {\r\n this._activeEffect.setTexture(\"diffuse2Sampler\", this._diffuseTexture2);\r\n this._activeEffect.setFloat2(\"diffuse2Infos\", this._diffuseTexture2.uScale, this._diffuseTexture2.vScale);\r\n }\r\n if (this._diffuseTexture3) {\r\n this._activeEffect.setTexture(\"diffuse3Sampler\", this._diffuseTexture3);\r\n this._activeEffect.setFloat2(\"diffuse3Infos\", this._diffuseTexture3.uScale, this._diffuseTexture3.vScale);\r\n }\r\n }\r\n\r\n if (MaterialFlags.BumpTextureEnabled && scene.getEngine().getCaps().standardDerivatives) {\r\n if (this._bumpTexture1) {\r\n this._activeEffect.setTexture(\"bump1Sampler\", this._bumpTexture1);\r\n }\r\n if (this._bumpTexture2) {\r\n this._activeEffect.setTexture(\"bump2Sampler\", this._bumpTexture2);\r\n }\r\n if (this._bumpTexture3) {\r\n this._activeEffect.setTexture(\"bump3Sampler\", this._bumpTexture3);\r\n }\r\n }\r\n }\r\n // Clip plane\r\n bindClipPlane(effect, this, scene);\r\n\r\n // Point size\r\n if (this.pointsCloud) {\r\n this._activeEffect.setFloat(\"pointSize\", this.pointSize);\r\n }\r\n\r\n // Log. depth\r\n if (this._useLogarithmicDepth) {\r\n MaterialHelper.BindLogDepth(defines, effect, scene);\r\n }\r\n\r\n scene.bindEyePosition(effect);\r\n }\r\n\r\n this._activeEffect.setColor4(\"vDiffuseColor\", this.diffuseColor, this.alpha * mesh.visibility);\r\n\r\n if (defines.SPECULARTERM) {\r\n this._activeEffect.setColor4(\"vSpecularColor\", this.specularColor, this.specularPower);\r\n }\r\n\r\n if (scene.lightsEnabled && !this.disableLighting) {\r\n MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);\r\n }\r\n\r\n // View\r\n if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {\r\n this._activeEffect.setMatrix(\"view\", scene.getViewMatrix());\r\n }\r\n\r\n // Fog\r\n MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);\r\n\r\n this._afterBind(mesh, this._activeEffect, subMesh);\r\n }\r\n\r\n public getAnimatables(): IAnimatable[] {\r\n const results = [];\r\n\r\n if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {\r\n results.push(this.mixTexture);\r\n }\r\n\r\n return results;\r\n }\r\n\r\n public getActiveTextures(): BaseTexture[] {\r\n const activeTextures = super.getActiveTextures();\r\n\r\n if (this._mixTexture) {\r\n activeTextures.push(this._mixTexture);\r\n }\r\n\r\n if (this._diffuseTexture1) {\r\n activeTextures.push(this._diffuseTexture1);\r\n }\r\n\r\n if (this._diffuseTexture2) {\r\n activeTextures.push(this._diffuseTexture2);\r\n }\r\n\r\n if (this._diffuseTexture3) {\r\n activeTextures.push(this._diffuseTexture3);\r\n }\r\n\r\n if (this._bumpTexture1) {\r\n activeTextures.push(this._bumpTexture1);\r\n }\r\n\r\n if (this._bumpTexture2) {\r\n activeTextures.push(this._bumpTexture2);\r\n }\r\n\r\n if (this._bumpTexture3) {\r\n activeTextures.push(this._bumpTexture3);\r\n }\r\n\r\n return activeTextures;\r\n }\r\n\r\n public hasTexture(texture: BaseTexture): boolean {\r\n if (super.hasTexture(texture)) {\r\n return true;\r\n }\r\n\r\n if (this._mixTexture === texture) {\r\n return true;\r\n }\r\n\r\n if (this._diffuseTexture1 === texture) {\r\n return true;\r\n }\r\n\r\n if (this._diffuseTexture2 === texture) {\r\n return true;\r\n }\r\n\r\n if (this._diffuseTexture3 === texture) {\r\n return true;\r\n }\r\n\r\n if (this._bumpTexture1 === texture) {\r\n return true;\r\n }\r\n\r\n if (this._bumpTexture2 === texture) {\r\n return true;\r\n }\r\n\r\n if (this._bumpTexture3 === texture) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n public dispose(forceDisposeEffect?: boolean): void {\r\n if (this.mixTexture) {\r\n this.mixTexture.dispose();\r\n }\r\n\r\n super.dispose(forceDisposeEffect);\r\n }\r\n\r\n public clone(name: string): TerrainMaterial {\r\n return SerializationHelper.Clone(() => new TerrainMaterial(name, this.getScene()), this);\r\n }\r\n\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.customType = \"BABYLON.TerrainMaterial\";\r\n return serializationObject;\r\n }\r\n\r\n public getClassName(): string {\r\n return \"TerrainMaterial\";\r\n }\r\n\r\n // Statics\r\n public static Parse(source: any, scene: Scene, rootUrl: string): TerrainMaterial {\r\n return SerializationHelper.Parse(() => new TerrainMaterial(source.name, scene), source, scene, rootUrl);\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.TerrainMaterial\", TerrainMaterial);\r\n"]}
|
1
|
+
{"version":3,"file":"terrainMaterial.js","sourceRoot":"","sources":["../../../../dev/materials/src/terrain/terrainMaterial.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,2CAA6B;AAE/H,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAK/C,OAAO,EAAE,eAAe,EAAE,qDAAuC;AACjE,OAAO,EAAE,YAAY,EAAE,kDAAoC;AAC3D,OAAO,EAAE,aAAa,EAAE,mDAAqC;AAC7D,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAInD,OAAO,EAAE,KAAK,EAAE,iCAAmB;AACnC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,oBAAoB,CAAC;AAC5B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,qDAAuC;AACjE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,6DAA+C;AAC7F,OAAO,EACH,mBAAm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kCAAkC,CAAC;qDACxB;AAGrB;IADP,kBAAkB,CAAC,cAAc,CAAC;sDACJ;AAExB;IADN,gBAAgB,CAAC,kCAAkC,CAAC;qDACxB;AAGtB;IADN,iBAAiB,EAAE;qDACsB;AAGnC;IADN,iBAAiB,EAAE;sDACuB;AAGpC;IADN,SAAS,EAAE;sDACc;AAGlB;IADP,SAAS,CAAC,iBAAiB,CAAC;yDACI;AAE1B;IADN,gBAAgB,CAAC,gCAAgC,CAAC;wDACnB;AAGxB;IADP,SAAS,CAAC,uBAAuB,CAAC;+DACA;AAE5B;IADN,gBAAgB,CAAC,gCAAgC,CAAC;8DACd;AAuZzC,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper } from \"core/Misc/decorators\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport type { IAnimatable } from \"core/Animations/animatable.interface\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport type { IEffectCreationOptions } from \"core/Materials/effect\";\r\nimport { MaterialDefines } from \"core/Materials/materialDefines\";\r\nimport { PushMaterial } from \"core/Materials/pushMaterial\";\r\nimport { MaterialFlags } from \"core/Materials/materialFlags\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\n\r\nimport \"./terrain.fragment\";\r\nimport \"./terrain.vertex\";\r\nimport { EffectFallbacks } from \"core/Materials/effectFallbacks\";\r\nimport { addClipPlaneUniforms, bindClipPlane } from \"core/Materials/clipPlaneMaterialHelper\";\r\nimport {\r\n BindBonesParameters,\r\n BindFogParameters,\r\n BindLights,\r\n BindLogDepth,\r\n HandleFallbacksForShadows,\r\n PrepareAttributesForBones,\r\n PrepareAttributesForInstances,\r\n PrepareDefinesForAttributes,\r\n PrepareDefinesForFrameBoundValues,\r\n PrepareDefinesForLights,\r\n PrepareDefinesForMisc,\r\n PrepareUniformsAndSamplersList,\r\n} from \"core/Materials/materialHelper.functions\";\r\n\r\nclass TerrainMaterialDefines extends MaterialDefines {\r\n public DIFFUSE = false;\r\n public BUMP = false;\r\n public CLIPPLANE = false;\r\n public CLIPPLANE2 = false;\r\n public CLIPPLANE3 = false;\r\n public CLIPPLANE4 = false;\r\n public CLIPPLANE5 = false;\r\n public CLIPPLANE6 = false;\r\n public ALPHATEST = false;\r\n public DEPTHPREPASS = false;\r\n public POINTSIZE = false;\r\n public FOG = false;\r\n public SPECULARTERM = false;\r\n public NORMAL = false;\r\n public UV1 = false;\r\n public UV2 = false;\r\n public VERTEXCOLOR = false;\r\n public VERTEXALPHA = false;\r\n public NUM_BONE_INFLUENCERS = 0;\r\n public BonesPerMesh = 0;\r\n public INSTANCES = false;\r\n public INSTANCESCOLOR = false;\r\n public IMAGEPROCESSINGPOSTPROCESS = false;\r\n public SKIPFINALCOLORCLAMP = false;\r\n public LOGARITHMICDEPTH = false;\r\n\r\n constructor() {\r\n super();\r\n this.rebuild();\r\n }\r\n}\r\n\r\nexport class TerrainMaterial extends PushMaterial {\r\n @serializeAsTexture(\"mixTexture\")\r\n private _mixTexture: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public mixTexture: BaseTexture;\r\n\r\n @serializeAsTexture(\"diffuseTexture1\")\r\n private _diffuseTexture1: Texture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public diffuseTexture1: Texture;\r\n\r\n @serializeAsTexture(\"diffuseTexture2\")\r\n private _diffuseTexture2: Texture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public diffuseTexture2: Texture;\r\n\r\n @serializeAsTexture(\"diffuseTexture3\")\r\n private _diffuseTexture3: Texture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public diffuseTexture3: Texture;\r\n\r\n @serializeAsTexture(\"bumpTexture1\")\r\n private _bumpTexture1: Texture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public bumpTexture1: Texture;\r\n\r\n @serializeAsTexture(\"bumpTexture2\")\r\n private _bumpTexture2: Texture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public bumpTexture2: Texture;\r\n\r\n @serializeAsTexture(\"bumpTexture3\")\r\n private _bumpTexture3: Texture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public bumpTexture3: Texture;\r\n\r\n @serializeAsColor3()\r\n public diffuseColor = new Color3(1, 1, 1);\r\n\r\n @serializeAsColor3()\r\n public specularColor = new Color3(0, 0, 0);\r\n\r\n @serialize()\r\n public specularPower = 64;\r\n\r\n @serialize(\"disableLighting\")\r\n private _disableLighting = false;\r\n @expandToProperty(\"_markAllSubMeshesAsLightsDirty\")\r\n public disableLighting: boolean;\r\n\r\n @serialize(\"maxSimultaneousLights\")\r\n private _maxSimultaneousLights = 4;\r\n @expandToProperty(\"_markAllSubMeshesAsLightsDirty\")\r\n public maxSimultaneousLights: number;\r\n\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n }\r\n\r\n public needAlphaBlending(): boolean {\r\n return this.alpha < 1.0;\r\n }\r\n\r\n public needAlphaTesting(): boolean {\r\n return false;\r\n }\r\n\r\n public getAlphaTestTexture(): Nullable<BaseTexture> {\r\n return null;\r\n }\r\n\r\n // Methods\r\n public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean {\r\n const drawWrapper = subMesh._drawWrapper;\r\n\r\n if (this.isFrozen) {\r\n if (drawWrapper.effect && drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!subMesh.materialDefines) {\r\n subMesh.materialDefines = new TerrainMaterialDefines();\r\n }\r\n\r\n const defines = <TerrainMaterialDefines>subMesh.materialDefines;\r\n const scene = this.getScene();\r\n\r\n if (this._isReadyForSubMesh(subMesh)) {\r\n return true;\r\n }\r\n\r\n const engine = scene.getEngine();\r\n\r\n // Textures\r\n if (scene.texturesEnabled) {\r\n if (!this.mixTexture || !this.mixTexture.isReady()) {\r\n return false;\r\n }\r\n\r\n defines._needUVs = true;\r\n\r\n if (MaterialFlags.DiffuseTextureEnabled) {\r\n if (!this.diffuseTexture1 || !this.diffuseTexture1.isReady()) {\r\n return false;\r\n }\r\n if (!this.diffuseTexture2 || !this.diffuseTexture2.isReady()) {\r\n return false;\r\n }\r\n if (!this.diffuseTexture3 || !this.diffuseTexture3.isReady()) {\r\n return false;\r\n }\r\n\r\n defines.DIFFUSE = true;\r\n }\r\n\r\n if (this.bumpTexture1 && this.bumpTexture2 && this.bumpTexture3 && MaterialFlags.BumpTextureEnabled) {\r\n if (!this.bumpTexture1.isReady()) {\r\n return false;\r\n }\r\n if (!this.bumpTexture2.isReady()) {\r\n return false;\r\n }\r\n if (!this.bumpTexture3.isReady()) {\r\n return false;\r\n }\r\n\r\n defines._needNormals = true;\r\n defines.BUMP = true;\r\n }\r\n }\r\n\r\n // Misc.\r\n PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);\r\n\r\n // Lights\r\n defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);\r\n\r\n // Values that need to be evaluated on every frame\r\n PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);\r\n\r\n // Attribs\r\n PrepareDefinesForAttributes(mesh, defines, true, true);\r\n\r\n // Get correct effect\r\n if (defines.isDirty) {\r\n defines.markAsProcessed();\r\n scene.resetCachedMaterial();\r\n\r\n // Fallbacks\r\n const fallbacks = new EffectFallbacks();\r\n if (defines.FOG) {\r\n fallbacks.addFallback(1, \"FOG\");\r\n }\r\n\r\n HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);\r\n\r\n if (defines.NUM_BONE_INFLUENCERS > 0) {\r\n fallbacks.addCPUSkinningFallback(0, mesh);\r\n }\r\n\r\n defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;\r\n\r\n //Attributes\r\n const attribs = [VertexBuffer.PositionKind];\r\n\r\n if (defines.NORMAL) {\r\n attribs.push(VertexBuffer.NormalKind);\r\n }\r\n\r\n if (defines.UV1) {\r\n attribs.push(VertexBuffer.UVKind);\r\n }\r\n\r\n if (defines.UV2) {\r\n attribs.push(VertexBuffer.UV2Kind);\r\n }\r\n\r\n if (defines.VERTEXCOLOR) {\r\n attribs.push(VertexBuffer.ColorKind);\r\n }\r\n\r\n PrepareAttributesForBones(attribs, mesh, defines, fallbacks);\r\n PrepareAttributesForInstances(attribs, defines);\r\n\r\n // Legacy browser patch\r\n const shaderName = \"terrain\";\r\n const join = defines.toString();\r\n const uniforms = [\r\n \"world\",\r\n \"view\",\r\n \"viewProjection\",\r\n \"vEyePosition\",\r\n \"vLightsType\",\r\n \"vDiffuseColor\",\r\n \"vSpecularColor\",\r\n \"vFogInfos\",\r\n \"vFogColor\",\r\n \"pointSize\",\r\n \"vTextureInfos\",\r\n \"mBones\",\r\n \"textureMatrix\",\r\n \"diffuse1Infos\",\r\n \"diffuse2Infos\",\r\n \"diffuse3Infos\",\r\n ];\r\n const samplers = [\r\n \"textureSampler\",\r\n \"diffuse1Sampler\",\r\n \"diffuse2Sampler\",\r\n \"diffuse3Sampler\",\r\n \"bump1Sampler\",\r\n \"bump2Sampler\",\r\n \"bump3Sampler\",\r\n \"logarithmicDepthConstant\",\r\n ];\r\n\r\n const uniformBuffers: string[] = [];\r\n\r\n addClipPlaneUniforms(uniforms);\r\n\r\n PrepareUniformsAndSamplersList(<IEffectCreationOptions>{\r\n uniformsNames: uniforms,\r\n uniformBuffersNames: uniformBuffers,\r\n samplers: samplers,\r\n defines: defines,\r\n maxSimultaneousLights: this.maxSimultaneousLights,\r\n });\r\n\r\n subMesh.setEffect(\r\n scene.getEngine().createEffect(\r\n shaderName,\r\n <IEffectCreationOptions>{\r\n attributes: attribs,\r\n uniformsNames: uniforms,\r\n uniformBuffersNames: uniformBuffers,\r\n samplers: samplers,\r\n defines: join,\r\n fallbacks: fallbacks,\r\n onCompiled: this.onCompiled,\r\n onError: this.onError,\r\n indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },\r\n },\r\n engine\r\n ),\r\n defines,\r\n this._materialContext\r\n );\r\n }\r\n if (!subMesh.effect || !subMesh.effect.isReady()) {\r\n return false;\r\n }\r\n\r\n defines._renderId = scene.getRenderId();\r\n drawWrapper._wasPreviouslyReady = true;\r\n drawWrapper._wasPreviouslyUsingInstances = !!useInstances;\r\n\r\n return true;\r\n }\r\n\r\n public bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {\r\n const scene = this.getScene();\r\n\r\n const defines = <TerrainMaterialDefines>subMesh.materialDefines;\r\n if (!defines) {\r\n return;\r\n }\r\n\r\n const effect = subMesh.effect;\r\n if (!effect) {\r\n return;\r\n }\r\n this._activeEffect = effect;\r\n\r\n // Matrices\r\n this.bindOnlyWorldMatrix(world);\r\n this._activeEffect.setMatrix(\"viewProjection\", scene.getTransformMatrix());\r\n\r\n // Bones\r\n BindBonesParameters(mesh, this._activeEffect);\r\n\r\n if (this._mustRebind(scene, effect, subMesh)) {\r\n // Textures\r\n if (this.mixTexture) {\r\n this._activeEffect.setTexture(\"textureSampler\", this._mixTexture);\r\n this._activeEffect.setFloat2(\"vTextureInfos\", this._mixTexture.coordinatesIndex, this._mixTexture.level);\r\n this._activeEffect.setMatrix(\"textureMatrix\", this._mixTexture.getTextureMatrix());\r\n\r\n if (MaterialFlags.DiffuseTextureEnabled) {\r\n if (this._diffuseTexture1) {\r\n this._activeEffect.setTexture(\"diffuse1Sampler\", this._diffuseTexture1);\r\n this._activeEffect.setFloat2(\"diffuse1Infos\", this._diffuseTexture1.uScale, this._diffuseTexture1.vScale);\r\n }\r\n if (this._diffuseTexture2) {\r\n this._activeEffect.setTexture(\"diffuse2Sampler\", this._diffuseTexture2);\r\n this._activeEffect.setFloat2(\"diffuse2Infos\", this._diffuseTexture2.uScale, this._diffuseTexture2.vScale);\r\n }\r\n if (this._diffuseTexture3) {\r\n this._activeEffect.setTexture(\"diffuse3Sampler\", this._diffuseTexture3);\r\n this._activeEffect.setFloat2(\"diffuse3Infos\", this._diffuseTexture3.uScale, this._diffuseTexture3.vScale);\r\n }\r\n }\r\n\r\n if (MaterialFlags.BumpTextureEnabled && scene.getEngine().getCaps().standardDerivatives) {\r\n if (this._bumpTexture1) {\r\n this._activeEffect.setTexture(\"bump1Sampler\", this._bumpTexture1);\r\n }\r\n if (this._bumpTexture2) {\r\n this._activeEffect.setTexture(\"bump2Sampler\", this._bumpTexture2);\r\n }\r\n if (this._bumpTexture3) {\r\n this._activeEffect.setTexture(\"bump3Sampler\", this._bumpTexture3);\r\n }\r\n }\r\n }\r\n // Clip plane\r\n bindClipPlane(effect, this, scene);\r\n\r\n // Point size\r\n if (this.pointsCloud) {\r\n this._activeEffect.setFloat(\"pointSize\", this.pointSize);\r\n }\r\n\r\n // Log. depth\r\n if (this._useLogarithmicDepth) {\r\n BindLogDepth(defines, effect, scene);\r\n }\r\n\r\n scene.bindEyePosition(effect);\r\n }\r\n\r\n this._activeEffect.setColor4(\"vDiffuseColor\", this.diffuseColor, this.alpha * mesh.visibility);\r\n\r\n if (defines.SPECULARTERM) {\r\n this._activeEffect.setColor4(\"vSpecularColor\", this.specularColor, this.specularPower);\r\n }\r\n\r\n if (scene.lightsEnabled && !this.disableLighting) {\r\n BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);\r\n }\r\n\r\n // View\r\n if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {\r\n this._activeEffect.setMatrix(\"view\", scene.getViewMatrix());\r\n }\r\n\r\n // Fog\r\n BindFogParameters(scene, mesh, this._activeEffect);\r\n\r\n this._afterBind(mesh, this._activeEffect, subMesh);\r\n }\r\n\r\n public getAnimatables(): IAnimatable[] {\r\n const results = [];\r\n\r\n if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {\r\n results.push(this.mixTexture);\r\n }\r\n\r\n return results;\r\n }\r\n\r\n public getActiveTextures(): BaseTexture[] {\r\n const activeTextures = super.getActiveTextures();\r\n\r\n if (this._mixTexture) {\r\n activeTextures.push(this._mixTexture);\r\n }\r\n\r\n if (this._diffuseTexture1) {\r\n activeTextures.push(this._diffuseTexture1);\r\n }\r\n\r\n if (this._diffuseTexture2) {\r\n activeTextures.push(this._diffuseTexture2);\r\n }\r\n\r\n if (this._diffuseTexture3) {\r\n activeTextures.push(this._diffuseTexture3);\r\n }\r\n\r\n if (this._bumpTexture1) {\r\n activeTextures.push(this._bumpTexture1);\r\n }\r\n\r\n if (this._bumpTexture2) {\r\n activeTextures.push(this._bumpTexture2);\r\n }\r\n\r\n if (this._bumpTexture3) {\r\n activeTextures.push(this._bumpTexture3);\r\n }\r\n\r\n return activeTextures;\r\n }\r\n\r\n public hasTexture(texture: BaseTexture): boolean {\r\n if (super.hasTexture(texture)) {\r\n return true;\r\n }\r\n\r\n if (this._mixTexture === texture) {\r\n return true;\r\n }\r\n\r\n if (this._diffuseTexture1 === texture) {\r\n return true;\r\n }\r\n\r\n if (this._diffuseTexture2 === texture) {\r\n return true;\r\n }\r\n\r\n if (this._diffuseTexture3 === texture) {\r\n return true;\r\n }\r\n\r\n if (this._bumpTexture1 === texture) {\r\n return true;\r\n }\r\n\r\n if (this._bumpTexture2 === texture) {\r\n return true;\r\n }\r\n\r\n if (this._bumpTexture3 === texture) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n public dispose(forceDisposeEffect?: boolean): void {\r\n if (this.mixTexture) {\r\n this.mixTexture.dispose();\r\n }\r\n\r\n super.dispose(forceDisposeEffect);\r\n }\r\n\r\n public clone(name: string): TerrainMaterial {\r\n return SerializationHelper.Clone(() => new TerrainMaterial(name, this.getScene()), this);\r\n }\r\n\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.customType = \"BABYLON.TerrainMaterial\";\r\n return serializationObject;\r\n }\r\n\r\n public getClassName(): string {\r\n return \"TerrainMaterial\";\r\n }\r\n\r\n // Statics\r\n public static Parse(source: any, scene: Scene, rootUrl: string): TerrainMaterial {\r\n return SerializationHelper.Parse(() => new TerrainMaterial(source.name, scene), source, scene, rootUrl);\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.TerrainMaterial\", TerrainMaterial);\r\n"]}
|
@@ -2,7 +2,6 @@ import { __decorate } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
3
3
|
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
4
4
|
import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
|
5
|
-
import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
|
6
5
|
import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
|
7
6
|
import { MaterialFlags } from "@babylonjs/core/Materials/materialFlags.js";
|
8
7
|
import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
@@ -12,6 +11,7 @@ import "./triplanar.fragment.js";
|
|
12
11
|
import "./triplanar.vertex.js";
|
13
12
|
import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
|
14
13
|
import { addClipPlaneUniforms, bindClipPlane } from "@babylonjs/core/Materials/clipPlaneMaterialHelper.js";
|
14
|
+
import { BindBonesParameters, BindFogParameters, BindLights, BindLogDepth, HandleFallbacksForShadows, PrepareAttributesForBones, PrepareAttributesForInstances, PrepareDefinesForAttributes, PrepareDefinesForFrameBoundValues, PrepareDefinesForLights, PrepareDefinesForMisc, PrepareUniformsAndSamplersList, } from "@babylonjs/core/Materials/materialHelper.functions.js";
|
15
15
|
class TriPlanarMaterialDefines extends MaterialDefines {
|
16
16
|
constructor() {
|
17
17
|
super();
|
@@ -116,13 +116,13 @@ export class TriPlanarMaterial extends PushMaterial {
|
|
116
116
|
}
|
117
117
|
}
|
118
118
|
// Misc.
|
119
|
-
|
119
|
+
PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
|
120
120
|
// Lights
|
121
|
-
defines._needNormals =
|
121
|
+
defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
|
122
122
|
// Values that need to be evaluated on every frame
|
123
|
-
|
123
|
+
PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);
|
124
124
|
// Attribs
|
125
|
-
|
125
|
+
PrepareDefinesForAttributes(mesh, defines, true, true);
|
126
126
|
// Get correct effect
|
127
127
|
if (defines.isDirty) {
|
128
128
|
defines.markAsProcessed();
|
@@ -132,7 +132,7 @@ export class TriPlanarMaterial extends PushMaterial {
|
|
132
132
|
if (defines.FOG) {
|
133
133
|
fallbacks.addFallback(1, "FOG");
|
134
134
|
}
|
135
|
-
|
135
|
+
HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
|
136
136
|
if (defines.NUM_BONE_INFLUENCERS > 0) {
|
137
137
|
fallbacks.addCPUSkinningFallback(0, mesh);
|
138
138
|
}
|
@@ -145,8 +145,8 @@ export class TriPlanarMaterial extends PushMaterial {
|
|
145
145
|
if (defines.VERTEXCOLOR) {
|
146
146
|
attribs.push(VertexBuffer.ColorKind);
|
147
147
|
}
|
148
|
-
|
149
|
-
|
148
|
+
PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
149
|
+
PrepareAttributesForInstances(attribs, defines);
|
150
150
|
// Legacy browser patch
|
151
151
|
const shaderName = "triplanar";
|
152
152
|
const join = defines.toString();
|
@@ -167,7 +167,7 @@ export class TriPlanarMaterial extends PushMaterial {
|
|
167
167
|
const samplers = ["diffuseSamplerX", "diffuseSamplerY", "diffuseSamplerZ", "normalSamplerX", "normalSamplerY", "normalSamplerZ", "logarithmicDepthConstant"];
|
168
168
|
const uniformBuffers = [];
|
169
169
|
addClipPlaneUniforms(uniforms);
|
170
|
-
|
170
|
+
PrepareUniformsAndSamplersList({
|
171
171
|
uniformsNames: uniforms,
|
172
172
|
uniformBuffersNames: uniformBuffers,
|
173
173
|
samplers: samplers,
|
@@ -209,7 +209,7 @@ export class TriPlanarMaterial extends PushMaterial {
|
|
209
209
|
this.bindOnlyWorldMatrix(world);
|
210
210
|
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
211
211
|
// Bones
|
212
|
-
|
212
|
+
BindBonesParameters(mesh, this._activeEffect);
|
213
213
|
this._activeEffect.setFloat("tileSize", this.tileSize);
|
214
214
|
if (this._mustRebind(scene, effect, subMesh)) {
|
215
215
|
// Textures
|
@@ -239,7 +239,7 @@ export class TriPlanarMaterial extends PushMaterial {
|
|
239
239
|
}
|
240
240
|
// Log. depth
|
241
241
|
if (this._useLogarithmicDepth) {
|
242
|
-
|
242
|
+
BindLogDepth(defines, effect, scene);
|
243
243
|
}
|
244
244
|
scene.bindEyePosition(effect);
|
245
245
|
}
|
@@ -248,14 +248,14 @@ export class TriPlanarMaterial extends PushMaterial {
|
|
248
248
|
this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
|
249
249
|
}
|
250
250
|
if (scene.lightsEnabled && !this.disableLighting) {
|
251
|
-
|
251
|
+
BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
|
252
252
|
}
|
253
253
|
// View
|
254
254
|
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
|
255
255
|
this._activeEffect.setMatrix("view", scene.getViewMatrix());
|
256
256
|
}
|
257
257
|
// Fog
|
258
|
-
|
258
|
+
BindFogParameters(scene, mesh, this._activeEffect);
|
259
259
|
this._afterBind(mesh, this._activeEffect, subMesh);
|
260
260
|
}
|
261
261
|
getAnimatables() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"triPlanarMaterial.js","sourceRoot":"","sources":["../../../../dev/materials/src/triPlanar/triPlanarMaterial.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,2CAA6B;AAE/H,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAK/C,OAAO,EAAE,eAAe,EAAE,qDAAuC;AACjE,OAAO,EAAE,cAAc,EAAE,oDAAsC;AAC/D,OAAO,EAAE,YAAY,EAAE,kDAAoC;AAC3D,OAAO,EAAE,aAAa,EAAE,mDAAqC;AAC7D,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAInD,OAAO,EAAE,KAAK,EAAE,iCAAmB;AACnC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,sBAAsB,CAAC;AAC9B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,qDAAuC;AACjE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,6DAA+C;AAE7F,MAAM,wBAAyB,SAAQ,eAAe;IAgClD;QACI,KAAK,EAAE,CAAC;QAhCL,aAAQ,GAAG,KAAK,CAAC;QACjB,aAAQ,GAAG,KAAK,CAAC;QACjB,aAAQ,GAAG,KAAK,CAAC;QAEjB,UAAK,GAAG,KAAK,CAAC;QACd,UAAK,GAAG,KAAK,CAAC;QACd,UAAK,GAAG,KAAK,CAAC;QAEd,cAAS,GAAG,KAAK,CAAC;QAClB,eAAU,GAAG,KAAK,C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,CAAC,iBAAiB,CAAC;2DACI;AAE1B;IADN,gBAAgB,CAAC,gCAAgC,CAAC;0DACnB;AAGxB;IADP,SAAS,CAAC,uBAAuB,CAAC;iEACA;AAE5B;IADN,gBAAgB,CAAC,gCAAgC,CAAC;gEACd;AAyWzC,aAAa,CAAC,2BAA2B,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper } from \"core/Misc/decorators\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\n\r\nimport type { IAnimatable } from \"core/Animations/animatable.interface\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { IEffectCreationOptions } from \"core/Materials/effect\";\r\nimport { MaterialDefines } from \"core/Materials/materialDefines\";\r\nimport { MaterialHelper } from \"core/Materials/materialHelper\";\r\nimport { PushMaterial } from \"core/Materials/pushMaterial\";\r\nimport { MaterialFlags } from \"core/Materials/materialFlags\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\n\r\nimport \"./triplanar.fragment\";\r\nimport \"./triplanar.vertex\";\r\nimport { EffectFallbacks } from \"core/Materials/effectFallbacks\";\r\nimport { addClipPlaneUniforms, bindClipPlane } from \"core/Materials/clipPlaneMaterialHelper\";\r\n\r\nclass TriPlanarMaterialDefines extends MaterialDefines {\r\n public DIFFUSEX = false;\r\n public DIFFUSEY = false;\r\n public DIFFUSEZ = false;\r\n\r\n public BUMPX = false;\r\n public BUMPY = false;\r\n public BUMPZ = false;\r\n\r\n public CLIPPLANE = false;\r\n public CLIPPLANE2 = false;\r\n public CLIPPLANE3 = false;\r\n public CLIPPLANE4 = false;\r\n public CLIPPLANE5 = false;\r\n public CLIPPLANE6 = false;\r\n public ALPHATEST = false;\r\n public DEPTHPREPASS = false;\r\n public POINTSIZE = false;\r\n public FOG = false;\r\n public SPECULARTERM = false;\r\n public NORMAL = false;\r\n public VERTEXCOLOR = false;\r\n public VERTEXALPHA = false;\r\n public NUM_BONE_INFLUENCERS = 0;\r\n public BonesPerMesh = 0;\r\n public INSTANCES = false;\r\n public INSTANCESCOLOR = false;\r\n public IMAGEPROCESSINGPOSTPROCESS = false;\r\n public SKIPFINALCOLORCLAMP = false;\r\n public NONUNIFORMSCALING = false;\r\n public LOGARITHMICDEPTH = false;\r\n\r\n constructor() {\r\n super();\r\n this.rebuild();\r\n }\r\n}\r\n\r\nexport class TriPlanarMaterial extends PushMaterial {\r\n @serializeAsTexture()\r\n public mixTexture: BaseTexture;\r\n\r\n @serializeAsTexture(\"diffuseTextureX\")\r\n private _diffuseTextureX: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public diffuseTextureX: BaseTexture;\r\n\r\n @serializeAsTexture(\"diffuseTexturY\")\r\n private _diffuseTextureY: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public diffuseTextureY: BaseTexture;\r\n\r\n @serializeAsTexture(\"diffuseTextureZ\")\r\n private _diffuseTextureZ: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public diffuseTextureZ: BaseTexture;\r\n\r\n @serializeAsTexture(\"normalTextureX\")\r\n private _normalTextureX: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public normalTextureX: BaseTexture;\r\n\r\n @serializeAsTexture(\"normalTextureY\")\r\n private _normalTextureY: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public normalTextureY: BaseTexture;\r\n\r\n @serializeAsTexture(\"normalTextureZ\")\r\n private _normalTextureZ: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public normalTextureZ: BaseTexture;\r\n\r\n @serialize()\r\n public tileSize: number = 1;\r\n\r\n @serializeAsColor3()\r\n public diffuseColor = new Color3(1, 1, 1);\r\n\r\n @serializeAsColor3()\r\n public specularColor = new Color3(0.2, 0.2, 0.2);\r\n\r\n @serialize()\r\n public specularPower = 64;\r\n\r\n @serialize(\"disableLighting\")\r\n private _disableLighting = false;\r\n @expandToProperty(\"_markAllSubMeshesAsLightsDirty\")\r\n public disableLighting: boolean;\r\n\r\n @serialize(\"maxSimultaneousLights\")\r\n private _maxSimultaneousLights = 4;\r\n @expandToProperty(\"_markAllSubMeshesAsLightsDirty\")\r\n public maxSimultaneousLights: number;\r\n\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n }\r\n\r\n public needAlphaBlending(): boolean {\r\n return this.alpha < 1.0;\r\n }\r\n\r\n public needAlphaTesting(): boolean {\r\n return false;\r\n }\r\n\r\n public getAlphaTestTexture(): Nullable<BaseTexture> {\r\n return null;\r\n }\r\n\r\n // Methods\r\n public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean {\r\n const drawWrapper = subMesh._drawWrapper;\r\n\r\n if (this.isFrozen) {\r\n if (drawWrapper.effect && drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!subMesh.materialDefines) {\r\n subMesh.materialDefines = new TriPlanarMaterialDefines();\r\n }\r\n\r\n const defines = <TriPlanarMaterialDefines>subMesh.materialDefines;\r\n const scene = this.getScene();\r\n\r\n if (this._isReadyForSubMesh(subMesh)) {\r\n return true;\r\n }\r\n\r\n const engine = scene.getEngine();\r\n\r\n // Textures\r\n if (defines._areTexturesDirty) {\r\n if (scene.texturesEnabled) {\r\n if (MaterialFlags.DiffuseTextureEnabled) {\r\n const textures = [this.diffuseTextureX, this.diffuseTextureY, this.diffuseTextureZ];\r\n const textureDefines = [\"DIFFUSEX\", \"DIFFUSEY\", \"DIFFUSEZ\"];\r\n\r\n for (let i = 0; i < textures.length; i++) {\r\n if (textures[i]) {\r\n if (!textures[i].isReady()) {\r\n return false;\r\n } else {\r\n (<any>defines)[textureDefines[i]] = true;\r\n }\r\n }\r\n }\r\n }\r\n if (MaterialFlags.BumpTextureEnabled) {\r\n const textures = [this.normalTextureX, this.normalTextureY, this.normalTextureZ];\r\n const textureDefines = [\"BUMPX\", \"BUMPY\", \"BUMPZ\"];\r\n\r\n for (let i = 0; i < textures.length; i++) {\r\n if (textures[i]) {\r\n if (!textures[i].isReady()) {\r\n return false;\r\n } else {\r\n (<any>defines)[textureDefines[i]] = true;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Misc.\r\n MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);\r\n\r\n // Lights\r\n defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);\r\n\r\n // Values that need to be evaluated on every frame\r\n MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);\r\n\r\n // Attribs\r\n MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);\r\n\r\n // Get correct effect\r\n if (defines.isDirty) {\r\n defines.markAsProcessed();\r\n scene.resetCachedMaterial();\r\n\r\n // Fallbacks\r\n const fallbacks = new EffectFallbacks();\r\n if (defines.FOG) {\r\n fallbacks.addFallback(1, \"FOG\");\r\n }\r\n\r\n MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);\r\n\r\n if (defines.NUM_BONE_INFLUENCERS > 0) {\r\n fallbacks.addCPUSkinningFallback(0, mesh);\r\n }\r\n\r\n defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;\r\n\r\n //Attributes\r\n const attribs = [VertexBuffer.PositionKind];\r\n\r\n if (defines.NORMAL) {\r\n attribs.push(VertexBuffer.NormalKind);\r\n }\r\n\r\n if (defines.VERTEXCOLOR) {\r\n attribs.push(VertexBuffer.ColorKind);\r\n }\r\n\r\n MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);\r\n MaterialHelper.PrepareAttributesForInstances(attribs, defines);\r\n\r\n // Legacy browser patch\r\n const shaderName = \"triplanar\";\r\n const join = defines.toString();\r\n const uniforms = [\r\n \"world\",\r\n \"view\",\r\n \"viewProjection\",\r\n \"vEyePosition\",\r\n \"vLightsType\",\r\n \"vDiffuseColor\",\r\n \"vSpecularColor\",\r\n \"vFogInfos\",\r\n \"vFogColor\",\r\n \"pointSize\",\r\n \"mBones\",\r\n \"tileSize\",\r\n ];\r\n const samplers = [\"diffuseSamplerX\", \"diffuseSamplerY\", \"diffuseSamplerZ\", \"normalSamplerX\", \"normalSamplerY\", \"normalSamplerZ\", \"logarithmicDepthConstant\"];\r\n\r\n const uniformBuffers: string[] = [];\r\n\r\n addClipPlaneUniforms(uniforms);\r\n\r\n MaterialHelper.PrepareUniformsAndSamplersList(<IEffectCreationOptions>{\r\n uniformsNames: uniforms,\r\n uniformBuffersNames: uniformBuffers,\r\n samplers: samplers,\r\n defines: defines,\r\n maxSimultaneousLights: this.maxSimultaneousLights,\r\n });\r\n\r\n subMesh.setEffect(\r\n scene.getEngine().createEffect(\r\n shaderName,\r\n <IEffectCreationOptions>{\r\n attributes: attribs,\r\n uniformsNames: uniforms,\r\n uniformBuffersNames: uniformBuffers,\r\n samplers: samplers,\r\n defines: join,\r\n fallbacks: fallbacks,\r\n onCompiled: this.onCompiled,\r\n onError: this.onError,\r\n indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },\r\n },\r\n engine\r\n ),\r\n defines,\r\n this._materialContext\r\n );\r\n }\r\n if (!subMesh.effect || !subMesh.effect.isReady()) {\r\n return false;\r\n }\r\n\r\n defines._renderId = scene.getRenderId();\r\n drawWrapper._wasPreviouslyReady = true;\r\n drawWrapper._wasPreviouslyUsingInstances = !!useInstances;\r\n\r\n return true;\r\n }\r\n\r\n public bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {\r\n const scene = this.getScene();\r\n\r\n const defines = <TriPlanarMaterialDefines>subMesh.materialDefines;\r\n if (!defines) {\r\n return;\r\n }\r\n\r\n const effect = subMesh.effect;\r\n if (!effect) {\r\n return;\r\n }\r\n this._activeEffect = effect;\r\n\r\n // Matrices\r\n this.bindOnlyWorldMatrix(world);\r\n this._activeEffect.setMatrix(\"viewProjection\", scene.getTransformMatrix());\r\n\r\n // Bones\r\n MaterialHelper.BindBonesParameters(mesh, this._activeEffect);\r\n\r\n this._activeEffect.setFloat(\"tileSize\", this.tileSize);\r\n\r\n if (this._mustRebind(scene, effect, subMesh)) {\r\n // Textures\r\n if (this.diffuseTextureX) {\r\n this._activeEffect.setTexture(\"diffuseSamplerX\", this.diffuseTextureX);\r\n }\r\n if (this.diffuseTextureY) {\r\n this._activeEffect.setTexture(\"diffuseSamplerY\", this.diffuseTextureY);\r\n }\r\n if (this.diffuseTextureZ) {\r\n this._activeEffect.setTexture(\"diffuseSamplerZ\", this.diffuseTextureZ);\r\n }\r\n if (this.normalTextureX) {\r\n this._activeEffect.setTexture(\"normalSamplerX\", this.normalTextureX);\r\n }\r\n if (this.normalTextureY) {\r\n this._activeEffect.setTexture(\"normalSamplerY\", this.normalTextureY);\r\n }\r\n if (this.normalTextureZ) {\r\n this._activeEffect.setTexture(\"normalSamplerZ\", this.normalTextureZ);\r\n }\r\n // Clip plane\r\n bindClipPlane(effect, this, scene);\r\n\r\n // Point size\r\n if (this.pointsCloud) {\r\n this._activeEffect.setFloat(\"pointSize\", this.pointSize);\r\n }\r\n\r\n // Log. depth\r\n if (this._useLogarithmicDepth) {\r\n MaterialHelper.BindLogDepth(defines, effect, scene);\r\n }\r\n\r\n scene.bindEyePosition(effect);\r\n }\r\n\r\n this._activeEffect.setColor4(\"vDiffuseColor\", this.diffuseColor, this.alpha * mesh.visibility);\r\n\r\n if (defines.SPECULARTERM) {\r\n this._activeEffect.setColor4(\"vSpecularColor\", this.specularColor, this.specularPower);\r\n }\r\n\r\n if (scene.lightsEnabled && !this.disableLighting) {\r\n MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);\r\n }\r\n\r\n // View\r\n if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {\r\n this._activeEffect.setMatrix(\"view\", scene.getViewMatrix());\r\n }\r\n\r\n // Fog\r\n MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);\r\n\r\n this._afterBind(mesh, this._activeEffect, subMesh);\r\n }\r\n\r\n public getAnimatables(): IAnimatable[] {\r\n const results = [];\r\n\r\n if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {\r\n results.push(this.mixTexture);\r\n }\r\n\r\n return results;\r\n }\r\n\r\n public getActiveTextures(): BaseTexture[] {\r\n const activeTextures = super.getActiveTextures();\r\n\r\n if (this._diffuseTextureX) {\r\n activeTextures.push(this._diffuseTextureX);\r\n }\r\n\r\n if (this._diffuseTextureY) {\r\n activeTextures.push(this._diffuseTextureY);\r\n }\r\n\r\n if (this._diffuseTextureZ) {\r\n activeTextures.push(this._diffuseTextureZ);\r\n }\r\n\r\n if (this._normalTextureX) {\r\n activeTextures.push(this._normalTextureX);\r\n }\r\n\r\n if (this._normalTextureY) {\r\n activeTextures.push(this._normalTextureY);\r\n }\r\n\r\n if (this._normalTextureZ) {\r\n activeTextures.push(this._normalTextureZ);\r\n }\r\n\r\n return activeTextures;\r\n }\r\n\r\n public hasTexture(texture: BaseTexture): boolean {\r\n if (super.hasTexture(texture)) {\r\n return true;\r\n }\r\n\r\n if (this._diffuseTextureX === texture) {\r\n return true;\r\n }\r\n\r\n if (this._diffuseTextureY === texture) {\r\n return true;\r\n }\r\n\r\n if (this._diffuseTextureZ === texture) {\r\n return true;\r\n }\r\n\r\n if (this._normalTextureX === texture) {\r\n return true;\r\n }\r\n\r\n if (this._normalTextureY === texture) {\r\n return true;\r\n }\r\n\r\n if (this._normalTextureZ === texture) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n public dispose(forceDisposeEffect?: boolean): void {\r\n if (this.mixTexture) {\r\n this.mixTexture.dispose();\r\n }\r\n\r\n super.dispose(forceDisposeEffect);\r\n }\r\n\r\n public clone(name: string): TriPlanarMaterial {\r\n return SerializationHelper.Clone(() => new TriPlanarMaterial(name, this.getScene()), this);\r\n }\r\n\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.customType = \"BABYLON.TriPlanarMaterial\";\r\n return serializationObject;\r\n }\r\n\r\n public getClassName(): string {\r\n return \"TriPlanarMaterial\";\r\n }\r\n\r\n // Statics\r\n public static Parse(source: any, scene: Scene, rootUrl: string): TriPlanarMaterial {\r\n return SerializationHelper.Parse(() => new TriPlanarMaterial(source.name, scene), source, scene, rootUrl);\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.TriPlanarMaterial\", TriPlanarMaterial);\r\n"]}
|
1
|
+
{"version":3,"file":"triPlanarMaterial.js","sourceRoot":"","sources":["../../../../dev/materials/src/triPlanar/triPlanarMaterial.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,2CAA6B;AAE/H,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAK/C,OAAO,EAAE,eAAe,EAAE,qDAAuC;AACjE,OAAO,EAAE,YAAY,EAAE,kDAAoC;AAC3D,OAAO,EAAE,aAAa,EAAE,mDAAqC;AAC7D,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAInD,OAAO,EAAE,KAAK,EAAE,iCAAmB;AACnC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD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BAAiB,CAAC;2DACA;AAE/B;IADN,gBAAgB,CAAC,kCAAkC,CAAC;0DACjB;AAG5B;IADP,kBAAkB,CAAC,gBAAgB,CAAC;0DACA;AAE9B;IADN,gBAAgB,CAAC,kCAAkC,CAAC;yDAClB;AAG3B;IADP,kBAAkB,CAAC,gBAAgB,CAAC;0DACA;AAE9B;IADN,gBAAgB,CAAC,kCAAkC,CAAC;yDAClB;AAG3B;IADP,kBAAkB,CAAC,gBAAgB,CAAC;0DACA;AAE9B;IADN,gBAAgB,CAAC,kCAAkC,CAAC;yDAClB;AAG5B;IADN,SAAS,EAAE;mDACgB;AAGrB;IADN,iBAAiB,EAAE;uDACsB;AAGnC;IADN,iBAAiB,EAAE;wDAC6B;AAG1C;IADN,SAAS,EAAE;wDACc;AAGlB;IADP,SAAS,CAAC,iBAAiB,CAAC;2DACI;AAE1B;IADN,gBAAgB,CAAC,gCAAgC,CAAC;0DACnB;AAGxB;IADP,SAAS,CAAC,uBAAuB,CAAC;iEACA;AAE5B;IADN,gBAAgB,CAAC,gCAAgC,CAAC;gEACd;AAyWzC,aAAa,CAAC,2BAA2B,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper } from \"core/Misc/decorators\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\n\r\nimport type { IAnimatable } from \"core/Animations/animatable.interface\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { IEffectCreationOptions } from \"core/Materials/effect\";\r\nimport { MaterialDefines } from \"core/Materials/materialDefines\";\r\nimport { PushMaterial } from \"core/Materials/pushMaterial\";\r\nimport { MaterialFlags } from \"core/Materials/materialFlags\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\n\r\nimport \"./triplanar.fragment\";\r\nimport \"./triplanar.vertex\";\r\nimport { EffectFallbacks } from \"core/Materials/effectFallbacks\";\r\nimport { addClipPlaneUniforms, bindClipPlane } from \"core/Materials/clipPlaneMaterialHelper\";\r\nimport {\r\n BindBonesParameters,\r\n BindFogParameters,\r\n BindLights,\r\n BindLogDepth,\r\n HandleFallbacksForShadows,\r\n PrepareAttributesForBones,\r\n PrepareAttributesForInstances,\r\n PrepareDefinesForAttributes,\r\n PrepareDefinesForFrameBoundValues,\r\n PrepareDefinesForLights,\r\n PrepareDefinesForMisc,\r\n PrepareUniformsAndSamplersList,\r\n} from \"core/Materials/materialHelper.functions\";\r\n\r\nclass TriPlanarMaterialDefines extends MaterialDefines {\r\n public DIFFUSEX = false;\r\n public DIFFUSEY = false;\r\n public DIFFUSEZ = false;\r\n\r\n public BUMPX = false;\r\n public BUMPY = false;\r\n public BUMPZ = false;\r\n\r\n public CLIPPLANE = false;\r\n public CLIPPLANE2 = false;\r\n public CLIPPLANE3 = false;\r\n public CLIPPLANE4 = false;\r\n public CLIPPLANE5 = false;\r\n public CLIPPLANE6 = false;\r\n public ALPHATEST = false;\r\n public DEPTHPREPASS = false;\r\n public POINTSIZE = false;\r\n public FOG = false;\r\n public SPECULARTERM = false;\r\n public NORMAL = false;\r\n public VERTEXCOLOR = false;\r\n public VERTEXALPHA = false;\r\n public NUM_BONE_INFLUENCERS = 0;\r\n public BonesPerMesh = 0;\r\n public INSTANCES = false;\r\n public INSTANCESCOLOR = false;\r\n public IMAGEPROCESSINGPOSTPROCESS = false;\r\n public SKIPFINALCOLORCLAMP = false;\r\n public NONUNIFORMSCALING = false;\r\n public LOGARITHMICDEPTH = false;\r\n\r\n constructor() {\r\n super();\r\n this.rebuild();\r\n }\r\n}\r\n\r\nexport class TriPlanarMaterial extends PushMaterial {\r\n @serializeAsTexture()\r\n public mixTexture: BaseTexture;\r\n\r\n @serializeAsTexture(\"diffuseTextureX\")\r\n private _diffuseTextureX: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public diffuseTextureX: BaseTexture;\r\n\r\n @serializeAsTexture(\"diffuseTexturY\")\r\n private _diffuseTextureY: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public diffuseTextureY: BaseTexture;\r\n\r\n @serializeAsTexture(\"diffuseTextureZ\")\r\n private _diffuseTextureZ: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public diffuseTextureZ: BaseTexture;\r\n\r\n @serializeAsTexture(\"normalTextureX\")\r\n private _normalTextureX: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public normalTextureX: BaseTexture;\r\n\r\n @serializeAsTexture(\"normalTextureY\")\r\n private _normalTextureY: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public normalTextureY: BaseTexture;\r\n\r\n @serializeAsTexture(\"normalTextureZ\")\r\n private _normalTextureZ: BaseTexture;\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public normalTextureZ: BaseTexture;\r\n\r\n @serialize()\r\n public tileSize: number = 1;\r\n\r\n @serializeAsColor3()\r\n public diffuseColor = new Color3(1, 1, 1);\r\n\r\n @serializeAsColor3()\r\n public specularColor = new Color3(0.2, 0.2, 0.2);\r\n\r\n @serialize()\r\n public specularPower = 64;\r\n\r\n @serialize(\"disableLighting\")\r\n private _disableLighting = false;\r\n @expandToProperty(\"_markAllSubMeshesAsLightsDirty\")\r\n public disableLighting: boolean;\r\n\r\n @serialize(\"maxSimultaneousLights\")\r\n private _maxSimultaneousLights = 4;\r\n @expandToProperty(\"_markAllSubMeshesAsLightsDirty\")\r\n public maxSimultaneousLights: number;\r\n\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n }\r\n\r\n public needAlphaBlending(): boolean {\r\n return this.alpha < 1.0;\r\n }\r\n\r\n public needAlphaTesting(): boolean {\r\n return false;\r\n }\r\n\r\n public getAlphaTestTexture(): Nullable<BaseTexture> {\r\n return null;\r\n }\r\n\r\n // Methods\r\n public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean {\r\n const drawWrapper = subMesh._drawWrapper;\r\n\r\n if (this.isFrozen) {\r\n if (drawWrapper.effect && drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!subMesh.materialDefines) {\r\n subMesh.materialDefines = new TriPlanarMaterialDefines();\r\n }\r\n\r\n const defines = <TriPlanarMaterialDefines>subMesh.materialDefines;\r\n const scene = this.getScene();\r\n\r\n if (this._isReadyForSubMesh(subMesh)) {\r\n return true;\r\n }\r\n\r\n const engine = scene.getEngine();\r\n\r\n // Textures\r\n if (defines._areTexturesDirty) {\r\n if (scene.texturesEnabled) {\r\n if (MaterialFlags.DiffuseTextureEnabled) {\r\n const textures = [this.diffuseTextureX, this.diffuseTextureY, this.diffuseTextureZ];\r\n const textureDefines = [\"DIFFUSEX\", \"DIFFUSEY\", \"DIFFUSEZ\"];\r\n\r\n for (let i = 0; i < textures.length; i++) {\r\n if (textures[i]) {\r\n if (!textures[i].isReady()) {\r\n return false;\r\n } else {\r\n (<any>defines)[textureDefines[i]] = true;\r\n }\r\n }\r\n }\r\n }\r\n if (MaterialFlags.BumpTextureEnabled) {\r\n const textures = [this.normalTextureX, this.normalTextureY, this.normalTextureZ];\r\n const textureDefines = [\"BUMPX\", \"BUMPY\", \"BUMPZ\"];\r\n\r\n for (let i = 0; i < textures.length; i++) {\r\n if (textures[i]) {\r\n if (!textures[i].isReady()) {\r\n return false;\r\n } else {\r\n (<any>defines)[textureDefines[i]] = true;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Misc.\r\n PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);\r\n\r\n // Lights\r\n defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);\r\n\r\n // Values that need to be evaluated on every frame\r\n PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);\r\n\r\n // Attribs\r\n PrepareDefinesForAttributes(mesh, defines, true, true);\r\n\r\n // Get correct effect\r\n if (defines.isDirty) {\r\n defines.markAsProcessed();\r\n scene.resetCachedMaterial();\r\n\r\n // Fallbacks\r\n const fallbacks = new EffectFallbacks();\r\n if (defines.FOG) {\r\n fallbacks.addFallback(1, \"FOG\");\r\n }\r\n\r\n HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);\r\n\r\n if (defines.NUM_BONE_INFLUENCERS > 0) {\r\n fallbacks.addCPUSkinningFallback(0, mesh);\r\n }\r\n\r\n defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;\r\n\r\n //Attributes\r\n const attribs = [VertexBuffer.PositionKind];\r\n\r\n if (defines.NORMAL) {\r\n attribs.push(VertexBuffer.NormalKind);\r\n }\r\n\r\n if (defines.VERTEXCOLOR) {\r\n attribs.push(VertexBuffer.ColorKind);\r\n }\r\n\r\n PrepareAttributesForBones(attribs, mesh, defines, fallbacks);\r\n PrepareAttributesForInstances(attribs, defines);\r\n\r\n // Legacy browser patch\r\n const shaderName = \"triplanar\";\r\n const join = defines.toString();\r\n const uniforms = [\r\n \"world\",\r\n \"view\",\r\n \"viewProjection\",\r\n \"vEyePosition\",\r\n \"vLightsType\",\r\n \"vDiffuseColor\",\r\n \"vSpecularColor\",\r\n \"vFogInfos\",\r\n \"vFogColor\",\r\n \"pointSize\",\r\n \"mBones\",\r\n \"tileSize\",\r\n ];\r\n const samplers = [\"diffuseSamplerX\", \"diffuseSamplerY\", \"diffuseSamplerZ\", \"normalSamplerX\", \"normalSamplerY\", \"normalSamplerZ\", \"logarithmicDepthConstant\"];\r\n\r\n const uniformBuffers: string[] = [];\r\n\r\n addClipPlaneUniforms(uniforms);\r\n\r\n PrepareUniformsAndSamplersList(<IEffectCreationOptions>{\r\n uniformsNames: uniforms,\r\n uniformBuffersNames: uniformBuffers,\r\n samplers: samplers,\r\n defines: defines,\r\n maxSimultaneousLights: this.maxSimultaneousLights,\r\n });\r\n\r\n subMesh.setEffect(\r\n scene.getEngine().createEffect(\r\n shaderName,\r\n <IEffectCreationOptions>{\r\n attributes: attribs,\r\n uniformsNames: uniforms,\r\n uniformBuffersNames: uniformBuffers,\r\n samplers: samplers,\r\n defines: join,\r\n fallbacks: fallbacks,\r\n onCompiled: this.onCompiled,\r\n onError: this.onError,\r\n indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },\r\n },\r\n engine\r\n ),\r\n defines,\r\n this._materialContext\r\n );\r\n }\r\n if (!subMesh.effect || !subMesh.effect.isReady()) {\r\n return false;\r\n }\r\n\r\n defines._renderId = scene.getRenderId();\r\n drawWrapper._wasPreviouslyReady = true;\r\n drawWrapper._wasPreviouslyUsingInstances = !!useInstances;\r\n\r\n return true;\r\n }\r\n\r\n public bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {\r\n const scene = this.getScene();\r\n\r\n const defines = <TriPlanarMaterialDefines>subMesh.materialDefines;\r\n if (!defines) {\r\n return;\r\n }\r\n\r\n const effect = subMesh.effect;\r\n if (!effect) {\r\n return;\r\n }\r\n this._activeEffect = effect;\r\n\r\n // Matrices\r\n this.bindOnlyWorldMatrix(world);\r\n this._activeEffect.setMatrix(\"viewProjection\", scene.getTransformMatrix());\r\n\r\n // Bones\r\n BindBonesParameters(mesh, this._activeEffect);\r\n\r\n this._activeEffect.setFloat(\"tileSize\", this.tileSize);\r\n\r\n if (this._mustRebind(scene, effect, subMesh)) {\r\n // Textures\r\n if (this.diffuseTextureX) {\r\n this._activeEffect.setTexture(\"diffuseSamplerX\", this.diffuseTextureX);\r\n }\r\n if (this.diffuseTextureY) {\r\n this._activeEffect.setTexture(\"diffuseSamplerY\", this.diffuseTextureY);\r\n }\r\n if (this.diffuseTextureZ) {\r\n this._activeEffect.setTexture(\"diffuseSamplerZ\", this.diffuseTextureZ);\r\n }\r\n if (this.normalTextureX) {\r\n this._activeEffect.setTexture(\"normalSamplerX\", this.normalTextureX);\r\n }\r\n if (this.normalTextureY) {\r\n this._activeEffect.setTexture(\"normalSamplerY\", this.normalTextureY);\r\n }\r\n if (this.normalTextureZ) {\r\n this._activeEffect.setTexture(\"normalSamplerZ\", this.normalTextureZ);\r\n }\r\n // Clip plane\r\n bindClipPlane(effect, this, scene);\r\n\r\n // Point size\r\n if (this.pointsCloud) {\r\n this._activeEffect.setFloat(\"pointSize\", this.pointSize);\r\n }\r\n\r\n // Log. depth\r\n if (this._useLogarithmicDepth) {\r\n BindLogDepth(defines, effect, scene);\r\n }\r\n\r\n scene.bindEyePosition(effect);\r\n }\r\n\r\n this._activeEffect.setColor4(\"vDiffuseColor\", this.diffuseColor, this.alpha * mesh.visibility);\r\n\r\n if (defines.SPECULARTERM) {\r\n this._activeEffect.setColor4(\"vSpecularColor\", this.specularColor, this.specularPower);\r\n }\r\n\r\n if (scene.lightsEnabled && !this.disableLighting) {\r\n BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);\r\n }\r\n\r\n // View\r\n if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {\r\n this._activeEffect.setMatrix(\"view\", scene.getViewMatrix());\r\n }\r\n\r\n // Fog\r\n BindFogParameters(scene, mesh, this._activeEffect);\r\n\r\n this._afterBind(mesh, this._activeEffect, subMesh);\r\n }\r\n\r\n public getAnimatables(): IAnimatable[] {\r\n const results = [];\r\n\r\n if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {\r\n results.push(this.mixTexture);\r\n }\r\n\r\n return results;\r\n }\r\n\r\n public getActiveTextures(): BaseTexture[] {\r\n const activeTextures = super.getActiveTextures();\r\n\r\n if (this._diffuseTextureX) {\r\n activeTextures.push(this._diffuseTextureX);\r\n }\r\n\r\n if (this._diffuseTextureY) {\r\n activeTextures.push(this._diffuseTextureY);\r\n }\r\n\r\n if (this._diffuseTextureZ) {\r\n activeTextures.push(this._diffuseTextureZ);\r\n }\r\n\r\n if (this._normalTextureX) {\r\n activeTextures.push(this._normalTextureX);\r\n }\r\n\r\n if (this._normalTextureY) {\r\n activeTextures.push(this._normalTextureY);\r\n }\r\n\r\n if (this._normalTextureZ) {\r\n activeTextures.push(this._normalTextureZ);\r\n }\r\n\r\n return activeTextures;\r\n }\r\n\r\n public hasTexture(texture: BaseTexture): boolean {\r\n if (super.hasTexture(texture)) {\r\n return true;\r\n }\r\n\r\n if (this._diffuseTextureX === texture) {\r\n return true;\r\n }\r\n\r\n if (this._diffuseTextureY === texture) {\r\n return true;\r\n }\r\n\r\n if (this._diffuseTextureZ === texture) {\r\n return true;\r\n }\r\n\r\n if (this._normalTextureX === texture) {\r\n return true;\r\n }\r\n\r\n if (this._normalTextureY === texture) {\r\n return true;\r\n }\r\n\r\n if (this._normalTextureZ === texture) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n public dispose(forceDisposeEffect?: boolean): void {\r\n if (this.mixTexture) {\r\n this.mixTexture.dispose();\r\n }\r\n\r\n super.dispose(forceDisposeEffect);\r\n }\r\n\r\n public clone(name: string): TriPlanarMaterial {\r\n return SerializationHelper.Clone(() => new TriPlanarMaterial(name, this.getScene()), this);\r\n }\r\n\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.customType = \"BABYLON.TriPlanarMaterial\";\r\n return serializationObject;\r\n }\r\n\r\n public getClassName(): string {\r\n return \"TriPlanarMaterial\";\r\n }\r\n\r\n // Statics\r\n public static Parse(source: any, scene: Scene, rootUrl: string): TriPlanarMaterial {\r\n return SerializationHelper.Parse(() => new TriPlanarMaterial(source.name, scene), source, scene, rootUrl);\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.TriPlanarMaterial\", TriPlanarMaterial);\r\n"]}
|