@babylonjs/core 5.6.1 → 5.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/Cameras/Inputs/freeCameraTouchInput.js +2 -2
  2. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  3. package/DeviceInput/InputDevices/webDeviceInputSystem.js +1 -1
  4. package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +1 -1
  5. package/Engines/Extensions/engine.dynamicBuffer.js +7 -5
  6. package/Engines/Extensions/engine.dynamicBuffer.js.map +1 -1
  7. package/Engines/Extensions/engine.rawTexture.d.ts +4 -2
  8. package/Engines/Extensions/engine.rawTexture.js +9 -4
  9. package/Engines/Extensions/engine.rawTexture.js.map +1 -1
  10. package/Engines/WebGPU/Extensions/engine.computeShader.js +3 -1
  11. package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
  12. package/Engines/WebGPU/Extensions/engine.dynamicBuffer.js +3 -21
  13. package/Engines/WebGPU/Extensions/engine.dynamicBuffer.js.map +1 -1
  14. package/Engines/WebGPU/Extensions/engine.rawTexture.js +7 -3
  15. package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
  16. package/Engines/WebGPU/webgpuConstants.d.ts +8 -2
  17. package/Engines/WebGPU/webgpuConstants.js +15 -8
  18. package/Engines/WebGPU/webgpuConstants.js.map +1 -1
  19. package/Engines/WebGPU/webgpuTextureHelper.js +4 -0
  20. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  21. package/Engines/engine.d.ts +56 -77
  22. package/Engines/nativeEngine.d.ts +4 -4
  23. package/Engines/nativeEngine.js +9 -5
  24. package/Engines/nativeEngine.js.map +1 -1
  25. package/Engines/nullEngine.d.ts +4 -2
  26. package/Engines/nullEngine.js +11 -3
  27. package/Engines/nullEngine.js.map +1 -1
  28. package/Engines/thinEngine.js +30 -4
  29. package/Engines/thinEngine.js.map +1 -1
  30. package/Engines/webgpuEngine.js +2 -8
  31. package/Engines/webgpuEngine.js.map +1 -1
  32. package/Gizmos/boundingBoxGizmo.js +5 -0
  33. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  34. package/Inputs/scene.inputManager.js +5 -2
  35. package/Inputs/scene.inputManager.js.map +1 -1
  36. package/Loading/Plugins/babylonFileLoader.js +1 -0
  37. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  38. package/Materials/Node/Blocks/Input/inputBlock.js +7 -0
  39. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  40. package/Materials/Node/nodeMaterial.d.ts +4 -2
  41. package/Materials/Node/nodeMaterial.js +13 -4
  42. package/Materials/Node/nodeMaterial.js.map +1 -1
  43. package/Materials/PBR/pbrBaseMaterial.js +1 -1
  44. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  45. package/Materials/Textures/internalTexture.js +1 -1
  46. package/Materials/Textures/internalTexture.js.map +1 -1
  47. package/Materials/Textures/rawTexture.d.ts +10 -4
  48. package/Materials/Textures/rawTexture.js +20 -9
  49. package/Materials/Textures/rawTexture.js.map +1 -1
  50. package/Materials/effect.d.ts +1 -0
  51. package/Materials/effect.js +5 -0
  52. package/Materials/effect.js.map +1 -1
  53. package/Materials/standardMaterial.js +5 -1
  54. package/Materials/standardMaterial.js.map +1 -1
  55. package/Maths/math.vector.js +5 -5
  56. package/Maths/math.vector.js.map +1 -1
  57. package/Meshes/Builders/groundBuilder.d.ts +1 -1
  58. package/Meshes/Builders/groundBuilder.js.map +1 -1
  59. package/Meshes/abstractMesh.d.ts +0 -5
  60. package/Meshes/abstractMesh.js +1 -13
  61. package/Meshes/abstractMesh.js.map +1 -1
  62. package/Meshes/instancedMesh.js +2 -0
  63. package/Meshes/instancedMesh.js.map +1 -1
  64. package/Meshes/mesh.d.ts +1 -1
  65. package/Meshes/mesh.js +60 -32
  66. package/Meshes/mesh.js.map +1 -1
  67. package/Particles/particleHelper.js +1 -1
  68. package/Particles/particleHelper.js.map +1 -1
  69. package/PostProcesses/depthOfFieldBlurPostProcess.d.ts +1 -1
  70. package/PostProcesses/depthOfFieldBlurPostProcess.js +2 -4
  71. package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
  72. package/Rendering/geometryBufferRenderer.d.ts +6 -2
  73. package/Rendering/geometryBufferRenderer.js +209 -18
  74. package/Rendering/geometryBufferRenderer.js.map +1 -1
  75. package/Shaders/ShadersInclude/defaultFragmentDeclaration.js +1 -1
  76. package/Shaders/ShadersInclude/defaultFragmentDeclaration.js.map +1 -1
  77. package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js +1 -1
  78. package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
  79. package/Shaders/ShadersInclude/pbrBlockClearcoat.js +1 -1
  80. package/Shaders/ShadersInclude/pbrBlockClearcoat.js.map +1 -1
  81. package/Shaders/ShadersInclude/vertexColorMixing.js +1 -1
  82. package/Shaders/ShadersInclude/vertexColorMixing.js.map +1 -1
  83. package/Shaders/default.fragment.js +1 -1
  84. package/Shaders/default.fragment.js.map +1 -1
  85. package/Shaders/geometry.fragment.d.ts +1 -0
  86. package/Shaders/geometry.fragment.js +2 -1
  87. package/Shaders/geometry.fragment.js.map +1 -1
  88. package/Shaders/geometry.vertex.js +1 -1
  89. package/Shaders/geometry.vertex.js.map +1 -1
  90. package/Shaders/pbr.fragment.js +1 -1
  91. package/Shaders/pbr.fragment.js.map +1 -1
  92. package/XR/features/WebXRControllerPointerSelection.js +1 -1
  93. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  94. package/package.json +1 -1
  95. package/scene.d.ts +4 -0
  96. package/scene.js +4 -0
  97. package/scene.js.map +1 -1
