@babylonjs/core 5.33.2 → 5.34.0

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 (70) hide show
  1. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +4 -3
  2. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
  3. package/Engines/thinEngine.js +2 -2
  4. package/Engines/thinEngine.js.map +1 -1
  5. package/Lights/Shadows/shadowGenerator.js +1 -0
  6. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  7. package/Materials/Node/Blocks/Dual/lightBlock.d.ts +4 -0
  8. package/Materials/Node/Blocks/Dual/lightBlock.js +47 -3
  9. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  10. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.d.ts +6 -0
  11. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +36 -8
  12. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
  13. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.d.ts +2 -0
  14. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js +22 -0
  15. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js.map +1 -1
  16. package/Materials/Node/Blocks/Fragment/fragDepthBlock.d.ts +31 -0
  17. package/Materials/Node/Blocks/Fragment/fragDepthBlock.js +67 -0
  18. package/Materials/Node/Blocks/Fragment/fragDepthBlock.js.map +1 -0
  19. package/Materials/Node/Blocks/Fragment/index.d.ts +2 -0
  20. package/Materials/Node/Blocks/Fragment/index.js +2 -0
  21. package/Materials/Node/Blocks/Fragment/index.js.map +1 -1
  22. package/Materials/Node/Blocks/Fragment/shadowMapBlock.d.ts +40 -0
  23. package/Materials/Node/Blocks/Fragment/shadowMapBlock.js +111 -0
  24. package/Materials/Node/Blocks/Fragment/shadowMapBlock.js.map +1 -0
  25. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.d.ts +4 -0
  26. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +50 -3
  27. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  28. package/Materials/Node/Blocks/PBR/reflectionBlock.d.ts +2 -0
  29. package/Materials/Node/Blocks/PBR/reflectionBlock.js +18 -1
  30. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  31. package/Materials/Node/Blocks/biPlanarBlock.d.ts +18 -0
  32. package/Materials/Node/Blocks/biPlanarBlock.js +70 -0
  33. package/Materials/Node/Blocks/biPlanarBlock.js.map +1 -0
  34. package/Materials/Node/Blocks/index.d.ts +2 -0
  35. package/Materials/Node/Blocks/index.js +2 -0
  36. package/Materials/Node/Blocks/index.js.map +1 -1
  37. package/Materials/Node/Blocks/triPlanarBlock.d.ts +116 -0
  38. package/Materials/Node/Blocks/triPlanarBlock.js +340 -0
  39. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -0
  40. package/Materials/Node/nodeMaterial.d.ts +4 -1
  41. package/Materials/Node/nodeMaterial.js +8 -0
  42. package/Materials/Node/nodeMaterial.js.map +1 -1
  43. package/Materials/Node/nodeMaterialBlock.d.ts +2 -0
  44. package/Materials/Node/nodeMaterialBlock.js +5 -0
  45. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  46. package/Materials/Node/nodeMaterialBuildState.d.ts +2 -0
  47. package/Materials/Node/nodeMaterialBuildState.js +3 -3
  48. package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
  49. package/Materials/Node/nodeMaterialBuildStateSharedData.d.ts +2 -1
  50. package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
  51. package/Materials/Node/nodeMaterialDecorator.d.ts +4 -1
  52. package/Materials/Node/nodeMaterialDecorator.js.map +1 -1
  53. package/Materials/PBR/pbrBaseMaterial.d.ts +2 -0
  54. package/Materials/PBR/pbrBaseMaterial.js +11 -0
  55. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  56. package/Materials/Textures/videoTexture.js +8 -35
  57. package/Materials/Textures/videoTexture.js.map +1 -1
  58. package/Materials/materialHelper.d.ts +7 -0
  59. package/Materials/materialHelper.js +22 -1
  60. package/Materials/materialHelper.js.map +1 -1
  61. package/Materials/shadowDepthWrapper.d.ts +4 -0
  62. package/Materials/shadowDepthWrapper.js +46 -39
  63. package/Materials/shadowDepthWrapper.js.map +1 -1
  64. package/Materials/standardMaterial.d.ts +2 -0
  65. package/Materials/standardMaterial.js +2 -0
  66. package/Materials/standardMaterial.js.map +1 -1
  67. package/package.json +1 -1
  68. package/scene.d.ts +12 -8
  69. package/scene.js +32 -27
  70. package/scene.js.map +1 -1
@@ -8,6 +8,25 @@ import { ReflectionTextureBaseBlock } from "./reflectionTextureBaseBlock.js";
8
8
  * Block used to read a reflection texture from a sampler
9
9
  */
10
10
  export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
11
+ _onGenerateOnlyFragmentCodeChanged() {
12
+ if (this.position.isConnected) {
13
+ this.generateOnlyFragmentCode = !this.generateOnlyFragmentCode;
14
+ console.error("The position input must not be connected to be able to switch!");
15
+ return false;
16
+ }
17
+ if (this.worldPosition.isConnected) {
18
+ this.generateOnlyFragmentCode = !this.generateOnlyFragmentCode;
19
+ console.error("The worldPosition input must not be connected to be able to switch!");
20
+ return false;
21
+ }
22
+ this._setTarget();
23
+ return true;
24
+ }
25
+ _setTarget() {
26
+ super._setTarget();
27
+ this.getInputByName("position").target = this.generateOnlyFragmentCode ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.Vertex;
28
+ this.getInputByName("worldPosition").target = this.generateOnlyFragmentCode ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.Vertex;
29
+ }
11
30
  /**
12
31
  * Create a new ReflectionTextureBlock
13
32
  * @param name defines the block name
@@ -128,6 +147,9 @@ export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
128
147
  state.compilationString += this.handleVertexSide(state);
129
148
  return this;
130
149
  }
150
+ if (this.generateOnlyFragmentCode) {
151
+ state.compilationString += this.handleVertexSide(state);
152
+ }
131
153
  this.handleFragmentSideInits(state);
132
154
  const normalWUnit = state._getFreeVariableName("normalWUnit");
133
155
  state.compilationString += `vec4 ${normalWUnit} = normalize(${this.worldNormal.associatedVariableName});\r\n`;
@@ -1 +1 @@
1
- {"version":3,"file":"reflectionTextureBlock.js","sourceRoot":"","sources":["../../../../../../../../lts/core/generated/Materials/Node/Blocks/Dual/reflectionTextureBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAGhF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,0BAA0B;IAClE;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,OAAO,EAAE,KAAK,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QACtH,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,qCAAqC,CAAC,OAAO,EAAE,KAAK,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;QAC3H,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,qCAAqC,CAAC,OAAO,EAAE,KAAK,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC,qEAAqE;QACjM,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,MAAM,EAAE,KAAK,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC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AAC","sourcesContent":["import { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport type { NodeMaterial } from \"../../nodeMaterial\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { InputBlock } from \"../Input/inputBlock\";\r\nimport { NodeMaterialSystemValues } from \"../../Enums/nodeMaterialSystemValues\";\r\nimport { ReflectionTextureBaseBlock } from \"./reflectionTextureBaseBlock\";\r\n\r\n/**\r\n * Block used to read a reflection texture from a sampler\r\n */\r\nexport class ReflectionTextureBlock extends ReflectionTextureBaseBlock {\r\n /**\r\n * Create a new ReflectionTextureBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"position\", NodeMaterialBlockConnectionPointTypes.Vector3, false, NodeMaterialBlockTargets.Vertex);\r\n this.registerInput(\"worldPosition\", NodeMaterialBlockConnectionPointTypes.Vector4, false, NodeMaterialBlockTargets.Vertex);\r\n this.registerInput(\"worldNormal\", NodeMaterialBlockConnectionPointTypes.Vector4, false, NodeMaterialBlockTargets.Fragment); // Flagging as fragment as the normal can be changed by fragment code\r\n this.registerInput(\"world\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\r\n\r\n this.registerInput(\"cameraPosition\", NodeMaterialBlockConnectionPointTypes.Vector3, false, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\"view\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerOutput(\"rgb\", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);\r\n this.registerOutput(\"rgba\", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment);\r\n this.registerOutput(\"r\", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);\r\n this.registerOutput(\"g\", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);\r\n this.registerOutput(\"b\", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);\r\n this.registerOutput(\"a\", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);\r\n\r\n this._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"ReflectionTextureBlock\";\r\n }\r\n\r\n /**\r\n * Gets the world position input component\r\n */\r\n public get position(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the world position input component\r\n */\r\n public get worldPosition(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the world normal input component\r\n */\r\n public get worldNormal(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the world input component\r\n */\r\n public get world(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the camera (or eye) position component\r\n */\r\n public get cameraPosition(): NodeMaterialConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the view input component\r\n */\r\n public get view(): NodeMaterialConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the rgb output component\r\n */\r\n public get rgb(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the rgba output component\r\n */\r\n public get rgba(): NodeMaterialConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n /**\r\n * Gets the r output component\r\n */\r\n public get r(): NodeMaterialConnectionPoint {\r\n return this._outputs[2];\r\n }\r\n\r\n /**\r\n * Gets the g output component\r\n */\r\n public get g(): NodeMaterialConnectionPoint {\r\n return this._outputs[3];\r\n }\r\n\r\n /**\r\n * Gets the b output component\r\n */\r\n public get b(): NodeMaterialConnectionPoint {\r\n return this._outputs[4];\r\n }\r\n\r\n /**\r\n * Gets the a output component\r\n */\r\n public get a(): NodeMaterialConnectionPoint {\r\n return this._outputs[5];\r\n }\r\n\r\n public autoConfigure(material: NodeMaterial) {\r\n super.autoConfigure(material);\r\n\r\n if (!this.cameraPosition.isConnected) {\r\n let cameraPositionInput = material.getInputBlockByPredicate((b) => b.systemValue === NodeMaterialSystemValues.CameraPosition);\r\n\r\n if (!cameraPositionInput) {\r\n cameraPositionInput = new InputBlock(\"cameraPosition\");\r\n cameraPositionInput.setAsSystemValue(NodeMaterialSystemValues.CameraPosition);\r\n }\r\n cameraPositionInput.output.connectTo(this.cameraPosition);\r\n }\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (!this.texture) {\r\n state.compilationString += this.writeOutputs(state, \"vec4(0.)\");\r\n return this;\r\n }\r\n\r\n if (state.target !== NodeMaterialBlockTargets.Fragment) {\r\n state.compilationString += this.handleVertexSide(state);\r\n return this;\r\n }\r\n\r\n this.handleFragmentSideInits(state);\r\n\r\n const normalWUnit = state._getFreeVariableName(\"normalWUnit\");\r\n\r\n state.compilationString += `vec4 ${normalWUnit} = normalize(${this.worldNormal.associatedVariableName});\\r\\n`;\r\n\r\n state.compilationString += this.handleFragmentSideCodeReflectionCoords(normalWUnit);\r\n\r\n state.compilationString += this.handleFragmentSideCodeReflectionColor(undefined, \"\");\r\n\r\n state.compilationString += this.writeOutputs(state, this._reflectionColorName);\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ReflectionTextureBlock\", ReflectionTextureBlock);\r\n"]}
1
+ {"version":3,"file":"reflectionTextureBlock.js","sourceRoot":"","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AAC,CAAC;YACxD,OAAO,IAAI,CAAC;SACf;QAED,IAAI,IAAI,CAAC,wBAAwB,EAAE;YAC/B,KAAK,CAAC,iBAAiB,IAAI,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;SAC3D;QAED,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAEpC,MAAM,WAAW,GAAG,KAAK,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC;QAE9D,KAAK,CAAC,iBAAiB,IAAI,QAAQ,WAAW,gBAAgB,IAAI,CAAC,WAAW,CAAC,sBAAsB,QAAQ,CAAC;QAE9G,KAAK,CAAC,iBAAiB,IAAI,IAAI,CAAC,sCAAsC,CAAC,WAAW,CAAC,CAAC;QAEpF,KAAK,CAAC,iBAAiB,IAAI,IAAI,CAAC,qCAAqC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAErF,KAAK,CAAC,iBAAiB,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAE/E,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,gCAAgC,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport type { NodeMaterial } from \"../../nodeMaterial\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { InputBlock } from \"../Input/inputBlock\";\r\nimport { NodeMaterialSystemValues } from \"../../Enums/nodeMaterialSystemValues\";\r\nimport { ReflectionTextureBaseBlock } from \"./reflectionTextureBaseBlock\";\r\n\r\n/**\r\n * Block used to read a reflection texture from a sampler\r\n */\r\nexport class ReflectionTextureBlock extends ReflectionTextureBaseBlock {\r\n protected _onGenerateOnlyFragmentCodeChanged(): boolean {\r\n if (this.position.isConnected) {\r\n this.generateOnlyFragmentCode = !this.generateOnlyFragmentCode;\r\n console.error(\"The position input must not be connected to be able to switch!\");\r\n return false;\r\n }\r\n\r\n if (this.worldPosition.isConnected) {\r\n this.generateOnlyFragmentCode = !this.generateOnlyFragmentCode;\r\n console.error(\"The worldPosition input must not be connected to be able to switch!\");\r\n return false;\r\n }\r\n\r\n this._setTarget();\r\n\r\n return true;\r\n }\r\n\r\n protected _setTarget(): void {\r\n super._setTarget();\r\n this.getInputByName(\"position\")!.target = this.generateOnlyFragmentCode ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.Vertex;\r\n this.getInputByName(\"worldPosition\")!.target = this.generateOnlyFragmentCode ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.Vertex;\r\n }\r\n\r\n /**\r\n * Create a new ReflectionTextureBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"position\", NodeMaterialBlockConnectionPointTypes.Vector3, false, NodeMaterialBlockTargets.Vertex);\r\n this.registerInput(\"worldPosition\", NodeMaterialBlockConnectionPointTypes.Vector4, false, NodeMaterialBlockTargets.Vertex);\r\n this.registerInput(\"worldNormal\", NodeMaterialBlockConnectionPointTypes.Vector4, false, NodeMaterialBlockTargets.Fragment); // Flagging as fragment as the normal can be changed by fragment code\r\n this.registerInput(\"world\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\r\n\r\n this.registerInput(\"cameraPosition\", NodeMaterialBlockConnectionPointTypes.Vector3, false, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\"view\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerOutput(\"rgb\", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);\r\n this.registerOutput(\"rgba\", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment);\r\n this.registerOutput(\"r\", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);\r\n this.registerOutput(\"g\", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);\r\n this.registerOutput(\"b\", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);\r\n this.registerOutput(\"a\", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);\r\n\r\n this._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"ReflectionTextureBlock\";\r\n }\r\n\r\n /**\r\n * Gets the world position input component\r\n */\r\n public get position(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the world position input component\r\n */\r\n public get worldPosition(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the world normal input component\r\n */\r\n public get worldNormal(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the world input component\r\n */\r\n public get world(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the camera (or eye) position component\r\n */\r\n public get cameraPosition(): NodeMaterialConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the view input component\r\n */\r\n public get view(): NodeMaterialConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the rgb output component\r\n */\r\n public get rgb(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the rgba output component\r\n */\r\n public get rgba(): NodeMaterialConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n /**\r\n * Gets the r output component\r\n */\r\n public get r(): NodeMaterialConnectionPoint {\r\n return this._outputs[2];\r\n }\r\n\r\n /**\r\n * Gets the g output component\r\n */\r\n public get g(): NodeMaterialConnectionPoint {\r\n return this._outputs[3];\r\n }\r\n\r\n /**\r\n * Gets the b output component\r\n */\r\n public get b(): NodeMaterialConnectionPoint {\r\n return this._outputs[4];\r\n }\r\n\r\n /**\r\n * Gets the a output component\r\n */\r\n public get a(): NodeMaterialConnectionPoint {\r\n return this._outputs[5];\r\n }\r\n\r\n public autoConfigure(material: NodeMaterial) {\r\n super.autoConfigure(material);\r\n\r\n if (!this.cameraPosition.isConnected) {\r\n let cameraPositionInput = material.getInputBlockByPredicate((b) => b.systemValue === NodeMaterialSystemValues.CameraPosition);\r\n\r\n if (!cameraPositionInput) {\r\n cameraPositionInput = new InputBlock(\"cameraPosition\");\r\n cameraPositionInput.setAsSystemValue(NodeMaterialSystemValues.CameraPosition);\r\n }\r\n cameraPositionInput.output.connectTo(this.cameraPosition);\r\n }\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (!this.texture) {\r\n state.compilationString += this.writeOutputs(state, \"vec4(0.)\");\r\n return this;\r\n }\r\n\r\n if (state.target !== NodeMaterialBlockTargets.Fragment) {\r\n state.compilationString += this.handleVertexSide(state);\r\n return this;\r\n }\r\n\r\n if (this.generateOnlyFragmentCode) {\r\n state.compilationString += this.handleVertexSide(state);\r\n }\r\n\r\n this.handleFragmentSideInits(state);\r\n\r\n const normalWUnit = state._getFreeVariableName(\"normalWUnit\");\r\n\r\n state.compilationString += `vec4 ${normalWUnit} = normalize(${this.worldNormal.associatedVariableName});\\r\\n`;\r\n\r\n state.compilationString += this.handleFragmentSideCodeReflectionCoords(normalWUnit);\r\n\r\n state.compilationString += this.handleFragmentSideCodeReflectionColor(undefined, \"\");\r\n\r\n state.compilationString += this.writeOutputs(state, this._reflectionColorName);\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ReflectionTextureBlock\", ReflectionTextureBlock);\r\n"]}
@@ -0,0 +1,31 @@
1
+ import { NodeMaterialBlock } from "../../nodeMaterialBlock";
2
+ import type { NodeMaterialBuildState } from "../../nodeMaterialBuildState";
3
+ import type { NodeMaterialConnectionPoint } from "../../nodeMaterialBlockConnectionPoint";
4
+ /**
5
+ * Block used to write the fragment depth
6
+ */
7
+ export declare class FragDepthBlock extends NodeMaterialBlock {
8
+ /**
9
+ * Create a new FragDepthBlock
10
+ * @param name defines the block name
11
+ */
12
+ constructor(name: string);
13
+ /**
14
+ * Gets the current class name
15
+ * @returns the class name
16
+ */
17
+ getClassName(): string;
18
+ /**
19
+ * Gets the depth input component
20
+ */
21
+ get depth(): NodeMaterialConnectionPoint;
22
+ /**
23
+ * Gets the worldPos input component
24
+ */
25
+ get worldPos(): NodeMaterialConnectionPoint;
26
+ /**
27
+ * Gets the viewProjection input component
28
+ */
29
+ get viewProjection(): NodeMaterialConnectionPoint;
30
+ protected _buildBlock(state: NodeMaterialBuildState): this;
31
+ }
@@ -0,0 +1,67 @@
1
+ import { NodeMaterialBlock } from "../../nodeMaterialBlock.js";
2
+ import { NodeMaterialBlockConnectionPointTypes } from "../../Enums/nodeMaterialBlockConnectionPointTypes.js";
3
+ import { NodeMaterialBlockTargets } from "../../Enums/nodeMaterialBlockTargets.js";
4
+ import { RegisterClass } from "../../../../Misc/typeStore.js";
5
+ /**
6
+ * Block used to write the fragment depth
7
+ */
8
+ export class FragDepthBlock extends NodeMaterialBlock {
9
+ /**
10
+ * Create a new FragDepthBlock
11
+ * @param name defines the block name
12
+ */
13
+ constructor(name) {
14
+ super(name, NodeMaterialBlockTargets.Fragment, true);
15
+ this.registerInput("depth", NodeMaterialBlockConnectionPointTypes.Float, true);
16
+ this.registerInput("worldPos", NodeMaterialBlockConnectionPointTypes.Vector4, true);
17
+ this.registerInput("viewProjection", NodeMaterialBlockConnectionPointTypes.Matrix, true);
18
+ }
19
+ /**
20
+ * Gets the current class name
21
+ * @returns the class name
22
+ */
23
+ getClassName() {
24
+ return "FragDepthBlock";
25
+ }
26
+ /**
27
+ * Gets the depth input component
28
+ */
29
+ get depth() {
30
+ return this._inputs[0];
31
+ }
32
+ /**
33
+ * Gets the worldPos input component
34
+ */
35
+ get worldPos() {
36
+ return this._inputs[1];
37
+ }
38
+ /**
39
+ * Gets the viewProjection input component
40
+ */
41
+ get viewProjection() {
42
+ return this._inputs[2];
43
+ }
44
+ _buildBlock(state) {
45
+ super._buildBlock(state);
46
+ if (this.depth.isConnected) {
47
+ state.compilationString += `gl_FragDepth = ${this.depth.associatedVariableName};\r\n`;
48
+ }
49
+ else if (this.worldPos.isConnected && this.viewProjection.isConnected) {
50
+ state.compilationString += `
51
+ vec4 p = ${this.viewProjection.associatedVariableName} * ${this.worldPos.associatedVariableName};
52
+ float v = p.z / p.w;
53
+ #ifndef IS_NDC_HALF_ZRANGE
54
+ v = v * 0.5 + 0.5;
55
+ #endif
56
+ gl_FragDepth = v;
57
+
58
+ `;
59
+ }
60
+ else {
61
+ console.warn("FragDepthBlock: either the depth input or both the worldPos and viewProjection inputs must be connected!");
62
+ }
63
+ return this;
64
+ }
65
+ }
66
+ RegisterClass("BABYLON.FragDepthBlock", FragDepthBlock);
67
+ //# sourceMappingURL=fragDepthBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragDepthBlock.js","sourceRoot":"","sources":["../../../../../../../../lts/core/generated/Materials/Node/Blocks/Fragment/fragDepthBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAiB;IACjD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QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\n/**\r\n * Block used to write the fragment depth\r\n */\r\nexport class FragDepthBlock extends NodeMaterialBlock {\r\n /**\r\n * Create a new FragDepthBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment, true);\r\n\r\n this.registerInput(\"depth\", NodeMaterialBlockConnectionPointTypes.Float, true);\r\n this.registerInput(\"worldPos\", NodeMaterialBlockConnectionPointTypes.Vector4, true);\r\n this.registerInput(\"viewProjection\", NodeMaterialBlockConnectionPointTypes.Matrix, true);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FragDepthBlock\";\r\n }\r\n\r\n /**\r\n * Gets the depth input component\r\n */\r\n public get depth(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the worldPos input component\r\n */\r\n public get worldPos(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the viewProjection input component\r\n */\r\n public get viewProjection(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (this.depth.isConnected) {\r\n state.compilationString += `gl_FragDepth = ${this.depth.associatedVariableName};\\r\\n`;\r\n } else if (this.worldPos.isConnected && this.viewProjection.isConnected) {\r\n state.compilationString += `\r\n vec4 p = ${this.viewProjection.associatedVariableName} * ${this.worldPos.associatedVariableName};\r\n float v = p.z / p.w;\r\n #ifndef IS_NDC_HALF_ZRANGE\r\n v = v * 0.5 + 0.5;\r\n #endif\r\n gl_FragDepth = v;\r\n \r\n `;\r\n } else {\r\n console.warn(\"FragDepthBlock: either the depth input or both the worldPos and viewProjection inputs must be connected!\");\r\n }\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.FragDepthBlock\", FragDepthBlock);\r\n"]}
@@ -10,3 +10,5 @@ export * from "./screenSpaceBlock";
10
10
  export * from "./twirlBlock";
11
11
  export * from "./TBNBlock";
12
12
  export * from "./heightToNormalBlock";
13
+ export * from "./fragDepthBlock";
14
+ export * from "./shadowMapBlock";
@@ -10,4 +10,6 @@ export * from "./screenSpaceBlock.js";
10
10
  export * from "./twirlBlock.js";
11
11
  export * from "./TBNBlock.js";
12
12
  export * from "./heightToNormalBlock.js";
13
+ export * from "./fragDepthBlock.js";
14
+ export * from "./shadowMapBlock.js";
13
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../lts/core/generated/Materials/Node/Blocks/Fragment/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC","sourcesContent":["export * from \"./fragmentOutputBlock\";\r\nexport * from \"./imageProcessingBlock\";\r\nexport * from \"./perturbNormalBlock\";\r\nexport * from \"./discardBlock\";\r\nexport * from \"./frontFacingBlock\";\r\nexport * from \"./derivativeBlock\";\r\nexport * from \"./fragCoordBlock\";\r\nexport * from \"./screenSizeBlock\";\r\nexport * from \"./screenSpaceBlock\";\r\nexport * from \"./twirlBlock\";\r\nexport * from \"./TBNBlock\";\r\nexport * from \"./heightToNormalBlock\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../lts/core/generated/Materials/Node/Blocks/Fragment/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC","sourcesContent":["export * from \"./fragmentOutputBlock\";\r\nexport * from \"./imageProcessingBlock\";\r\nexport * from \"./perturbNormalBlock\";\r\nexport * from \"./discardBlock\";\r\nexport * from \"./frontFacingBlock\";\r\nexport * from \"./derivativeBlock\";\r\nexport * from \"./fragCoordBlock\";\r\nexport * from \"./screenSizeBlock\";\r\nexport * from \"./screenSpaceBlock\";\r\nexport * from \"./twirlBlock\";\r\nexport * from \"./TBNBlock\";\r\nexport * from \"./heightToNormalBlock\";\r\nexport * from \"./fragDepthBlock\";\r\nexport * from \"./shadowMapBlock\";\r\n"]}
@@ -0,0 +1,40 @@
1
+ import { NodeMaterialBlock } from "../../nodeMaterialBlock";
2
+ import type { NodeMaterialBuildState } from "../../nodeMaterialBuildState";
3
+ import type { NodeMaterialConnectionPoint } from "../../nodeMaterialBlockConnectionPoint";
4
+ /**
5
+ * Block used to output the depth to a shadow map
6
+ */
7
+ export declare class ShadowMapBlock extends NodeMaterialBlock {
8
+ /**
9
+ * Create a new ShadowMapBlock
10
+ * @param name defines the block name
11
+ */
12
+ constructor(name: string);
13
+ /**
14
+ * Gets the current class name
15
+ * @returns the class name
16
+ */
17
+ getClassName(): string;
18
+ /**
19
+ * Initialize the block and prepare the context for build
20
+ * @param state defines the state that will be used for the build
21
+ */
22
+ initialize(state: NodeMaterialBuildState): void;
23
+ /**
24
+ * Gets the world position input component
25
+ */
26
+ get worldPosition(): NodeMaterialConnectionPoint;
27
+ /**
28
+ * Gets the view x projection input component
29
+ */
30
+ get viewProjection(): NodeMaterialConnectionPoint;
31
+ /**
32
+ * Gets the world normal input component
33
+ */
34
+ get worldNormal(): NodeMaterialConnectionPoint;
35
+ /**
36
+ * Gets the depth output component
37
+ */
38
+ get depth(): NodeMaterialConnectionPoint;
39
+ protected _buildBlock(state: NodeMaterialBuildState): this;
40
+ }
@@ -0,0 +1,111 @@
1
+ import { NodeMaterialBlock } from "../../nodeMaterialBlock.js";
2
+ import { NodeMaterialBlockConnectionPointTypes } from "../../Enums/nodeMaterialBlockConnectionPointTypes.js";
3
+ import { NodeMaterialBlockTargets } from "../../Enums/nodeMaterialBlockTargets.js";
4
+ import { RegisterClass } from "../../../../Misc/typeStore.js";
5
+ /**
6
+ * Block used to output the depth to a shadow map
7
+ */
8
+ export class ShadowMapBlock extends NodeMaterialBlock {
9
+ /**
10
+ * Create a new ShadowMapBlock
11
+ * @param name defines the block name
12
+ */
13
+ constructor(name) {
14
+ super(name, NodeMaterialBlockTargets.Fragment);
15
+ this.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, false);
16
+ this.registerInput("viewProjection", NodeMaterialBlockConnectionPointTypes.Matrix, false);
17
+ this.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector3, true);
18
+ this.registerOutput("depth", NodeMaterialBlockConnectionPointTypes.Vector3);
19
+ this.worldNormal.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4);
20
+ }
21
+ /**
22
+ * Gets the current class name
23
+ * @returns the class name
24
+ */
25
+ getClassName() {
26
+ return "ShadowMapBlock";
27
+ }
28
+ /**
29
+ * Initialize the block and prepare the context for build
30
+ * @param state defines the state that will be used for the build
31
+ */
32
+ initialize(state) {
33
+ state._excludeVariableName("vPositionWSM");
34
+ state._excludeVariableName("lightDataSM");
35
+ state._excludeVariableName("biasAndScaleSM");
36
+ state._excludeVariableName("depthValuesSM");
37
+ state._excludeVariableName("clipPos");
38
+ state._excludeVariableName("worldPos");
39
+ state._excludeVariableName("zSM");
40
+ }
41
+ /**
42
+ * Gets the world position input component
43
+ */
44
+ get worldPosition() {
45
+ return this._inputs[0];
46
+ }
47
+ /**
48
+ * Gets the view x projection input component
49
+ */
50
+ get viewProjection() {
51
+ return this._inputs[1];
52
+ }
53
+ /**
54
+ * Gets the world normal input component
55
+ */
56
+ get worldNormal() {
57
+ return this._inputs[2];
58
+ }
59
+ /**
60
+ * Gets the depth output component
61
+ */
62
+ get depth() {
63
+ return this._outputs[0];
64
+ }
65
+ _buildBlock(state) {
66
+ super._buildBlock(state);
67
+ const comments = `//${this.name}`;
68
+ state._emitUniformFromString("biasAndScaleSM", "vec3");
69
+ state._emitUniformFromString("lightDataSM", "vec3");
70
+ state._emitUniformFromString("depthValuesSM", "vec2");
71
+ state._emitFunctionFromInclude("packingFunctions", comments);
72
+ state.compilationString += `vec4 worldPos = ${this.worldPosition.associatedVariableName};\r\n`;
73
+ state.compilationString += `vec3 vPositionWSM;\r\n`;
74
+ state.compilationString += `float vDepthMetricSM = 0.0;\r\n`;
75
+ state.compilationString += `float zSM;\r\n`;
76
+ if (this.worldNormal.isConnected) {
77
+ state.compilationString += `vec3 vNormalW = ${this.worldNormal.associatedVariableName}.xyz;\r\n`;
78
+ state.compilationString += state._emitCodeFromInclude("shadowMapVertexNormalBias", comments);
79
+ }
80
+ state.compilationString += `vec4 clipPos = ${this.viewProjection.associatedVariableName} * worldPos;\r\n`;
81
+ state.compilationString += state._emitCodeFromInclude("shadowMapVertexMetric", comments, {
82
+ replaceStrings: [
83
+ {
84
+ search: /gl_Position/g,
85
+ replace: "clipPos",
86
+ },
87
+ ],
88
+ });
89
+ state.compilationString += state._emitCodeFromInclude("shadowMapFragment", comments, {
90
+ replaceStrings: [
91
+ {
92
+ search: /return;/g,
93
+ replace: "",
94
+ },
95
+ ],
96
+ });
97
+ state.compilationString += `
98
+ #if SM_DEPTHTEXTURE == 1
99
+ #ifdef IS_NDC_HALF_ZRANGE
100
+ gl_FragDepth = (clipPos.z / clipPos.w);
101
+ #else
102
+ gl_FragDepth = (clipPos.z / clipPos.w) * 0.5 + 0.5;
103
+ #endif
104
+ #endif
105
+ `;
106
+ state.compilationString += `${this._declareOutput(this.depth, state)} = vec3(depthSM, 1., 1.);\r\n`;
107
+ return this;
108
+ }
109
+ }
110
+ RegisterClass("BABYLON.ShadowMapBlock", ShadowMapBlock);
111
+ //# sourceMappingURL=shadowMapBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shadowMapBlock.js","sourceRoot":"","sources":["../../../../../../../../lts/core/generated/Materials/Node/Blocks/Fragment/shadowMapBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAiB;IACjD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAE/C,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,qCAAqC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC1F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,MAAM,EAAE,UAAU;oBAClB,OAAO,EAAE,EAAE;iBACd;aACJ;SACJ,CAAC,CAAC;QAEH,KAAK,CAAC,iBAAiB,IAAI;;;;;;;;SAQ1B,CAAC;QAEF,KAAK,CAAC,iBAAiB,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,+BAA+B,CAAC;QAEpG,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\n\r\n/**\r\n * Block used to output the depth to a shadow map\r\n */\r\nexport class ShadowMapBlock extends NodeMaterialBlock {\r\n /**\r\n * Create a new ShadowMapBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerInput(\"worldPosition\", NodeMaterialBlockConnectionPointTypes.Vector4, false);\r\n this.registerInput(\"viewProjection\", NodeMaterialBlockConnectionPointTypes.Matrix, false);\r\n this.registerInput(\"worldNormal\", NodeMaterialBlockConnectionPointTypes.Vector3, true);\r\n this.registerOutput(\"depth\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n\r\n this.worldNormal.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"ShadowMapBlock\";\r\n }\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"vPositionWSM\");\r\n state._excludeVariableName(\"lightDataSM\");\r\n state._excludeVariableName(\"biasAndScaleSM\");\r\n state._excludeVariableName(\"depthValuesSM\");\r\n state._excludeVariableName(\"clipPos\");\r\n state._excludeVariableName(\"worldPos\");\r\n state._excludeVariableName(\"zSM\");\r\n }\r\n\r\n /**\r\n * Gets the world position input component\r\n */\r\n public get worldPosition(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the view x projection input component\r\n */\r\n public get viewProjection(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the world normal input component\r\n */\r\n public get worldNormal(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the depth output component\r\n */\r\n public get depth(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const comments = `//${this.name}`;\r\n\r\n state._emitUniformFromString(\"biasAndScaleSM\", \"vec3\");\r\n state._emitUniformFromString(\"lightDataSM\", \"vec3\");\r\n state._emitUniformFromString(\"depthValuesSM\", \"vec2\");\r\n\r\n state._emitFunctionFromInclude(\"packingFunctions\", comments);\r\n\r\n state.compilationString += `vec4 worldPos = ${this.worldPosition.associatedVariableName};\\r\\n`;\r\n state.compilationString += `vec3 vPositionWSM;\\r\\n`;\r\n state.compilationString += `float vDepthMetricSM = 0.0;\\r\\n`;\r\n state.compilationString += `float zSM;\\r\\n`;\r\n\r\n if (this.worldNormal.isConnected) {\r\n state.compilationString += `vec3 vNormalW = ${this.worldNormal.associatedVariableName}.xyz;\\r\\n`;\r\n state.compilationString += state._emitCodeFromInclude(\"shadowMapVertexNormalBias\", comments);\r\n }\r\n\r\n state.compilationString += `vec4 clipPos = ${this.viewProjection.associatedVariableName} * worldPos;\\r\\n`;\r\n\r\n state.compilationString += state._emitCodeFromInclude(\"shadowMapVertexMetric\", comments, {\r\n replaceStrings: [\r\n {\r\n search: /gl_Position/g,\r\n replace: \"clipPos\",\r\n },\r\n ],\r\n });\r\n\r\n state.compilationString += state._emitCodeFromInclude(\"shadowMapFragment\", comments, {\r\n replaceStrings: [\r\n {\r\n search: /return;/g,\r\n replace: \"\",\r\n },\r\n ],\r\n });\r\n\r\n state.compilationString += `\r\n #if SM_DEPTHTEXTURE == 1\r\n #ifdef IS_NDC_HALF_ZRANGE\r\n gl_FragDepth = (clipPos.z / clipPos.w);\r\n #else\r\n gl_FragDepth = (clipPos.z / clipPos.w) * 0.5 + 0.5;\r\n #endif\r\n #endif\r\n `;\r\n\r\n state.compilationString += `${this._declareOutput(this.depth, state)} = vec3(depthSM, 1., 1.);\\r\\n`;\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ShadowMapBlock\", ShadowMapBlock);\r\n"]}
@@ -16,6 +16,8 @@ export declare class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
16
16
  * Gets or sets the light associated with this block
17
17
  */
18
18
  light: Nullable<Light>;
19
+ private static _OnGenerateOnlyFragmentCodeChanged;
20
+ private _setTarget;
19
21
  private _lightId;
20
22
  private _scene;
21
23
  private _environmentBRDFTexture;
@@ -108,6 +110,8 @@ export declare class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
108
110
  * Force normal to face away from face.
109
111
  */
110
112
  forceNormalForward: boolean;
113
+ /** Indicates that no code should be generated in the vertex shader. Can be useful in some specific circumstances (like when doing ray marching for eg) */
114
+ generateOnlyFragmentCode: boolean;
111
115
  /**
112
116
  * Defines the material debug mode.
113
117
  * It helps seeing only some components of the material while troubleshooting.
@@ -126,6 +126,8 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
126
126
  * Force normal to face away from face.
127
127
  */
128
128
  this.forceNormalForward = false;
129
+ /** Indicates that no code should be generated in the vertex shader. Can be useful in some specific circumstances (like when doing ray marching for eg) */
130
+ this.generateOnlyFragmentCode = false;
129
131
  /**
130
132
  * Defines the material debug mode.
131
133
  * It helps seeing only some components of the material while troubleshooting.
@@ -176,6 +178,20 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
176
178
  this.registerOutput("shadow", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);
177
179
  this.registerOutput("alpha", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);
178
180
  }
181
+ static _OnGenerateOnlyFragmentCodeChanged(block, _propertyName) {
182
+ const that = block;
183
+ if (that.worldPosition.isConnected) {
184
+ that.generateOnlyFragmentCode = !that.generateOnlyFragmentCode;
185
+ console.error("The worldPosition input must not be connected to be able to switch!");
186
+ return false;
187
+ }
188
+ that._setTarget();
189
+ return true;
190
+ }
191
+ _setTarget() {
192
+ this._setInitialTarget(this.generateOnlyFragmentCode ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.VertexAndFragment);
193
+ this.getInputByName("worldPosition").target = this.generateOnlyFragmentCode ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.Vertex;
194
+ }
179
195
  /**
180
196
  * Initialize the block and prepare the context for build
181
197
  * @param state defines the state that will be used for the build
@@ -608,8 +624,6 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
608
624
  reflectionBlock.viewConnectionPoint = this.view;
609
625
  }
610
626
  state.compilationString += (_b = reflectionBlock === null || reflectionBlock === void 0 ? void 0 : reflectionBlock.handleVertexSide(state)) !== null && _b !== void 0 ? _b : "";
611
- state._emitUniformFromString("vDebugMode", "vec2", "defined(IGNORE) || DEBUGMODE > 0");
612
- state._emitUniformFromString("ambientFromScene", "vec3");
613
627
  if (state._emitVaryingFromString("vClipSpacePosition", "vec4", "defined(IGNORE) || DEBUGMODE > 0")) {
614
628
  state._injectAtEnd += `#if DEBUGMODE > 0\r\n`;
615
629
  state._injectAtEnd += `vClipSpacePosition = gl_Position;\r\n`;
@@ -716,6 +730,7 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
716
730
  reflectionBlock.worldPositionConnectionPoint = this.worldPosition;
717
731
  reflectionBlock.cameraPositionConnectionPoint = this.cameraPosition;
718
732
  reflectionBlock.worldNormalConnectionPoint = this.worldNormal;
733
+ reflectionBlock.viewConnectionPoint = this.view;
719
734
  }
720
735
  if (state.target !== NodeMaterialBlockTargets.Fragment) {
721
736
  // Vertex
@@ -726,15 +741,35 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
726
741
  state.sharedData.forcedBindableBlocks.push(this);
727
742
  state.sharedData.blocksWithDefines.push(this);
728
743
  state.sharedData.blockingBlocks.push(this);
744
+ if (this.generateOnlyFragmentCode) {
745
+ state.sharedData.dynamicUniformBlocks.push(this);
746
+ }
729
747
  const comments = `//${this.name}`;
730
- const worldPosVarName = "v_" + this.worldPosition.associatedVariableName;
731
748
  const normalShading = this.perturbedNormal;
749
+ let worldPosVarName = this.worldPosition.associatedVariableName;
750
+ if (this.generateOnlyFragmentCode) {
751
+ worldPosVarName = state._getFreeVariableName("globalWorldPos");
752
+ state._emitFunction("pbr_globalworldpos", `vec3 ${worldPosVarName};\r\n`, comments);
753
+ state.compilationString += `${worldPosVarName} = ${this.worldPosition.associatedVariableName}.xyz;\r\n`;
754
+ state.compilationString += state._emitCodeFromInclude("shadowsVertex", comments, {
755
+ repeatKey: "maxSimultaneousLights",
756
+ substitutionVars: this.generateOnlyFragmentCode ? `worldPos,${this.worldPosition.associatedVariableName}` : undefined,
757
+ });
758
+ state.compilationString += `#if DEBUGMODE > 0\r\n`;
759
+ state.compilationString += `vec4 vClipSpacePosition = vec4((vec2(gl_FragCoord.xy) / vec2(1.0)) * 2.0 - 1.0, 0.0, 1.0);\r\n`;
760
+ state.compilationString += `#endif\r\n`;
761
+ }
762
+ else {
763
+ worldPosVarName = "v_" + worldPosVarName;
764
+ }
732
765
  this._environmentBrdfSamplerName = state._getFreeVariableName("environmentBrdfSampler");
733
766
  state._emit2DSampler(this._environmentBrdfSamplerName);
734
767
  state.sharedData.hints.needAlphaBlending = state.sharedData.hints.needAlphaBlending || this.useAlphaBlending;
735
768
  state.sharedData.hints.needAlphaTesting = state.sharedData.hints.needAlphaTesting || this.useAlphaTest;
736
769
  state._emitExtension("lod", "#extension GL_EXT_shader_texture_lod : enable", "defined(LODBASEDMICROSFURACE)");
737
770
  state._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
771
+ state._emitUniformFromString("vDebugMode", "vec2", "defined(IGNORE) || DEBUGMODE > 0");
772
+ state._emitUniformFromString("ambientFromScene", "vec3");
738
773
  // Image processing uniforms
739
774
  state.uniforms.push("exposureLinear");
740
775
  state.uniforms.push("contrast");
@@ -754,6 +789,7 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
754
789
  // Emit for all lights
755
790
  state._emitFunctionFromInclude(state.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", comments, {
756
791
  repeatKey: "maxSimultaneousLights",
792
+ substitutionVars: this.generateOnlyFragmentCode ? "varying," : undefined,
757
793
  });
758
794
  }
759
795
  else {
@@ -790,6 +826,9 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
790
826
  // code
791
827
  //
792
828
  state._emitUniformFromString("vLightingIntensity", "vec4");
829
+ if (reflectionBlock === null || reflectionBlock === void 0 ? void 0 : reflectionBlock.generateOnlyFragmentCode) {
830
+ state.compilationString += reflectionBlock.handleVertexSide(state);
831
+ }
793
832
  // _____________________________ Geometry Information ____________________________
794
833
  this._vNormalWName = state._getFreeVariableName("vNormalW");
795
834
  state.compilationString += `vec4 ${this._vNormalWName} = normalize(${this.worldNormal.associatedVariableName});\r\n`;
@@ -1032,6 +1071,7 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
1032
1071
  serializationObject.debugMode = this.debugMode;
1033
1072
  serializationObject.debugLimit = this.debugLimit;
1034
1073
  serializationObject.debugFactor = this.debugFactor;
1074
+ serializationObject.generateOnlyFragmentCode = this.generateOnlyFragmentCode;
1035
1075
  return serializationObject;
1036
1076
  }
1037
1077
  _deserialize(serializationObject, scene, rootUrl) {
@@ -1057,6 +1097,8 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
1057
1097
  this.debugMode = serializationObject.debugMode;
1058
1098
  this.debugLimit = serializationObject.debugLimit;
1059
1099
  this.debugFactor = serializationObject.debugFactor;
1100
+ this.generateOnlyFragmentCode = !!serializationObject.generateOnlyFragmentCode;
1101
+ this._setTarget();
1060
1102
  }
1061
1103
  }
1062
1104
  __decorate([
@@ -1124,6 +1166,11 @@ __decorate([
1124
1166
  __decorate([
1125
1167
  editableInPropertyPage("Force normal forward", PropertyTypeForEdition.Boolean, "ADVANCED", { notifiers: { update: true } })
1126
1168
  ], PBRMetallicRoughnessBlock.prototype, "forceNormalForward", void 0);
1169
+ __decorate([
1170
+ editableInPropertyPage("Generate only fragment code", PropertyTypeForEdition.Boolean, "ADVANCED", {
1171
+ notifiers: { rebuild: true, update: true, onValidation: PBRMetallicRoughnessBlock._OnGenerateOnlyFragmentCodeChanged },
1172
+ })
1173
+ ], PBRMetallicRoughnessBlock.prototype, "generateOnlyFragmentCode", void 0);
1127
1174
  __decorate([
1128
1175
  editableInPropertyPage("Debug mode", PropertyTypeForEdition.List, "DEBUG", {
1129
1176
  notifiers: { update: true },