@@ -32,7 +32,7 @@ var ParticleHelper = /** @class */ (function () {
32
32
  system = new ParticleSystem("default system", capacity, scene);
33
33
  }
34
34
  system.emitter = emitter;
35
- system.particleTexture = new Texture("https://www.babylonjs.com/assets/Flare.png", system.getScene());
35
+ system.particleTexture = new Texture("https://assets.babylonjs.com/textures/flare.png", system.getScene());
36
36
  system.createConeEmitter(0.1, Math.PI / 4);
37
37
  // Particle color
38
38
  system.color1 = new Color4(1.0, 1.0, 1.0, 1.0);
@@ -1 +1 @@
1
- {"version":3,"file":"particleHelper.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Particles/particleHelper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD;;GAEG;AACH;IAAA;IAgMA,CAAC;IAvLG;;;;;;;OAOG;IACW,4BAAa,GAA3B,UAA4B,OAAyC,EAAE,QAAc,EAAE,KAAa,EAAE,MAAc;QAA7C,yBAAA,EAAA,cAAc;QAAiB,uBAAA,EAAA,cAAc;QAChH,IAAI,MAAuB,CAAC;QAE5B,IAAI,MAAM,EAAE;YACR,MAAM,GAAG,IAAI,iBAAiB,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,KAAM,CAAC,CAAC;SACpF;aAAM;YACH,MAAM,GAAG,IAAI,cAAc,CAAC,gBAAgB,EAAE,QAAQ,EAAE,KAAM,CAAC,CAAC;SACnE;QAED,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QACzB,MAAM,CAAC,eAAe,GAAG,IAAI,OAAO,CAAC,4CAA4C,EAAE,MAAM,CAAC,QAAQ,E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CAAA,AAhMD,IAgMC;SAhMY,cAAc","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport type { Vector3 } from \"../Maths/math.vector\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { IParticleSystem } from \"./IParticleSystem\";\r\nimport { GPUParticleSystem } from \"./gpuParticleSystem\";\r\nimport { ParticleSystemSet } from \"./particleSystemSet\";\r\nimport { ParticleSystem } from \"./particleSystem\";\r\nimport { WebRequest } from \"../Misc/webRequest\";\r\nimport { Constants } from \"../Engines/constants\";\r\n/**\r\n * This class is made for on one-liner static method to help creating particle system set.\r\n */\r\nexport class ParticleHelper {\r\n /**\r\n * Gets or sets base Assets URL\r\n */\r\n public static BaseAssetsUrl = ParticleSystemSet.BaseAssetsUrl;\r\n\r\n /** Define the Url to load snippets */\r\n public static SnippetUrl = Constants.SnippetUrl;\r\n\r\n /**\r\n * Create a default particle system that you can tweak\r\n * @param emitter defines the emitter to use\r\n * @param capacity defines the system capacity (default is 500 particles)\r\n * @param scene defines the hosting scene\r\n * @param useGPU defines if a GPUParticleSystem must be created (default is false)\r\n * @returns the new Particle system\r\n */\r\n public static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity = 500, scene?: Scene, useGPU = false): IParticleSystem {\r\n let system: IParticleSystem;\r\n\r\n if (useGPU) {\r\n system = new GPUParticleSystem(\"default system\", { capacity: capacity }, scene!);\r\n } else {\r\n system = new ParticleSystem(\"default system\", capacity, scene!);\r\n }\r\n\r\n system.emitter = emitter;\r\n system.particleTexture = new Texture(\"https://www.babylonjs.com/assets/Flare.png\", system.getScene());\r\n system.createConeEmitter(0.1, Math.PI / 4);\r\n\r\n // Particle color\r\n system.color1 = new Color4(1.0, 1.0, 1.0, 1.0);\r\n system.color2 = new Color4(1.0, 1.0, 1.0, 1.0);\r\n system.colorDead = new Color4(1.0, 1.0, 1.0, 0.0);\r\n\r\n // Particle Size\r\n system.minSize = 0.1;\r\n system.maxSize = 0.1;\r\n\r\n // Emission speed\r\n system.minEmitPower = 2;\r\n system.maxEmitPower = 2;\r\n\r\n // Update speed\r\n system.updateSpeed = 1 / 60;\r\n\r\n system.emitRate = 30;\r\n\r\n return system;\r\n }\r\n\r\n /**\r\n * This is the main static method (one-liner) of this helper to create different particle systems\r\n * @param type This string represents the type to the particle system to create\r\n * @param scene The scene where the particle system should live\r\n * @param gpu If the system will use gpu\r\n * @param capacity defines the system capacity (if null or undefined the sotred capacity will be used)\r\n * @returns the ParticleSystemSet created\r\n */\r\n public static CreateAsync(type: string, scene: Nullable<Scene>, gpu: boolean = false, capacity?: number): Promise<ParticleSystemSet> {\r\n if (!scene) {\r\n scene = EngineStore.LastCreatedScene;\r\n }\r\n\r\n const token = {};\r\n\r\n scene!._addPendingData(token);\r\n\r\n return new Promise((resolve, reject) => {\r\n if (gpu && !GPUParticleSystem.IsSupported) {\r\n scene!._removePendingData(token);\r\n return reject(\"Particle system with GPU is not supported.\");\r\n }\r\n\r\n Tools.LoadFile(\r\n `${ParticleHelper.BaseAssetsUrl}/systems/${type}.json`,\r\n (data) => {\r\n scene!._removePendingData(token);\r\n const newData = JSON.parse(data.toString());\r\n return resolve(ParticleSystemSet.Parse(newData, scene!, gpu, capacity));\r\n },\r\n undefined,\r\n undefined,\r\n undefined,\r\n () => {\r\n scene!._removePendingData(token);\r\n return reject(`An error occurred with the creation of your particle system. Check if your type '${type}' exists.`);\r\n }\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Static function used to export a particle system to a ParticleSystemSet variable.\r\n * Please note that the emitter shape is not exported\r\n * @param systems defines the particle systems to export\r\n * @returns the created particle system set\r\n */\r\n public static ExportSet(systems: IParticleSystem[]): ParticleSystemSet {\r\n const set = new ParticleSystemSet();\r\n\r\n for (const system of systems) {\r\n set.systems.push(system);\r\n }\r\n\r\n return set;\r\n }\r\n\r\n /**\r\n * Creates a particle system from a snippet saved in a remote file\r\n * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)\r\n * @param url defines the url to load from\r\n * @param scene defines the hosting scene\r\n * @param gpu If the system will use gpu\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @param capacity defines the system capacity (if null or undefined the sotred capacity will be used)\r\n * @returns a promise that will resolve to the new particle system\r\n */\r\n public static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu: boolean = false, rootUrl: string = \"\", capacity?: number): Promise<IParticleSystem> {\r\n return new Promise((resolve, reject) => {\r\n const request = new WebRequest();\r\n request.addEventListener(\"readystatechange\", () => {\r\n if (request.readyState == 4) {\r\n if (request.status == 200) {\r\n const serializationObject = JSON.parse(request.responseText);\r\n let output: IParticleSystem;\r\n\r\n if (gpu) {\r\n output = GPUParticleSystem.Parse(serializationObject, scene, rootUrl, false, capacity);\r\n } else {\r\n output = ParticleSystem.Parse(serializationObject, scene, rootUrl, false, capacity);\r\n }\r\n\r\n if (name) {\r\n output.name = name;\r\n }\r\n\r\n resolve(output);\r\n } else {\r\n reject(\"Unable to load the particle system\");\r\n }\r\n }\r\n });\r\n\r\n request.open(\"GET\", url);\r\n request.send();\r\n });\r\n }\r\n\r\n /**\r\n * Creates a particle system from a snippet saved by the particle system editor\r\n * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)\r\n * @param scene defines the hosting scene\r\n * @param gpu If the system will use gpu\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @param capacity defines the system capacity (if null or undefined the sotred capacity will be used)\r\n * @returns a promise that will resolve to the new particle system\r\n */\r\n public static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu: boolean = false, rootUrl: string = \"\", capacity?: number): Promise<IParticleSystem> {\r\n if (snippetId === \"_BLANK\") {\r\n const system = this.CreateDefault(null);\r\n system.start();\r\n return Promise.resolve(system);\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const request = new WebRequest();\r\n request.addEventListener(\"readystatechange\", () => {\r\n if (request.readyState == 4) {\r\n if (request.status == 200) {\r\n const snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);\r\n const serializationObject = JSON.parse(snippet.particleSystem);\r\n let output: IParticleSystem;\r\n\r\n if (gpu) {\r\n output = GPUParticleSystem.Parse(serializationObject, scene, rootUrl, false, capacity);\r\n } else {\r\n output = ParticleSystem.Parse(serializationObject, scene, rootUrl, false, capacity);\r\n }\r\n output.snippetId = snippetId;\r\n\r\n resolve(output);\r\n } else {\r\n reject(\"Unable to load the snippet \" + snippetId);\r\n }\r\n }\r\n });\r\n\r\n request.open(\"GET\", this.SnippetUrl + \"/\" + snippetId.replace(/#/g, \"/\"));\r\n request.send();\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"particleHelper.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Particles/particleHelper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD;;GAEG;AACH;IAAA;IAgMA,CAAC;IAvLG;;;;;;;OAOG;IACW,4BAAa,GAA3B,UAA4B,OAAyC,EAAE,QAAc,EAAE,KAAa,EAAE,MAAc;QAA7C,yBAAA,EAAA,cAAc;QAAiB,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G,SAAS,CAAC,CAAC;qBACrD;iBACJ;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,KAAI,CAAC,UAAU,GAAG,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YAC1E,OAAO,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC;IA9LD;;OAEG;IACW,4BAAa,GAAG,iBAAiB,CAAC,aAAa,CAAC;IAE9D,sCAAsC;IACxB,yBAAU,GAAG,SAAS,CAAC,UAAU,CAAC;IAyLpD,qBAAC;CAAA,AAhMD,IAgMC;SAhMY,cAAc","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport type { Vector3 } from \"../Maths/math.vector\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { IParticleSystem } from \"./IParticleSystem\";\r\nimport { GPUParticleSystem } from \"./gpuParticleSystem\";\r\nimport { ParticleSystemSet } from \"./particleSystemSet\";\r\nimport { ParticleSystem } from \"./particleSystem\";\r\nimport { WebRequest } from \"../Misc/webRequest\";\r\nimport { Constants } from \"../Engines/constants\";\r\n/**\r\n * This class is made for on one-liner static method to help creating particle system set.\r\n */\r\nexport class ParticleHelper {\r\n /**\r\n * Gets or sets base Assets URL\r\n */\r\n public static BaseAssetsUrl = ParticleSystemSet.BaseAssetsUrl;\r\n\r\n /** Define the Url to load snippets */\r\n public static SnippetUrl = Constants.SnippetUrl;\r\n\r\n /**\r\n * Create a default particle system that you can tweak\r\n * @param emitter defines the emitter to use\r\n * @param capacity defines the system capacity (default is 500 particles)\r\n * @param scene defines the hosting scene\r\n * @param useGPU defines if a GPUParticleSystem must be created (default is false)\r\n * @returns the new Particle system\r\n */\r\n public static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity = 500, scene?: Scene, useGPU = false): IParticleSystem {\r\n let system: IParticleSystem;\r\n\r\n if (useGPU) {\r\n system = new GPUParticleSystem(\"default system\", { capacity: capacity }, scene!);\r\n } else {\r\n system = new ParticleSystem(\"default system\", capacity, scene!);\r\n }\r\n\r\n system.emitter = emitter;\r\n system.particleTexture = new Texture(\"https://assets.babylonjs.com/textures/flare.png\", system.getScene());\r\n system.createConeEmitter(0.1, Math.PI / 4);\r\n\r\n // Particle color\r\n system.color1 = new Color4(1.0, 1.0, 1.0, 1.0);\r\n system.color2 = new Color4(1.0, 1.0, 1.0, 1.0);\r\n system.colorDead = new Color4(1.0, 1.0, 1.0, 0.0);\r\n\r\n // Particle Size\r\n system.minSize = 0.1;\r\n system.maxSize = 0.1;\r\n\r\n // Emission speed\r\n system.minEmitPower = 2;\r\n system.maxEmitPower = 2;\r\n\r\n // Update speed\r\n system.updateSpeed = 1 / 60;\r\n\r\n system.emitRate = 30;\r\n\r\n return system;\r\n }\r\n\r\n /**\r\n * This is the main static method (one-liner) of this helper to create different particle systems\r\n * @param type This string represents the type to the particle system to create\r\n * @param scene The scene where the particle system should live\r\n * @param gpu If the system will use gpu\r\n * @param capacity defines the system capacity (if null or undefined the sotred capacity will be used)\r\n * @returns the ParticleSystemSet created\r\n */\r\n public static CreateAsync(type: string, scene: Nullable<Scene>, gpu: boolean = false, capacity?: number): Promise<ParticleSystemSet> {\r\n if (!scene) {\r\n scene = EngineStore.LastCreatedScene;\r\n }\r\n\r\n const token = {};\r\n\r\n scene!._addPendingData(token);\r\n\r\n return new Promise((resolve, reject) => {\r\n if (gpu && !GPUParticleSystem.IsSupported) {\r\n scene!._removePendingData(token);\r\n return reject(\"Particle system with GPU is not supported.\");\r\n }\r\n\r\n Tools.LoadFile(\r\n `${ParticleHelper.BaseAssetsUrl}/systems/${type}.json`,\r\n (data) => {\r\n scene!._removePendingData(token);\r\n const newData = JSON.parse(data.toString());\r\n return resolve(ParticleSystemSet.Parse(newData, scene!, gpu, capacity));\r\n },\r\n undefined,\r\n undefined,\r\n undefined,\r\n () => {\r\n scene!._removePendingData(token);\r\n return reject(`An error occurred with the creation of your particle system. Check if your type '${type}' exists.`);\r\n }\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Static function used to export a particle system to a ParticleSystemSet variable.\r\n * Please note that the emitter shape is not exported\r\n * @param systems defines the particle systems to export\r\n * @returns the created particle system set\r\n */\r\n public static ExportSet(systems: IParticleSystem[]): ParticleSystemSet {\r\n const set = new ParticleSystemSet();\r\n\r\n for (const system of systems) {\r\n set.systems.push(system);\r\n }\r\n\r\n return set;\r\n }\r\n\r\n /**\r\n * Creates a particle system from a snippet saved in a remote file\r\n * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)\r\n * @param url defines the url to load from\r\n * @param scene defines the hosting scene\r\n * @param gpu If the system will use gpu\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @param capacity defines the system capacity (if null or undefined the sotred capacity will be used)\r\n * @returns a promise that will resolve to the new particle system\r\n */\r\n public static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu: boolean = false, rootUrl: string = \"\", capacity?: number): Promise<IParticleSystem> {\r\n return new Promise((resolve, reject) => {\r\n const request = new WebRequest();\r\n request.addEventListener(\"readystatechange\", () => {\r\n if (request.readyState == 4) {\r\n if (request.status == 200) {\r\n const serializationObject = JSON.parse(request.responseText);\r\n let output: IParticleSystem;\r\n\r\n if (gpu) {\r\n output = GPUParticleSystem.Parse(serializationObject, scene, rootUrl, false, capacity);\r\n } else {\r\n output = ParticleSystem.Parse(serializationObject, scene, rootUrl, false, capacity);\r\n }\r\n\r\n if (name) {\r\n output.name = name;\r\n }\r\n\r\n resolve(output);\r\n } else {\r\n reject(\"Unable to load the particle system\");\r\n }\r\n }\r\n });\r\n\r\n request.open(\"GET\", url);\r\n request.send();\r\n });\r\n }\r\n\r\n /**\r\n * Creates a particle system from a snippet saved by the particle system editor\r\n * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)\r\n * @param scene defines the hosting scene\r\n * @param gpu If the system will use gpu\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @param capacity defines the system capacity (if null or undefined the sotred capacity will be used)\r\n * @returns a promise that will resolve to the new particle system\r\n */\r\n public static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu: boolean = false, rootUrl: string = \"\", capacity?: number): Promise<IParticleSystem> {\r\n if (snippetId === \"_BLANK\") {\r\n const system = this.CreateDefault(null);\r\n system.start();\r\n return Promise.resolve(system);\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const request = new WebRequest();\r\n request.addEventListener(\"readystatechange\", () => {\r\n if (request.readyState == 4) {\r\n if (request.status == 200) {\r\n const snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);\r\n const serializationObject = JSON.parse(snippet.particleSystem);\r\n let output: IParticleSystem;\r\n\r\n if (gpu) {\r\n output = GPUParticleSystem.Parse(serializationObject, scene, rootUrl, false, capacity);\r\n } else {\r\n output = ParticleSystem.Parse(serializationObject, scene, rootUrl, false, capacity);\r\n }\r\n output.snippetId = snippetId;\r\n\r\n resolve(output);\r\n } else {\r\n reject(\"Unable to load the snippet \" + snippetId);\r\n }\r\n }\r\n });\r\n\r\n request.open(\"GET\", this.SnippetUrl + \"/\" + snippetId.replace(/#/g, \"/\"));\r\n request.send();\r\n });\r\n }\r\n}\r\n"]}
@@ -22,7 +22,7 @@ export declare class DepthOfFieldBlurPostProcess extends BlurPostProcess {
22
22
  */
23
23
  getClassName(): string;
24
24
  /**
25
- * Creates a new instance CircleOfConfusionPostProcess
25
+ * Creates a new instance DepthOfFieldBlurPostProcess
26
26
  * @param name The name of the effect.
27
27
  * @param scene The scene the effect belongs to.
28
28
  * @param direction The direction the blur should be applied.
@@ -13,7 +13,7 @@ import { serialize } from "../Misc/decorators.js";
13
13
  var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
14
14
  __extends(DepthOfFieldBlurPostProcess, _super);
15
15
  /**
16
- * Creates a new instance CircleOfConfusionPostProcess
16
+ * Creates a new instance DepthOfFieldBlurPostProcess
17
17
  * @param name The name of the effect.
18
18
  * @param scene The scene the effect belongs to.
19
19
  * @param direction The direction the blur should be applied.
@@ -35,9 +35,7 @@ var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
35
35
  if (blockCompilation === void 0) { blockCompilation = false; }
36
36
  var _this = _super.call(this, name, direction, kernel, options, camera,
37
37
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
38
- (samplingMode = 2), engine, reusable,
39
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
40
- (textureType = 0), "#define DOF 1\r\n", blockCompilation) || this;
38
+ (samplingMode = 2), engine, reusable, textureType, "#define DOF 1\r\n", blockCompilation) || this;
41
39
  _this.direction = direction;
42
40
  _this.externalTextureSamplerBinding = !!imageToBlur;
43
41
  _this.onApplyObservable.add(function (effect) {
@@ -1 +1 @@
1
- {"version":3,"file":"depthOfFieldBlurPostProcess.js","sourceRoot":"","sources":["../../../../../lts/core/generated/PostProcesses/depthOfFieldBlurPostProcess.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;GAKG;AACH;IAAiD,+CAAe;IAe5D;;;;;;;;;;;;;;;OAeG;IACH,qCACI,IAAY,EACZ,KAAY,EACZ,SAAkB,EAClB,MAAc,EACd,OAAoC,EACpC,MAAwB,EACxB,iBAA8B,EAC9B,WAAyC,EACzC,YAAoD,EACpD,MAAe,EACf,QAAkB,EAClB,WAAwD,EACxD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.vector\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { PostProcess, PostProcessOptions } from \"./postProcess\";\r\nimport { BlurPostProcess } from \"./blurPostProcess\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { serialize } from \"../Misc/decorators\";\r\n\r\n/**\r\n * The DepthOfFieldBlurPostProcess applied a blur in a give direction.\r\n * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels\r\n * based on samples that have a large difference in distance than the center pixel.\r\n * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf\r\n */\r\nexport class DepthOfFieldBlurPostProcess extends BlurPostProcess {\r\n /**\r\n * The direction the blur should be applied\r\n */\r\n @serialize()\r\n public direction: Vector2;\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"DepthOfFieldBlurPostProcess\" string\r\n */\r\n public getClassName(): string {\r\n return \"DepthOfFieldBlurPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance CircleOfConfusionPostProcess\r\n * @param name The name of the effect.\r\n * @param scene The scene the effect belongs to.\r\n * @param direction The direction the blur should be applied.\r\n * @param kernel The size of the kernel used to blur.\r\n * @param options The required width/height ratio to downsize to before computing the render pass.\r\n * @param camera The camera to apply the render pass to.\r\n * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges\r\n * @param imageToBlur The image to apply the blur to (default: Current rendered frame)\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)\r\n * @param engine The engine which the post process will be applied. (default: current engine)\r\n * @param reusable If the post process can be reused on the same frame. (default: false)\r\n * @param textureType Type of textures used when performing the post process. (default: 0)\r\n * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)\r\n */\r\n constructor(\r\n name: string,\r\n scene: Scene,\r\n direction: Vector2,\r\n kernel: number,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n circleOfConfusion: PostProcess,\r\n imageToBlur: Nullable<PostProcess> = null,\r\n samplingMode: number = Texture.BILINEAR_SAMPLINGMODE,\r\n engine?: Engine,\r\n reusable?: boolean,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n blockCompilation = false\r\n ) {\r\n super(\r\n name,\r\n direction,\r\n kernel,\r\n options,\r\n camera,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n (samplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE),\r\n engine,\r\n reusable,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n (textureType = Constants.TEXTURETYPE_UNSIGNED_INT),\r\n `#define DOF 1\\r\\n`,\r\n blockCompilation\r\n );\r\n\r\n this.direction = direction;\r\n this.externalTextureSamplerBinding = !!imageToBlur;\r\n\r\n this.onApplyObservable.add((effect: Effect) => {\r\n if (imageToBlur != null) {\r\n effect.setTextureFromPostProcess(\"textureSampler\", imageToBlur);\r\n }\r\n effect.setTextureFromPostProcessOutput(\"circleOfConfusionSampler\", circleOfConfusion);\r\n if (scene.activeCamera) {\r\n effect.setFloat2(\"cameraMinMaxZ\", scene.activeCamera.minZ, scene.activeCamera.maxZ);\r\n }\r\n });\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.DepthOfFieldBlurPostProcess\", DepthOfFieldBlurPostProcess);\r\n"]}
1
+ {"version":3,"file":"depthOfFieldBlurPostProcess.js","sourceRoot":"","sources":["../../../../../lts/core/generated/PostProcesses/depthOfFieldBlurPostProcess.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC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AlED;;;OAGG;IACI,kDAAY,GAAnB;QACI,OAAO,6BAA6B,CAAC;IACzC,CAAC;IARD;QADC,SAAS,EAAE;kEACc;IAqE9B,kCAAC;CAAA,AA1ED,CAAiD,eAAe,GA0E/D;SA1EY,2BAA2B;AA4ExC,aAAa,CAAC,qCAAqC,EAAE,2BAA2B,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Vector2 } from \"../Maths/math.vector\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { PostProcess, PostProcessOptions } from \"./postProcess\";\r\nimport { BlurPostProcess } from \"./blurPostProcess\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { serialize } from \"../Misc/decorators\";\r\n\r\n/**\r\n * The DepthOfFieldBlurPostProcess applied a blur in a give direction.\r\n * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels\r\n * based on samples that have a large difference in distance than the center pixel.\r\n * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf\r\n */\r\nexport class DepthOfFieldBlurPostProcess extends BlurPostProcess {\r\n /**\r\n * The direction the blur should be applied\r\n */\r\n @serialize()\r\n public direction: Vector2;\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"DepthOfFieldBlurPostProcess\" string\r\n */\r\n public getClassName(): string {\r\n return \"DepthOfFieldBlurPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance DepthOfFieldBlurPostProcess\r\n * @param name The name of the effect.\r\n * @param scene The scene the effect belongs to.\r\n * @param direction The direction the blur should be applied.\r\n * @param kernel The size of the kernel used to blur.\r\n * @param options The required width/height ratio to downsize to before computing the render pass.\r\n * @param camera The camera to apply the render pass to.\r\n * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges\r\n * @param imageToBlur The image to apply the blur to (default: Current rendered frame)\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)\r\n * @param engine The engine which the post process will be applied. (default: current engine)\r\n * @param reusable If the post process can be reused on the same frame. (default: false)\r\n * @param textureType Type of textures used when performing the post process. (default: 0)\r\n * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)\r\n */\r\n constructor(\r\n name: string,\r\n scene: Scene,\r\n direction: Vector2,\r\n kernel: number,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n circleOfConfusion: PostProcess,\r\n imageToBlur: Nullable<PostProcess> = null,\r\n samplingMode: number = Texture.BILINEAR_SAMPLINGMODE,\r\n engine?: Engine,\r\n reusable?: boolean,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n blockCompilation = false\r\n ) {\r\n super(\r\n name,\r\n direction,\r\n kernel,\r\n options,\r\n camera,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n (samplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE),\r\n engine,\r\n reusable,\r\n textureType,\r\n `#define DOF 1\\r\\n`,\r\n blockCompilation\r\n );\r\n\r\n this.direction = direction;\r\n this.externalTextureSamplerBinding = !!imageToBlur;\r\n\r\n this.onApplyObservable.add((effect: Effect) => {\r\n if (imageToBlur != null) {\r\n effect.setTextureFromPostProcess(\"textureSampler\", imageToBlur);\r\n }\r\n effect.setTextureFromPostProcessOutput(\"circleOfConfusionSampler\", circleOfConfusion);\r\n if (scene.activeCamera) {\r\n effect.setFloat2(\"cameraMinMaxZ\", scene.activeCamera.minZ, scene.activeCamera.maxZ);\r\n }\r\n });\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.DepthOfFieldBlurPostProcess\", DepthOfFieldBlurPostProcess);\r\n"]}
@@ -158,11 +158,15 @@ export declare class GeometryBufferRenderer {
158
158
  */
159
159
  set enableVelocity(enable: boolean);
160
160
  /**
161
- * Gets a boolean indicating if objects roughness are enabled in the G buffer.
161
+ * Gets a boolean indicating if objects reflectivity are enabled in the G buffer.
162
162
  */
163
163
  get enableReflectivity(): boolean;
164
164
  /**
165
- * Sets whether or not objects roughness are enabled for the G buffer.
165
+ * Sets whether or not objects reflectivity are enabled for the G buffer.
166
+ * For Metallic-Roughness workflow with ORM texture, we assume that ORM texture is defined according to the default layout:
167
+ * pbr.useRoughnessFromMetallicTextureAlpha = false;
168
+ * pbr.useRoughnessFromMetallicTextureGreen = true;
169
+ * pbr.useMetallnessFromMetallicTextureBlue = true;
166
170
  */
167
171
  set enableReflectivity(enable: boolean);
168
172
  /**
@@ -229,13 +229,17 @@ var GeometryBufferRenderer = /** @class */ (function () {
229
229
  });
230
230
  Object.defineProperty(GeometryBufferRenderer.prototype, "enableReflectivity", {
231
231
  /**
232
- * Gets a boolean indicating if objects roughness are enabled in the G buffer.
232
+ * Gets a boolean indicating if objects reflectivity are enabled in the G buffer.
233
233
  */
234
234
  get: function () {
235
235
  return this._enableReflectivity;
236
236
  },
237
237
  /**
238
- * Sets whether or not objects roughness are enabled for the G buffer.
238
+ * Sets whether or not objects reflectivity are enabled for the G buffer.
239
+ * For Metallic-Roughness workflow with ORM texture, we assume that ORM texture is defined according to the default layout:
240
+ * pbr.useRoughnessFromMetallicTextureAlpha = false;
241
+ * pbr.useRoughnessFromMetallicTextureGreen = true;
242
+ * pbr.useMetallnessFromMetallicTextureBlue = true;
239
243
  */
240
244
  set: function (enable) {
241
245
  this._enableReflectivity = enable;
@@ -296,15 +300,123 @@ var GeometryBufferRenderer = /** @class */ (function () {
296
300
  needUv = true;
297
301
  }
298
302
  if (this._enableReflectivity) {
299
- if (material.specularTexture) {
300
- defines.push("#define HAS_SPECULAR");
301
- defines.push("#define REFLECTIVITY_UV".concat(material.specularTexture.coordinatesIndex + 1));
302
- needUv = true;
303
+ var metallicWorkflow = false;
304
+ // for PBR materials: cf. https://doc.babylonjs.com/divingDeeper/materials/using/masterPBR
305
+ if (material.getClassName() === "PBRMetallicRoughnessMaterial") {
306
+ // if it is a PBR material in MetallicRoughness Mode:
307
+ if (material.metallicRoughnessTexture !== null) {
308
+ defines.push("#define ORMTEXTURE");
309
+ defines.push("#define REFLECTIVITY_UV".concat(material.metallicRoughnessTexture.coordinatesIndex + 1));
310
+ defines.push("#define METALLICWORKFLOW");
311
+ needUv = true;
312
+ metallicWorkflow = true;
313
+ }
314
+ if (material.metallic !== null) {
315
+ defines.push("#define METALLIC");
316
+ defines.push("#define METALLICWORKFLOW");
317
+ metallicWorkflow = true;
318
+ }
319
+ if (material.roughness !== null) {
320
+ defines.push("#define ROUGHNESS");
321
+ defines.push("#define METALLICWORKFLOW");
322
+ metallicWorkflow = true;
323
+ }
324
+ if (metallicWorkflow) {
325
+ if (material.baseTexture !== null) {
326
+ defines.push("#define ALBEDOTEXTURE");
327
+ defines.push("#define ALBEDO_UV".concat(material.baseTexture.coordinatesIndex + 1));
328
+ if (material.baseTexture.gammaSpace) {
329
+ defines.push("#define GAMMAALBEDO");
330
+ }
331
+ needUv = true;
332
+ }
333
+ if (material.baseColor !== null) {
334
+ defines.push("#define ALBEDOCOLOR");
335
+ }
336
+ }
337
+ }
338
+ else if (material.getClassName() === "PBRSpecularGlossinessMaterial") {
339
+ // if it is a PBR material in Specular/Glossiness Mode:
340
+ if (material.specularGlossinessTexture !== null) {
341
+ defines.push("#define SPECULARGLOSSINESSTEXTURE");
342
+ defines.push("#define REFLECTIVITY_UV".concat(material.specularGlossinessTexture.coordinatesIndex + 1));
343
+ needUv = true;
344
+ if (material.specularGlossinessTexture.gammaSpace) {
345
+ defines.push("#define GAMMAREFLECTIVITYTEXTURE");
346
+ }
347
+ }
348
+ else {
349
+ if (material.specularColor !== null) {
350
+ defines.push("#define REFLECTIVITYCOLOR");
351
+ }
352
+ }
353
+ if (material.glossiness !== null) {
354
+ defines.push("#define GLOSSINESSS");
355
+ }
356
+ }
357
+ else if (material.getClassName() === "PBRMaterial") {
358
+ // if it is the bigger PBRMaterial
359
+ if (material.metallicTexture !== null) {
360
+ defines.push("#define ORMTEXTURE");
361
+ defines.push("#define REFLECTIVITY_UV".concat(material.metallicTexture.coordinatesIndex + 1));
362
+ defines.push("#define METALLICWORKFLOW");
363
+ needUv = true;
364
+ metallicWorkflow = true;
365
+ }
366
+ if (material.metallic !== null) {
367
+ defines.push("#define METALLIC");
368
+ defines.push("#define METALLICWORKFLOW");
369
+ metallicWorkflow = true;
370
+ }
371
+ if (material.roughness !== null) {
372
+ defines.push("#define ROUGHNESS");
373
+ defines.push("#define METALLICWORKFLOW");
374
+ metallicWorkflow = true;
375
+ }
376
+ if (metallicWorkflow) {
377
+ if (material.albedoTexture !== null) {
378
+ defines.push("#define ALBEDOTEXTURE");
379
+ defines.push("#define ALBEDO_UV".concat(material.albedoTexture.coordinatesIndex + 1));
380
+ if (material.albedoTexture.gammaSpace) {
381
+ defines.push("#define GAMMAALBEDO");
382
+ }
383
+ needUv = true;
384
+ }
385
+ if (material.albedoColor !== null) {
386
+ defines.push("#define ALBEDOCOLOR");
387
+ }
388
+ }
389
+ else {
390
+ // SpecularGlossiness Model
391
+ if (material.reflectivityTexture !== null) {
392
+ defines.push("#define SPECULARGLOSSINESSTEXTURE");
393
+ defines.push("#define REFLECTIVITY_UV".concat(material.reflectivityTexture.coordinatesIndex + 1));
394
+ if (material.reflectivityTexture.gammaSpace) {
395
+ defines.push("#define GAMMAREFLECTIVITYTEXTURE");
396
+ }
397
+ needUv = true;
398
+ }
399
+ else if (material.reflectivityColor !== null) {
400
+ defines.push("#define REFLECTIVITYCOLOR");
401
+ }
402
+ if (material.microSurface !== null) {
403
+ defines.push("#define GLOSSINESSS");
404
+ }
405
+ }
303
406
  }
304
- else if (material.reflectivityTexture) {
305
- defines.push("#define HAS_REFLECTIVITY");
306
- defines.push("#define REFLECTIVITY_UV".concat(material.reflectivityTexture.coordinatesIndex + 1));
307
- needUv = true;
407
+ else if (material.getClassName() === "StandardMaterial") {
408
+ // if StandardMaterial:
409
+ if (material.specularTexture !== null) {
410
+ defines.push("#define REFLECTIVITYTEXTURE");
411
+ defines.push("#define REFLECTIVITY_UV".concat(material.specularTexture.coordinatesIndex + 1));
412
+ if (material.specularTexture.gammaSpace) {
413
+ defines.push("#define GAMMAREFLECTIVITYTEXTURE");
414
+ }
415
+ needUv = true;
416
+ }
417
+ if (material.specularColor !== null) {
418
+ defines.push("#define REFLECTIVITYCOLOR");
419
+ }
308
420
  }
309
421
  }
310
422
  if (needUv) {
@@ -408,13 +520,18 @@ var GeometryBufferRenderer = /** @class */ (function () {
408
520
  "mPreviousBones",
409
521
  "bumpMatrix",
410
522
  "reflectivityMatrix",
523
+ "albedoMatrix",
524
+ "reflectivityColor",
525
+ "albedoColor",
526
+ "metallic",
527
+ "glossiness",
411
528
  "vTangentSpaceParams",
412
529
  "vBumpInfos",
413
530
  "morphTargetInfluences",
414
531
  "morphTargetTextureInfo",
415
532
  "morphTargetTextureIndices",
416
533
  ],
417
- samplers: ["diffuseSampler", "bumpSampler", "reflectivitySampler", "morphTargets"],
534
+ samplers: ["diffuseSampler", "bumpSampler", "reflectivitySampler", "albedoSampler", "morphTargets"],
418
535
  defines: join,
419
536
  onCompiled: null,
420
537
  fallbacks: null,
@@ -588,15 +705,89 @@ var GeometryBufferRenderer = /** @class */ (function () {
588
705
  effect_1.setTexture("bumpSampler", material.bumpTexture);
589
706
  effect_1.setFloat2("vTangentSpaceParams", material.invertNormalMapX ? -1.0 : 1.0, material.invertNormalMapY ? -1.0 : 1.0);
590
707
  }
591
- // Roughness
708
+ // Reflectivity
592
709
  if (_this._enableReflectivity) {
593
- if (material.specularTexture) {
594
- effect_1.setMatrix("reflectivityMatrix", material.specularTexture.getTextureMatrix());
595
- effect_1.setTexture("reflectivitySampler", material.specularTexture);
710
+ // for PBR materials: cf. https://doc.babylonjs.com/divingDeeper/materials/using/masterPBR
711
+ if (material.getClassName() === "PBRMetallicRoughnessMaterial") {
712
+ // if it is a PBR material in MetallicRoughness Mode:
713
+ if (material.metallicRoughnessTexture !== null) {
714
+ effect_1.setTexture("reflectivitySampler", material.metallicRoughnessTexture);
715
+ effect_1.setMatrix("reflectivityMatrix", material.metallicRoughnessTexture.getTextureMatrix());
716
+ }
717
+ if (material.metallic !== null) {
718
+ effect_1.setFloat("metallic", material.metallic);
719
+ }
720
+ if (material.roughness !== null) {
721
+ effect_1.setFloat("glossiness", 1.0 - material.roughness);
722
+ }
723
+ if (material.baseTexture !== null) {
724
+ effect_1.setTexture("albedoSampler", material.baseTexture);
725
+ effect_1.setMatrix("albedoMatrix", material.baseTexture.getTextureMatrix());
726
+ }
727
+ if (material.baseColor !== null) {
728
+ effect_1.setColor3("albedoColor", material.baseColor);
729
+ }
730
+ }
731
+ else if (material.getClassName() === "PBRSpecularGlossinessMaterial") {
732
+ // if it is a PBR material in Specular/Glossiness Mode:
733
+ if (material.specularGlossinessTexture !== null) {
734
+ effect_1.setTexture("reflectivitySampler", material.specularGlossinessTexture);
735
+ effect_1.setMatrix("reflectivityMatrix", material.specularGlossinessTexture.getTextureMatrix());
736
+ }
737
+ else {
738
+ if (material.specularColor !== null) {
739
+ effect_1.setColor3("reflectivityColor", material.specularColor);
740
+ }
741
+ }
742
+ if (material.glossiness !== null) {
743
+ effect_1.setFloat("glossiness", material.glossiness);
744
+ }
745
+ }
746
+ else if (material.getClassName() === "PBRMaterial") {
747
+ // if it is the bigger PBRMaterial
748
+ if (material.metallicTexture !== null) {
749
+ effect_1.setTexture("reflectivitySampler", material.metallicTexture);
750
+ effect_1.setMatrix("reflectivityMatrix", material.metallicTexture.getTextureMatrix());
751
+ }
752
+ if (material.metallic !== null) {
753
+ effect_1.setFloat("metallic", material.metallic);
754
+ }
755
+ if (material.roughness !== null) {
756
+ effect_1.setFloat("glossiness", 1.0 - material.roughness);
757
+ }
758
+ if (material.roughness !== null || material.metallic !== null || material.metallicTexture !== null) {
759
+ // MetallicRoughness Model
760
+ if (material.albedoTexture !== null) {
761
+ effect_1.setTexture("albedoSampler", material.albedoTexture);
762
+ effect_1.setMatrix("albedoMatrix", material.albedoTexture.getTextureMatrix());
763
+ }
764
+ if (material.albedoColor !== null) {
765
+ effect_1.setColor3("albedoColor", material.albedoColor);
766
+ }
767
+ }
768
+ else {
769
+ // SpecularGlossiness Model
770
+ if (material.reflectivityTexture !== null) {
771
+ effect_1.setTexture("reflectivitySampler", material.reflectivityTexture);
772
+ effect_1.setMatrix("reflectivityMatrix", material.reflectivityTexture.getTextureMatrix());
773
+ }
774
+ else if (material.reflectivityColor !== null) {
775
+ effect_1.setColor3("reflectivityColor", material.reflectivityColor);
776
+ }
777
+ if (material.microSurface !== null) {
778
+ effect_1.setFloat("glossiness", material.microSurface);
779
+ }
780
+ }
596
781
  }
597
- else if (material.reflectivityTexture) {
598
- effect_1.setMatrix("reflectivityMatrix", material.reflectivityTexture.getTextureMatrix());
599
- effect_1.setTexture("reflectivitySampler", material.reflectivityTexture);
782
+ else if (material.getClassName() === "StandardMaterial") {
783
+ // if StandardMaterial:
784
+ if (material.specularTexture !== null) {
785
+ effect_1.setTexture("reflectivitySampler", material.specularTexture);
786
+ effect_1.setMatrix("reflectivityMatrix", material.specularTexture.getTextureMatrix());
787
+ }
788
+ if (material.specularColor !== null) {
789
+ effect_1.setColor3("reflectivityColor", material.specularColor);
790
+ }
600
791
  }
601
792
  }
602
793
  }