@babylonjs/core 6.19.0 → 6.20.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 (253) hide show
  1. package/Actions/actionManager.js +2 -2
  2. package/Actions/actionManager.js.map +1 -1
  3. package/Animations/runtimeAnimation.js +2 -2
  4. package/Animations/runtimeAnimation.js.map +1 -1
  5. package/Cameras/Inputs/BaseCameraPointersInput.d.ts +4 -4
  6. package/Cameras/Inputs/BaseCameraPointersInput.js +4 -6
  7. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  8. package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +3 -2
  9. package/Cameras/Inputs/arcRotateCameraPointersInput.js +3 -2
  10. package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
  11. package/Cameras/Inputs/flyCameraMouseInput.js +2 -7
  12. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  13. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js +2 -7
  14. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
  15. package/Cameras/Inputs/freeCameraMouseInput.js +4 -14
  16. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  17. package/Cameras/Inputs/freeCameraTouchInput.js +2 -1
  18. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  19. package/Cameras/arcRotateCamera.js +2 -7
  20. package/Cameras/arcRotateCamera.js.map +1 -1
  21. package/Cameras/camera.d.ts +2 -0
  22. package/Cameras/camera.js +8 -0
  23. package/Cameras/camera.js.map +1 -1
  24. package/Compute/computeShader.d.ts +15 -0
  25. package/Compute/computeShader.js +39 -0
  26. package/Compute/computeShader.js.map +1 -1
  27. package/Debug/physicsViewer.d.ts +33 -0
  28. package/Debug/physicsViewer.js +205 -0
  29. package/Debug/physicsViewer.js.map +1 -1
  30. package/Engines/Extensions/engine.computeShader.d.ts +2 -1
  31. package/Engines/Extensions/engine.computeShader.js +1 -0
  32. package/Engines/Extensions/engine.computeShader.js.map +1 -1
  33. package/Engines/WebGPU/webgpuComputeContext.js +15 -0
  34. package/Engines/WebGPU/webgpuComputeContext.js.map +1 -1
  35. package/Engines/thinEngine.js +2 -2
  36. package/Engines/thinEngine.js.map +1 -1
  37. package/FlowGraph/Blocks/Data/flowGraphAddBlock.d.ts +23 -0
  38. package/FlowGraph/Blocks/Data/flowGraphAddBlock.js +18 -0
  39. package/FlowGraph/Blocks/Data/flowGraphAddBlock.js.map +1 -0
  40. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.d.ts +30 -0
  41. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +22 -0
  42. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -0
  43. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +33 -0
  44. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +30 -0
  45. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -0
  46. package/FlowGraph/Blocks/Data/index.d.ts +3 -1
  47. package/FlowGraph/Blocks/Data/index.js +3 -1
  48. package/FlowGraph/Blocks/Data/index.js.map +1 -1
  49. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +12 -10
  50. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +25 -29
  51. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
  52. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +25 -0
  53. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +31 -0
  54. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -0
  55. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.d.ts +3 -7
  56. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js +11 -11
  57. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
  58. package/FlowGraph/Blocks/Event/index.d.ts +1 -0
  59. package/FlowGraph/Blocks/Event/index.js +1 -0
  60. package/FlowGraph/Blocks/Event/index.js.map +1 -1
  61. package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.d.ts +24 -0
  62. package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js +23 -0
  63. package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js.map +1 -0
  64. package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.d.ts +10 -13
  65. package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js +28 -22
  66. package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js.map +1 -1
  67. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.d.ts +5 -5
  68. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js +8 -6
  69. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +1 -1
  70. package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.d.ts +56 -0
  71. package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.js +66 -0
  72. package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.js.map +1 -0
  73. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.d.ts +18 -0
  74. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +19 -0
  75. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -0
  76. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +26 -0
  77. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +36 -0
  78. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -0
  79. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +23 -0
  80. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +25 -0
  81. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -0
  82. package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.d.ts +16 -0
  83. package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.js +18 -0
  84. package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.js.map +1 -0
  85. package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.d.ts +32 -0
  86. package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js +62 -0
  87. package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js.map +1 -0
  88. package/FlowGraph/Blocks/Execution/index.d.ts +7 -0
  89. package/FlowGraph/Blocks/Execution/index.js +7 -0
  90. package/FlowGraph/Blocks/Execution/index.js.map +1 -1
  91. package/FlowGraph/flowGraph.d.ts +42 -12
  92. package/FlowGraph/flowGraph.js +37 -23
  93. package/FlowGraph/flowGraph.js.map +1 -1
  94. package/FlowGraph/flowGraphAsyncExecutionBlock.d.ts +29 -0
  95. package/FlowGraph/flowGraphAsyncExecutionBlock.js +21 -0
  96. package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -0
  97. package/FlowGraph/flowGraphBlock.d.ts +9 -11
  98. package/FlowGraph/flowGraphBlock.js +12 -8
  99. package/FlowGraph/flowGraphBlock.js.map +1 -1
  100. package/FlowGraph/flowGraphConnection.d.ts +17 -7
  101. package/FlowGraph/flowGraphConnection.js +26 -9
  102. package/FlowGraph/flowGraphConnection.js.map +1 -1
  103. package/FlowGraph/flowGraphContext.d.ts +102 -0
  104. package/FlowGraph/flowGraphContext.js +111 -0
  105. package/FlowGraph/flowGraphContext.js.map +1 -0
  106. package/FlowGraph/flowGraphCustomEvent.d.ts +5 -0
  107. package/FlowGraph/flowGraphCustomEvent.js +2 -0
  108. package/FlowGraph/flowGraphCustomEvent.js.map +1 -0
  109. package/FlowGraph/flowGraphDataConnection.d.ts +10 -2
  110. package/FlowGraph/flowGraphDataConnection.js +16 -8
  111. package/FlowGraph/flowGraphDataConnection.js.map +1 -1
  112. package/FlowGraph/flowGraphEventBlock.d.ts +5 -12
  113. package/FlowGraph/flowGraphEventBlock.js +5 -5
  114. package/FlowGraph/flowGraphEventBlock.js.map +1 -1
  115. package/FlowGraph/flowGraphEventCoordinator.d.ts +23 -0
  116. package/FlowGraph/flowGraphEventCoordinator.js +37 -0
  117. package/FlowGraph/flowGraphEventCoordinator.js.map +1 -0
  118. package/FlowGraph/flowGraphExecutionBlock.d.ts +5 -5
  119. package/FlowGraph/flowGraphExecutionBlock.js +3 -3
  120. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  121. package/FlowGraph/flowGraphRichTypes.d.ts +28 -0
  122. package/FlowGraph/flowGraphRichTypes.js +43 -0
  123. package/FlowGraph/flowGraphRichTypes.js.map +1 -0
  124. package/FlowGraph/flowGraphSignalConnection.d.ts +7 -1
  125. package/FlowGraph/flowGraphSignalConnection.js +11 -4
  126. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  127. package/FlowGraph/flowGraphVariableDefinitions.d.ts +12 -0
  128. package/FlowGraph/flowGraphVariableDefinitions.js +22 -0
  129. package/FlowGraph/flowGraphVariableDefinitions.js.map +1 -0
  130. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.d.ts +10 -2
  131. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js +8 -2
  132. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js.map +1 -1
  133. package/FlowGraph/index.d.ts +3 -0
  134. package/FlowGraph/index.js +3 -0
  135. package/FlowGraph/index.js.map +1 -1
  136. package/Materials/Node/nodeMaterial.d.ts +2 -1
  137. package/Materials/Node/nodeMaterial.js +26 -2
  138. package/Materials/Node/nodeMaterial.js.map +1 -1
  139. package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
  140. package/Materials/PBR/pbrBaseMaterial.js +1 -0
  141. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  142. package/Materials/Textures/videoTexture.d.ts +5 -0
  143. package/Materials/Textures/videoTexture.js +6 -0
  144. package/Materials/Textures/videoTexture.js.map +1 -1
  145. package/Materials/materialHelper.js +1 -0
  146. package/Materials/materialHelper.js.map +1 -1
  147. package/Materials/standardMaterial.d.ts +1 -0
  148. package/Materials/standardMaterial.js +1 -0
  149. package/Materials/standardMaterial.js.map +1 -1
  150. package/Materials/uniformBuffer.d.ts +7 -0
  151. package/Materials/uniformBuffer.js +8 -0
  152. package/Materials/uniformBuffer.js.map +1 -1
  153. package/Maths/math.vector.d.ts +5 -0
  154. package/Maths/math.vector.js +7 -0
  155. package/Maths/math.vector.js.map +1 -1
  156. package/Meshes/Node/Blocks/Instances/instantiateBlock.d.ts +11 -5
  157. package/Meshes/Node/Blocks/Instances/instantiateBlock.js +20 -10
  158. package/Meshes/Node/Blocks/Instances/instantiateBlock.js.map +1 -1
  159. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +15 -9
  160. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +20 -11
  161. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
  162. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.d.ts +15 -9
  163. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +20 -11
  164. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
  165. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +15 -9
  166. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +20 -11
  167. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
  168. package/Meshes/Node/Blocks/Set/setColorsBlock.d.ts +12 -0
  169. package/Meshes/Node/Blocks/Set/setColorsBlock.js +62 -27
  170. package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
  171. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.d.ts +7 -0
  172. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js +19 -0
  173. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js.map +1 -1
  174. package/Meshes/Node/Blocks/Set/setNormalsBlock.d.ts +12 -0
  175. package/Meshes/Node/Blocks/Set/setNormalsBlock.js +62 -27
  176. package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
  177. package/Meshes/Node/Blocks/Set/setPositionsBlock.d.ts +12 -0
  178. package/Meshes/Node/Blocks/Set/setPositionsBlock.js +54 -19
  179. package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
  180. package/Meshes/Node/Blocks/Set/setTangentsBlock.d.ts +12 -0
  181. package/Meshes/Node/Blocks/Set/setTangentsBlock.js +62 -27
  182. package/Meshes/Node/Blocks/Set/setTangentsBlock.js.map +1 -1
  183. package/Meshes/Node/Blocks/Set/setUVsBlock.d.ts +5 -0
  184. package/Meshes/Node/Blocks/Set/setUVsBlock.js +65 -46
  185. package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
  186. package/Meshes/Node/Blocks/debugBlock.js +5 -1
  187. package/Meshes/Node/Blocks/debugBlock.js.map +1 -1
  188. package/Meshes/Node/Blocks/geometryInputBlock.js +1 -0
  189. package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
  190. package/Meshes/Node/Blocks/intFloatConverterBlock.js +2 -2
  191. package/Meshes/Node/Blocks/intFloatConverterBlock.js.map +1 -1
  192. package/Meshes/Node/Blocks/mapRangeBlock.js +8 -1
  193. package/Meshes/Node/Blocks/mapRangeBlock.js.map +1 -1
  194. package/Meshes/Node/Blocks/mathBlock.js +1 -0
  195. package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
  196. package/Meshes/Node/Blocks/matrixComposeBlock.d.ts +30 -0
  197. package/Meshes/Node/Blocks/matrixComposeBlock.js +55 -0
  198. package/Meshes/Node/Blocks/matrixComposeBlock.js.map +1 -0
  199. package/Meshes/Node/Enums/nodeGeometryContextualSources.d.ts +3 -1
  200. package/Meshes/Node/Enums/nodeGeometryContextualSources.js +2 -0
  201. package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -1
  202. package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.d.ts +10 -0
  203. package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.js +2 -0
  204. package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.js.map +1 -0
  205. package/Meshes/Node/index.d.ts +1 -0
  206. package/Meshes/Node/index.js +1 -0
  207. package/Meshes/Node/index.js.map +1 -1
  208. package/Meshes/Node/nodeGeometry.js +2 -2
  209. package/Meshes/Node/nodeGeometry.js.map +1 -1
  210. package/Meshes/Node/nodeGeometryBuildState.d.ts +5 -0
  211. package/Meshes/Node/nodeGeometryBuildState.js +20 -0
  212. package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
  213. package/Meshes/abstractMesh.js +4 -1
  214. package/Meshes/abstractMesh.js.map +1 -1
  215. package/Meshes/geometry.js +10 -10
  216. package/Meshes/geometry.js.map +1 -1
  217. package/Meshes/mesh.js +7 -5
  218. package/Meshes/mesh.js.map +1 -1
  219. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +2 -1
  220. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
  221. package/Misc/dumpTools.js +3 -2
  222. package/Misc/dumpTools.js.map +1 -1
  223. package/Misc/equirectangularCapture.d.ts +39 -0
  224. package/Misc/equirectangularCapture.js +56 -0
  225. package/Misc/equirectangularCapture.js.map +1 -0
  226. package/Misc/index.d.ts +1 -0
  227. package/Misc/index.js +1 -0
  228. package/Misc/index.js.map +1 -1
  229. package/Particles/solidParticleSystem.d.ts +4 -0
  230. package/Particles/solidParticleSystem.js +16 -1
  231. package/Particles/solidParticleSystem.js.map +1 -1
  232. package/Physics/v2/IPhysicsEnginePlugin.d.ts +10 -0
  233. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  234. package/Physics/v2/Plugins/havokPlugin.d.ts +8 -1
  235. package/Physics/v2/Plugins/havokPlugin.js +34 -0
  236. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  237. package/Physics/v2/physicsConstraint.d.ts +11 -1
  238. package/Physics/v2/physicsConstraint.js +7 -0
  239. package/Physics/v2/physicsConstraint.js.map +1 -1
  240. package/Rendering/prePassRenderer.d.ts +6 -0
  241. package/Rendering/prePassRenderer.js +14 -0
  242. package/Rendering/prePassRenderer.js.map +1 -1
  243. package/Shaders/default.fragment.js +4 -0
  244. package/Shaders/default.fragment.js.map +1 -1
  245. package/Shaders/equirectangularPanorama.fragment.d.ts +5 -0
  246. package/Shaders/equirectangularPanorama.fragment.js +17 -0
  247. package/Shaders/equirectangularPanorama.fragment.js.map +1 -0
  248. package/Shaders/pbr.fragment.js +4 -0
  249. package/Shaders/pbr.fragment.js.map +1 -1
  250. package/package.json +1 -1
  251. package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.d.ts +0 -34
  252. package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.js +0 -29
  253. package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import type { Scene } from "../../scene";
2
2
  import type { Vector3 } from "../../Maths/math.vector";
3
3
  import type { Nullable } from "../../types";
4
- import type { IPhysicsEnginePluginV2, PhysicsConstraintParameters, PhysicsConstraintAxisLimitMode, PhysicsConstraintMotorType } from "./IPhysicsEnginePlugin";
4
+ import type { IPhysicsEnginePluginV2, PhysicsConstraintParameters, PhysicsConstraintAxisLimitMode, PhysicsConstraintMotorType, ConstrainedBodyPair } from "./IPhysicsEnginePlugin";
5
5
  import { PhysicsConstraintAxis, PhysicsConstraintType } from "./IPhysicsEnginePlugin";
6
6
  /**
7
7
  * This is a holder class for the physics constraint created by the physics plugin
@@ -19,6 +19,11 @@ export declare class PhysicsConstraint {
19
19
  protected _physicsPlugin: IPhysicsEnginePluginV2;
20
20
  protected _options: PhysicsConstraintParameters;
21
21
  protected _type: PhysicsConstraintType;
22
+ /**
23
+ * @internal
24
+ * The internal options that were used to init the constraint
25
+ */
26
+ _initOptions?: PhysicsConstraintParameters;
22
27
  /**
23
28
  * Constructs a new constraint for the physics constraint.
24
29
  * @param type The type of constraint to create.
@@ -67,6 +72,11 @@ export declare class PhysicsConstraint {
67
72
  *
68
73
  */
69
74
  get isCollisionsEnabled(): boolean;
75
+ /**
76
+ * Gets all bodies that are using this constraint
77
+ * @returns
78
+ */
79
+ getBodiesUsingConstraint(): ConstrainedBodyPair[];
70
80
  /**
71
81
  * Disposes the constraint from the physics engine.
72
82
  *
@@ -87,6 +87,13 @@ export class PhysicsConstraint {
87
87
  get isCollisionsEnabled() {
88
88
  return this._physicsPlugin.getCollisionsEnabled(this);
89
89
  }
90
+ /**
91
+ * Gets all bodies that are using this constraint
92
+ * @returns
93
+ */
94
+ getBodiesUsingConstraint() {
95
+ return this._physicsPlugin.getBodiesUsingConstraint(this);
96
+ }
90
97
  /**
91
98
  * Disposes the constraint from the physics engine.
92
99
  *
@@ -1 +1 @@
1
- {"version":3,"file":"physicsConstraint.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsConstraint.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEtF;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAY1B;;;;;;;;OAQG;IACH,YAAY,IAA2B,EAAE,OAAoC,EAAE,KAAY;QApB3F;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAkBhC,IAAI,CAAC,KAAK,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SAC1E;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,g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QACtF,KAAK,CAAC,qBAAqB,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IAClH,CAAC;CACJ;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,gBAAiB,SAAQ,qBAAqB;IACvD,YAAY,MAAe,EAAE,MAAe,EAAE,KAAc,EAAE,KAAc,EAAE,WAAmB,EAAE,WAAmB,EAAE,SAAiB,EAAE,OAAe,EAAE,KAAY;QACpK,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,qBAAqB,CAAC,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACxK,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsConstraintParameters, PhysicsConstraintAxisLimitMode, PhysicsConstraintMotorType } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsConstraintAxis, PhysicsConstraintType } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n * This is a holder class for the physics constraint created by the physics plugin\r\n * It holds a set of functions to control the underlying constraint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsConstraint {\r\n /**\r\n * V2 Physics plugin private data for a physics material\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n protected _options: PhysicsConstraintParameters;\r\n protected _type: PhysicsConstraintType;\r\n\r\n /**\r\n * Constructs a new constraint for the physics constraint.\r\n * @param type The type of constraint to create.\r\n * @param options The options for the constraint.\r\n * @param scene The scene the constraint belongs to.\r\n *\r\n * This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.\r\n * If all checks pass, it initializes the constraint with the given type and options.\r\n */\r\n constructor(type: PhysicsConstraintType, options: PhysicsConstraintParameters, scene: Scene) {\r\n if (!scene) {\r\n throw new Error(\"Missing scene parameter for constraint constructor.\");\r\n }\r\n const physicsEngine = scene.getPhysicsEngine();\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n this._options = options;\r\n this._type = type;\r\n }\r\n\r\n /**\r\n * Gets the type of the constraint.\r\n *\r\n * @returns The type of the constraint.\r\n *\r\n */\r\n public get type(): PhysicsConstraintType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Retrieves the options of the physics constraint.\r\n *\r\n * @returns The physics constraint parameters.\r\n *\r\n */\r\n public get options(): PhysicsConstraintParameters {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Enable/disable the constraint\r\n * @param isEnabled value for the constraint\r\n */\r\n public set isEnabled(isEnabled: boolean) {\r\n this._physicsPlugin.setEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns true if constraint is enabled\r\n */\r\n public get isEnabled(): boolean {\r\n return this._physicsPlugin.getEnabled(this);\r\n }\r\n\r\n /**\r\n * Enables or disables collisions for the physics engine.\r\n *\r\n * @param isEnabled - A boolean value indicating whether collisions should be enabled or disabled.\r\n *\r\n */\r\n public set isCollisionsEnabled(isEnabled: boolean) {\r\n this._physicsPlugin.setCollisionsEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n * Gets whether collisions are enabled for this physics object.\r\n *\r\n * @returns `true` if collisions are enabled, `false` otherwise.\r\n *\r\n */\r\n public get isCollisionsEnabled(): boolean {\r\n return this._physicsPlugin.getCollisionsEnabled(this);\r\n }\r\n\r\n /**\r\n * Disposes the constraint from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeConstraint(this);\r\n }\r\n}\r\n\r\n/**\r\n * This describes a single limit used by Physics6DoFConstraint\r\n */\r\nexport class Physics6DoFLimit {\r\n /**\r\n * The axis ID to limit\r\n */\r\n axis: PhysicsConstraintAxis;\r\n /**\r\n * An optional minimum limit for the axis.\r\n * Corresponds to a distance in meters for linear axes, an angle in radians for angular axes.\r\n */\r\n minLimit?: number;\r\n /**\r\n * An optional maximum limit for the axis.\r\n * Corresponds to a distance in meters for linear axes, an angle in radians for angular axes.\r\n */\r\n maxLimit?: number;\r\n /**\r\n * The stiffness of the constraint.\r\n */\r\n stiffness?: number;\r\n /**\r\n * A constraint parameter that specifies damping.\r\n */\r\n damping?: number;\r\n}\r\n\r\n/**\r\n * A generic constraint, which can be used to build more complex constraints than those specified\r\n * in PhysicsConstraintType. The axis and pivot options in PhysicsConstraintParameters define the space\r\n * the constraint operates in. This constraint contains a set of limits, which restrict the\r\n * relative movement of the bodies in that coordinate system\r\n */\r\nexport class Physics6DoFConstraint extends PhysicsConstraint {\r\n /**\r\n * The collection of limits which this constraint will apply\r\n */\r\n public limits: Physics6DoFLimit[];\r\n\r\n constructor(constraintParams: PhysicsConstraintParameters, limits: Physics6DoFLimit[], scene: Scene) {\r\n super(PhysicsConstraintType.SIX_DOF, constraintParams, scene);\r\n this.limits = limits;\r\n }\r\n\r\n /**\r\n * Sets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine to set the friction for.\r\n * @param friction - The friction to set for the given axis.\r\n *\r\n */\r\n public setAxisFriction(axis: PhysicsConstraintAxis, friction: number): void {\r\n this._physicsPlugin.setAxisFriction(this, axis, friction);\r\n }\r\n\r\n /**\r\n * Gets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The friction of the given axis, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisFriction(axis: PhysicsConstraintAxis): Nullable<number> {\r\n return this._physicsPlugin.getAxisFriction(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the limit mode for the given axis of the constraint.\r\n * @param axis The axis to set the limit mode for.\r\n * @param limitMode The limit mode to set.\r\n *\r\n * This method is useful for setting the limit mode for a given axis of the constraint. This is important for\r\n * controlling the behavior of the physics engine when the constraint is reached. By setting the limit mode,\r\n * the engine can be configured to either stop the motion of the objects, or to allow them to continue\r\n * moving beyond the constraint.\r\n */\r\n public setAxisMode(axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void {\r\n this._physicsPlugin.setAxisMode(this, axis, limitMode);\r\n }\r\n\r\n /**\r\n * Gets the limit mode of the given axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The limit mode of the given axis, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisMode(axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintAxisLimitMode> {\r\n return this._physicsPlugin.getAxisMode(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the minimum limit of a given axis of a constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param minLimit - The minimum limit of the axis.\r\n *\r\n */\r\n public setAxisMinLimit(axis: PhysicsConstraintAxis, minLimit: number): void {\r\n this._physicsPlugin.setAxisMinLimit(this, axis, minLimit);\r\n }\r\n\r\n /**\r\n * Gets the minimum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The minimum limit of the given axis, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisMinLimit(axis: PhysicsConstraintAxis): Nullable<number> {\r\n return this._physicsPlugin.getAxisMinLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum limit of the given axis for the physics engine.\r\n * @param axis - The axis to set the limit for.\r\n * @param limit - The maximum limit of the axis.\r\n *\r\n * This method is useful for setting the maximum limit of the given axis for the physics engine,\r\n * which can be used to control the movement of the physics object. This helps to ensure that the\r\n * physics object does not move beyond the given limit.\r\n */\r\n public setAxisMaxLimit(axis: PhysicsConstraintAxis, limit: number): void {\r\n this._physicsPlugin.setAxisMaxLimit(this, axis, limit);\r\n }\r\n\r\n /**\r\n * Gets the maximum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The maximum limit of the given axis, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisMaxLimit(axis: PhysicsConstraintAxis): Nullable<number> {\r\n return this._physicsPlugin.getAxisMaxLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the motor type of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param motorType - The type of motor to use.\r\n * @returns void\r\n *\r\n */\r\n public setAxisMotorType(axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void {\r\n this._physicsPlugin.setAxisMotorType(this, axis, motorType);\r\n }\r\n\r\n /**\r\n * Gets the motor type of the specified axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The motor type of the specified axis, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisMotorType(axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintMotorType> {\r\n return this._physicsPlugin.getAxisMotorType(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the target velocity of the motor associated with the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param target - The target velocity of the motor.\r\n *\r\n * This method is useful for setting the target velocity of the motor associated with the given axis of the constraint.\r\n */\r\n public setAxisMotorTarget(axis: PhysicsConstraintAxis, target: number): void {\r\n this._physicsPlugin.setAxisMotorTarget(this, axis, target);\r\n }\r\n\r\n /**\r\n * Gets the target velocity of the motor associated to the given constraint axis.\r\n * @param axis - The constraint axis associated to the motor.\r\n * @returns The target velocity of the motor, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisMotorTarget(axis: PhysicsConstraintAxis): Nullable<number> {\r\n return this._physicsPlugin.getAxisMotorTarget(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param maxForce - The maximum force of the motor.\r\n *\r\n */\r\n public setAxisMotorMaxForce(axis: PhysicsConstraintAxis, maxForce: number): void {\r\n this._physicsPlugin.setAxisMotorMaxForce(this, axis, maxForce);\r\n }\r\n\r\n /**\r\n * Gets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @returns The maximum force of the motor, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisMotorMaxForce(axis: PhysicsConstraintAxis): Nullable<number> {\r\n return this._physicsPlugin.getAxisMotorMaxForce(this, axis);\r\n }\r\n}\r\n\r\n/**\r\n * Represents a Ball and Socket Constraint, used to simulate a joint\r\n *\r\n * @param pivotA - The first pivot, defined locally in the first body frame\r\n * @param pivotB - The second pivot, defined locally in the second body frame\r\n * @param axisA - The axis of the first body\r\n * @param axisB - The axis of the second body\r\n * @param scene - The scene the constraint is applied to\r\n * @returns The Ball and Socket Constraint\r\n *\r\n * This class is useful for simulating a joint between two bodies in a physics engine.\r\n * It allows for the two bodies to move relative to each other in a way that mimics a ball and socket joint, such as a shoulder or hip joint.\r\n */\r\nexport class BallAndSocketConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(PhysicsConstraintType.BALL_AND_SOCKET, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a distance constraint.\r\n * @param maxDistance distance between bodies\r\n * @param scene The scene the constraint belongs to\r\n * @returns DistanceConstraint\r\n *\r\n * This code is useful for creating a distance constraint in a physics engine.\r\n * A distance constraint is a type of constraint that keeps two objects at a certain distance from each other.\r\n * The scene is used to add the constraint to the physics engine.\r\n */\r\nexport class DistanceConstraint extends PhysicsConstraint {\r\n constructor(maxDistance: number, scene: Scene) {\r\n super(PhysicsConstraintType.DISTANCE, { maxDistance: maxDistance }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a HingeConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot point, in world space.\r\n * @param pivotB - The second pivot point, in world space.\r\n * @param scene - The scene the constraint is used in.\r\n * @returns The new HingeConstraint.\r\n *\r\n * This code is useful for creating a HingeConstraint, which is a type of PhysicsConstraint.\r\n * This constraint is used to simulate a hinge joint between two rigid bodies, allowing them to rotate around a single axis.\r\n */\r\nexport class HingeConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(PhysicsConstraintType.HINGE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a SliderConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint, in world space.\r\n * @param pivotB - The second pivot of the constraint, in world space.\r\n * @param axisA - The first axis of the constraint, in world space.\r\n * @param axisB - The second axis of the constraint, in world space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created SliderConstraint.\r\n *\r\n * This code is useful for creating a SliderConstraint, which is a type of PhysicsConstraint.\r\n * It allows the user to specify the two pivots and two axes of the constraint in world space, as well as the scene the constraint belongs to.\r\n * This is useful for creating a constraint between two rigid bodies that allows them to move along a certain axis.\r\n */\r\nexport class SliderConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(PhysicsConstraintType.SLIDER, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a LockConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a LockConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a LockConstraint.\r\n */\r\nexport class LockConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(PhysicsConstraintType.LOCK, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a PrismaticConstraint.\r\n */\r\nexport class PrismaticConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(PhysicsConstraintType.PRISMATIC, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a SpringConstraint, which is a type of Physics6DoFConstraint. This constraint applies a force at the ends which is proportional\r\n * to the distance between ends, and a stiffness and damping factor. The force is calculated as (stiffness * positionError) - (damping * velocity)\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param minDistance - The minimum distance between the two pivots.\r\n * @param maxDistance - The maximum distance between the two pivots.\r\n * @param stiffness - The stiffness of the spring.\r\n * @param damping - The damping of the spring.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created SpringConstraint.\r\n */\r\nexport class SpringConstraint extends Physics6DoFConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, minDistance: number, maxDistance: number, stiffness: number, damping: number, scene: Scene) {\r\n super({ pivotA, pivotB, axisA, axisB }, [{ axis: PhysicsConstraintAxis.LINEAR_DISTANCE, minLimit: minDistance, maxLimit: maxDistance, stiffness, damping }], scene);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsConstraint.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsConstraint.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEtF;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAiB1B;;;;;;;;OAQG;IACH,YAAY,IAA2B,EAAE,OAAoC,EAAE,KAAY;QAzB3F;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAuBhC,IAAI,CAAC,KAAK,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SAC1E;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kD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,KAAK,CAAC,CAAC;IAC7G,CAAC;CACJ;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD,YAAY,MAAe,EAAE,MAAe,EAAE,KAAc,EAAE,KAAc,EAAE,KAAY;QACtF,KAAK,CAAC,qBAAqB,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IAClH,CAAC;CACJ;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,gBAAiB,SAAQ,qBAAqB;IACvD,YAAY,MAAe,EAAE,MAAe,EAAE,KAAc,EAAE,KAAc,EAAE,WAAmB,EAAE,WAAmB,EAAE,SAAiB,EAAE,OAAe,EAAE,KAAY;QACpK,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,qBAAqB,CAAC,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACxK,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsConstraintParameters, PhysicsConstraintAxisLimitMode, PhysicsConstraintMotorType, ConstrainedBodyPair } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsConstraintAxis, PhysicsConstraintType } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n * This is a holder class for the physics constraint created by the physics plugin\r\n * It holds a set of functions to control the underlying constraint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsConstraint {\r\n /**\r\n * V2 Physics plugin private data for a physics material\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n protected _options: PhysicsConstraintParameters;\r\n protected _type: PhysicsConstraintType;\r\n /**\r\n * @internal\r\n * The internal options that were used to init the constraint\r\n */\r\n public _initOptions?: PhysicsConstraintParameters;\r\n\r\n /**\r\n * Constructs a new constraint for the physics constraint.\r\n * @param type The type of constraint to create.\r\n * @param options The options for the constraint.\r\n * @param scene The scene the constraint belongs to.\r\n *\r\n * This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.\r\n * If all checks pass, it initializes the constraint with the given type and options.\r\n */\r\n constructor(type: PhysicsConstraintType, options: PhysicsConstraintParameters, scene: Scene) {\r\n if (!scene) {\r\n throw new Error(\"Missing scene parameter for constraint constructor.\");\r\n }\r\n const physicsEngine = scene.getPhysicsEngine();\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n this._options = options;\r\n this._type = type;\r\n }\r\n\r\n /**\r\n * Gets the type of the constraint.\r\n *\r\n * @returns The type of the constraint.\r\n *\r\n */\r\n public get type(): PhysicsConstraintType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Retrieves the options of the physics constraint.\r\n *\r\n * @returns The physics constraint parameters.\r\n *\r\n */\r\n public get options(): PhysicsConstraintParameters {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Enable/disable the constraint\r\n * @param isEnabled value for the constraint\r\n */\r\n public set isEnabled(isEnabled: boolean) {\r\n this._physicsPlugin.setEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns true if constraint is enabled\r\n */\r\n public get isEnabled(): boolean {\r\n return this._physicsPlugin.getEnabled(this);\r\n }\r\n\r\n /**\r\n * Enables or disables collisions for the physics engine.\r\n *\r\n * @param isEnabled - A boolean value indicating whether collisions should be enabled or disabled.\r\n *\r\n */\r\n public set isCollisionsEnabled(isEnabled: boolean) {\r\n this._physicsPlugin.setCollisionsEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n * Gets whether collisions are enabled for this physics object.\r\n *\r\n * @returns `true` if collisions are enabled, `false` otherwise.\r\n *\r\n */\r\n public get isCollisionsEnabled(): boolean {\r\n return this._physicsPlugin.getCollisionsEnabled(this);\r\n }\r\n\r\n /**\r\n * Gets all bodies that are using this constraint\r\n * @returns\r\n */\r\n public getBodiesUsingConstraint(): ConstrainedBodyPair[] {\r\n return this._physicsPlugin.getBodiesUsingConstraint(this);\r\n }\r\n\r\n /**\r\n * Disposes the constraint from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeConstraint(this);\r\n }\r\n}\r\n\r\n/**\r\n * This describes a single limit used by Physics6DoFConstraint\r\n */\r\nexport class Physics6DoFLimit {\r\n /**\r\n * The axis ID to limit\r\n */\r\n axis: PhysicsConstraintAxis;\r\n /**\r\n * An optional minimum limit for the axis.\r\n * Corresponds to a distance in meters for linear axes, an angle in radians for angular axes.\r\n */\r\n minLimit?: number;\r\n /**\r\n * An optional maximum limit for the axis.\r\n * Corresponds to a distance in meters for linear axes, an angle in radians for angular axes.\r\n */\r\n maxLimit?: number;\r\n /**\r\n * The stiffness of the constraint.\r\n */\r\n stiffness?: number;\r\n /**\r\n * A constraint parameter that specifies damping.\r\n */\r\n damping?: number;\r\n}\r\n\r\n/**\r\n * A generic constraint, which can be used to build more complex constraints than those specified\r\n * in PhysicsConstraintType. The axis and pivot options in PhysicsConstraintParameters define the space\r\n * the constraint operates in. This constraint contains a set of limits, which restrict the\r\n * relative movement of the bodies in that coordinate system\r\n */\r\nexport class Physics6DoFConstraint extends PhysicsConstraint {\r\n /**\r\n * The collection of limits which this constraint will apply\r\n */\r\n public limits: Physics6DoFLimit[];\r\n\r\n constructor(constraintParams: PhysicsConstraintParameters, limits: Physics6DoFLimit[], scene: Scene) {\r\n super(PhysicsConstraintType.SIX_DOF, constraintParams, scene);\r\n this.limits = limits;\r\n }\r\n\r\n /**\r\n * Sets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine to set the friction for.\r\n * @param friction - The friction to set for the given axis.\r\n *\r\n */\r\n public setAxisFriction(axis: PhysicsConstraintAxis, friction: number): void {\r\n this._physicsPlugin.setAxisFriction(this, axis, friction);\r\n }\r\n\r\n /**\r\n * Gets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The friction of the given axis, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisFriction(axis: PhysicsConstraintAxis): Nullable<number> {\r\n return this._physicsPlugin.getAxisFriction(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the limit mode for the given axis of the constraint.\r\n * @param axis The axis to set the limit mode for.\r\n * @param limitMode The limit mode to set.\r\n *\r\n * This method is useful for setting the limit mode for a given axis of the constraint. This is important for\r\n * controlling the behavior of the physics engine when the constraint is reached. By setting the limit mode,\r\n * the engine can be configured to either stop the motion of the objects, or to allow them to continue\r\n * moving beyond the constraint.\r\n */\r\n public setAxisMode(axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void {\r\n this._physicsPlugin.setAxisMode(this, axis, limitMode);\r\n }\r\n\r\n /**\r\n * Gets the limit mode of the given axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The limit mode of the given axis, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisMode(axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintAxisLimitMode> {\r\n return this._physicsPlugin.getAxisMode(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the minimum limit of a given axis of a constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param minLimit - The minimum limit of the axis.\r\n *\r\n */\r\n public setAxisMinLimit(axis: PhysicsConstraintAxis, minLimit: number): void {\r\n this._physicsPlugin.setAxisMinLimit(this, axis, minLimit);\r\n }\r\n\r\n /**\r\n * Gets the minimum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The minimum limit of the given axis, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisMinLimit(axis: PhysicsConstraintAxis): Nullable<number> {\r\n return this._physicsPlugin.getAxisMinLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum limit of the given axis for the physics engine.\r\n * @param axis - The axis to set the limit for.\r\n * @param limit - The maximum limit of the axis.\r\n *\r\n * This method is useful for setting the maximum limit of the given axis for the physics engine,\r\n * which can be used to control the movement of the physics object. This helps to ensure that the\r\n * physics object does not move beyond the given limit.\r\n */\r\n public setAxisMaxLimit(axis: PhysicsConstraintAxis, limit: number): void {\r\n this._physicsPlugin.setAxisMaxLimit(this, axis, limit);\r\n }\r\n\r\n /**\r\n * Gets the maximum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The maximum limit of the given axis, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisMaxLimit(axis: PhysicsConstraintAxis): Nullable<number> {\r\n return this._physicsPlugin.getAxisMaxLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the motor type of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param motorType - The type of motor to use.\r\n * @returns void\r\n *\r\n */\r\n public setAxisMotorType(axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void {\r\n this._physicsPlugin.setAxisMotorType(this, axis, motorType);\r\n }\r\n\r\n /**\r\n * Gets the motor type of the specified axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The motor type of the specified axis, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisMotorType(axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintMotorType> {\r\n return this._physicsPlugin.getAxisMotorType(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the target velocity of the motor associated with the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param target - The target velocity of the motor.\r\n *\r\n * This method is useful for setting the target velocity of the motor associated with the given axis of the constraint.\r\n */\r\n public setAxisMotorTarget(axis: PhysicsConstraintAxis, target: number): void {\r\n this._physicsPlugin.setAxisMotorTarget(this, axis, target);\r\n }\r\n\r\n /**\r\n * Gets the target velocity of the motor associated to the given constraint axis.\r\n * @param axis - The constraint axis associated to the motor.\r\n * @returns The target velocity of the motor, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisMotorTarget(axis: PhysicsConstraintAxis): Nullable<number> {\r\n return this._physicsPlugin.getAxisMotorTarget(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param maxForce - The maximum force of the motor.\r\n *\r\n */\r\n public setAxisMotorMaxForce(axis: PhysicsConstraintAxis, maxForce: number): void {\r\n this._physicsPlugin.setAxisMotorMaxForce(this, axis, maxForce);\r\n }\r\n\r\n /**\r\n * Gets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @returns The maximum force of the motor, or null if the constraint hasn't been initialized yet.\r\n *\r\n */\r\n public getAxisMotorMaxForce(axis: PhysicsConstraintAxis): Nullable<number> {\r\n return this._physicsPlugin.getAxisMotorMaxForce(this, axis);\r\n }\r\n}\r\n\r\n/**\r\n * Represents a Ball and Socket Constraint, used to simulate a joint\r\n *\r\n * @param pivotA - The first pivot, defined locally in the first body frame\r\n * @param pivotB - The second pivot, defined locally in the second body frame\r\n * @param axisA - The axis of the first body\r\n * @param axisB - The axis of the second body\r\n * @param scene - The scene the constraint is applied to\r\n * @returns The Ball and Socket Constraint\r\n *\r\n * This class is useful for simulating a joint between two bodies in a physics engine.\r\n * It allows for the two bodies to move relative to each other in a way that mimics a ball and socket joint, such as a shoulder or hip joint.\r\n */\r\nexport class BallAndSocketConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(PhysicsConstraintType.BALL_AND_SOCKET, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a distance constraint.\r\n * @param maxDistance distance between bodies\r\n * @param scene The scene the constraint belongs to\r\n * @returns DistanceConstraint\r\n *\r\n * This code is useful for creating a distance constraint in a physics engine.\r\n * A distance constraint is a type of constraint that keeps two objects at a certain distance from each other.\r\n * The scene is used to add the constraint to the physics engine.\r\n */\r\nexport class DistanceConstraint extends PhysicsConstraint {\r\n constructor(maxDistance: number, scene: Scene) {\r\n super(PhysicsConstraintType.DISTANCE, { maxDistance: maxDistance }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a HingeConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot point, in world space.\r\n * @param pivotB - The second pivot point, in world space.\r\n * @param scene - The scene the constraint is used in.\r\n * @returns The new HingeConstraint.\r\n *\r\n * This code is useful for creating a HingeConstraint, which is a type of PhysicsConstraint.\r\n * This constraint is used to simulate a hinge joint between two rigid bodies, allowing them to rotate around a single axis.\r\n */\r\nexport class HingeConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(PhysicsConstraintType.HINGE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a SliderConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint, in world space.\r\n * @param pivotB - The second pivot of the constraint, in world space.\r\n * @param axisA - The first axis of the constraint, in world space.\r\n * @param axisB - The second axis of the constraint, in world space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created SliderConstraint.\r\n *\r\n * This code is useful for creating a SliderConstraint, which is a type of PhysicsConstraint.\r\n * It allows the user to specify the two pivots and two axes of the constraint in world space, as well as the scene the constraint belongs to.\r\n * This is useful for creating a constraint between two rigid bodies that allows them to move along a certain axis.\r\n */\r\nexport class SliderConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(PhysicsConstraintType.SLIDER, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a LockConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a LockConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a LockConstraint.\r\n */\r\nexport class LockConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(PhysicsConstraintType.LOCK, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a PrismaticConstraint.\r\n */\r\nexport class PrismaticConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(PhysicsConstraintType.PRISMATIC, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a SpringConstraint, which is a type of Physics6DoFConstraint. This constraint applies a force at the ends which is proportional\r\n * to the distance between ends, and a stiffness and damping factor. The force is calculated as (stiffness * positionError) - (damping * velocity)\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param minDistance - The minimum distance between the two pivots.\r\n * @param maxDistance - The maximum distance between the two pivots.\r\n * @param stiffness - The stiffness of the spring.\r\n * @param damping - The damping of the spring.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created SpringConstraint.\r\n */\r\nexport class SpringConstraint extends Physics6DoFConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, minDistance: number, maxDistance: number, stiffness: number, damping: number, scene: Scene) {\r\n super({ pivotA, pivotB, axisA, axisB }, [{ axis: PhysicsConstraintAxis.LINEAR_DISTANCE, minLimit: minDistance, maxLimit: maxDistance, stiffness, damping }], scene);\r\n }\r\n}\r\n"]}
@@ -44,6 +44,12 @@ export declare class PrePassRenderer {
44
44
  private _defaultAttachments;
45
45
  private _clearAttachments;
46
46
  private _clearDepthAttachments;
47
+ private _generateNormalsInWorldSpace;
48
+ /**
49
+ * Indicates if the prepass renderer is generating normals in world space or camera space (default: camera space)
50
+ */
51
+ get generateNormalsInWorldSpace(): boolean;
52
+ set generateNormalsInWorldSpace(value: boolean);
47
53
  /**
48
54
  * Returns the index of a texture in the multi render target texture array.
49
55
  * @param type Texture type
@@ -11,6 +11,19 @@ import { GeometryBufferRenderer } from "../Rendering/geometryBufferRenderer.js";
11
11
  * It is necessary for effects like subsurface scattering or deferred shading
12
12
  */
13
13
  export class PrePassRenderer {
14
+ /**
15
+ * Indicates if the prepass renderer is generating normals in world space or camera space (default: camera space)
16
+ */
17
+ get generateNormalsInWorldSpace() {
18
+ return this._generateNormalsInWorldSpace;
19
+ }
20
+ set generateNormalsInWorldSpace(value) {
21
+ if (this._generateNormalsInWorldSpace === value) {
22
+ return;
23
+ }
24
+ this._generateNormalsInWorldSpace = value;
25
+ this._markAllMaterialsAsPrePassDirty();
26
+ }
14
27
  /**
15
28
  * Returns the index of a texture in the multi render target texture array.
16
29
  * @param type Texture type
@@ -120,6 +133,7 @@ export class PrePassRenderer {
120
133
  this._mrtLayout = [];
121
134
  this._mrtNames = [];
122
135
  this._textureIndices = [];
136
+ this._generateNormalsInWorldSpace = false;
123
137
  this._useSpecificClearForDepthTexture = false;
124
138
  this._isDirty = true;
125
139
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"prePassRenderer.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/prePassRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAGhF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAIjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAuCxB;;;;OAIG;IACI,QAAQ,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;I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,iBAAiB;QACjC,MAAM,EAAE,SAAS,CAAC,eAAe;QACjC,IAAI,EAAE,eAAe;KACxB;IACD;QACI,OAAO,EAAE,SAAS,CAAC,2BAA2B;QAC9C,IAAI,EAAE,SAAS,CAAC,sBAAsB;QACtC,MAAM,EAAE,SAAS,CAAC,kBAAkB;QACpC,IAAI,EAAE,gBAAgB;KACzB;IACD;QACI,OAAO,EAAE,SAAS,CAAC,gCAAgC;QACnD,IAAI,EAAE,SAAS,CAAC,wBAAwB;QACxC,MAAM,EAAE,SAAS,CAAC,kBAAkB;QACpC,IAAI,EAAE,gBAAgB;KACzB;CACJ,AAjD2B,CAiD1B","sourcesContent":["import { PrePassRenderTarget } from \"../Materials/Textures/prePassRenderTarget\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Material } from \"../Materials/material\";\r\nimport type { SubMesh } from \"../Meshes/subMesh\";\r\nimport type { PrePassEffectConfiguration } from \"./prePassEffectConfiguration\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { GeometryBufferRenderer } from \"../Rendering/geometryBufferRenderer\";\r\n\r\n/**\r\n * Renders a pre pass of the scene\r\n * This means every mesh in the scene will be rendered to a render target texture\r\n * And then this texture will be composited to the rendering canvas with post processes\r\n * It is necessary for effects like subsurface scattering or deferred shading\r\n */\r\nexport class PrePassRenderer {\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"PrePassRendererSceneComponent\");\r\n };\r\n\r\n /**\r\n * To save performance, we can excluded skinned meshes from the prepass\r\n */\r\n public excludedSkinnedMesh: AbstractMesh[] = [];\r\n\r\n /**\r\n * Force material to be excluded from the prepass\r\n * Can be useful when `useGeometryBufferFallback` is set to `true`\r\n * and you don't want a material to show in the effect.\r\n */\r\n public excludedMaterials: Material[] = [];\r\n\r\n private _scene: Scene;\r\n private _engine: Engine;\r\n\r\n /**\r\n * Number of textures in the multi render target texture where the scene is directly rendered\r\n */\r\n public mrtCount: number = 0;\r\n\r\n private _mrtTypes: number[] = [];\r\n private _mrtFormats: number[] = [];\r\n private _mrtLayout: number[] = [];\r\n private _mrtNames: string[] = [];\r\n private _textureIndices: number[] = [];\r\n\r\n private _multiRenderAttachments: number[];\r\n private _defaultAttachments: number[];\r\n private _clearAttachments: number[];\r\n private _clearDepthAttachments: number[];\r\n\r\n /**\r\n * Returns the index of a texture in the multi render target texture array.\r\n * @param type Texture type\r\n * @returns The index\r\n */\r\n public getIndex(type: number): number {\r\n return this._textureIndices[type];\r\n }\r\n\r\n /**\r\n * How many samples are used for MSAA of the scene render target\r\n */\r\n public get samples() {\r\n return this.defaultRT.samples;\r\n }\r\n\r\n public set samples(n: number) {\r\n this.defaultRT.samples = n;\r\n }\r\n\r\n private _useSpecificClearForDepthTexture = false;\r\n\r\n /**\r\n * If set to true (default: false), the depth texture will be cleared with the depth value corresponding to the far plane (1 in normal mode, 0 in reverse depth buffer mode)\r\n * If set to false, the depth texture is always cleared with 0.\r\n */\r\n public get useSpecificClearForDepthTexture() {\r\n return this._useSpecificClearForDepthTexture;\r\n }\r\n\r\n public set useSpecificClearForDepthTexture(value: boolean) {\r\n if (this._useSpecificClearForDepthTexture === value) {\r\n return;\r\n }\r\n\r\n this._useSpecificClearForDepthTexture = value;\r\n this._isDirty = true;\r\n }\r\n\r\n /**\r\n * Describes the types and formats of the textures used by the pre-pass renderer\r\n */\r\n public static TextureFormats = [\r\n {\r\n purpose: Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Irradiance\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_POSITION_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Position\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_VELOCITY_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_UNSIGNED_INT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Velocity\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_UNSIGNED_INT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Reflectivity\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_COLOR_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Color\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_DEPTH_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_FLOAT,\r\n format: Constants.TEXTUREFORMAT_R,\r\n name: \"prePass_Depth\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_NORMAL_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Normal\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_UNSIGNED_INT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Albedo\",\r\n },\r\n ];\r\n\r\n private _isDirty: boolean = true;\r\n\r\n /**\r\n * The render target where the scene is directly rendered\r\n */\r\n public defaultRT: PrePassRenderTarget;\r\n\r\n /**\r\n * Configuration for prepass effects\r\n */\r\n private _effectConfigurations: PrePassEffectConfiguration[] = [];\r\n\r\n /**\r\n * @returns the prepass render target for the rendering pass.\r\n * If we are currently rendering a render target, it returns the PrePassRenderTarget\r\n * associated with that render target. Otherwise, it returns the scene default PrePassRenderTarget\r\n */\r\n public getRenderTarget(): PrePassRenderTarget {\r\n return this._currentTarget;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Managed by the scene component\r\n * @param prePassRenderTarget\r\n */\r\n public _setRenderTarget(prePassRenderTarget: Nullable<PrePassRenderTarget>): void {\r\n if (prePassRenderTarget) {\r\n this._currentTarget = prePassRenderTarget;\r\n } else {\r\n this._currentTarget = this.defaultRT;\r\n this._engine.currentRenderPassId = this._scene.activeCamera?.renderPassId ?? this._currentTarget.renderPassId;\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if the currently rendered prePassRenderTarget is the one\r\n * associated with the scene.\r\n */\r\n public get currentRTisSceneRT(): boolean {\r\n return this._currentTarget === this.defaultRT;\r\n }\r\n\r\n private _geometryBuffer: Nullable<GeometryBufferRenderer>;\r\n\r\n /**\r\n * Prevents the PrePassRenderer from using the GeometryBufferRenderer as a fallback\r\n */\r\n public doNotUseGeometryRendererFallback = true;\r\n\r\n private _refreshGeometryBufferRendererLink() {\r\n if (!this.doNotUseGeometryRendererFallback) {\r\n this._geometryBuffer = this._scene.enableGeometryBufferRenderer();\r\n\r\n if (!this._geometryBuffer) {\r\n // Not supported\r\n this.doNotUseGeometryRendererFallback = true;\r\n return;\r\n }\r\n\r\n this._geometryBuffer._linkPrePassRenderer(this);\r\n } else {\r\n if (this._geometryBuffer) {\r\n this._geometryBuffer._unlinkPrePassRenderer();\r\n }\r\n this._geometryBuffer = null;\r\n this._scene.disableGeometryBufferRenderer();\r\n }\r\n }\r\n\r\n private _currentTarget: PrePassRenderTarget;\r\n\r\n /**\r\n * All the render targets generated by prepass\r\n */\r\n public renderTargets: PrePassRenderTarget[] = [];\r\n\r\n private readonly _clearColor = new Color4(0, 0, 0, 0);\r\n private readonly _clearDepthColor = new Color4(1e8, 0, 0, 1); // \"infinity\" value - depth in the depth texture is view.z, not a 0..1 value!\r\n\r\n private _enabled: boolean = false;\r\n\r\n private _needsCompositionForThisPass = false;\r\n private _postProcessesSourceForThisPass: Nullable<PostProcess>[];\r\n\r\n /**\r\n * Indicates if the prepass is enabled\r\n */\r\n public get enabled() {\r\n return this._enabled;\r\n }\r\n\r\n /**\r\n * Set to true to disable gamma transform in PrePass.\r\n * Can be useful in case you already proceed to gamma transform on a material level\r\n * and your post processes don't need to be in linear color space.\r\n */\r\n public disableGammaTransform = false;\r\n\r\n /**\r\n * Instantiates a prepass renderer\r\n * @param scene The scene\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n\r\n let type = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (this._engine._caps.textureFloat && this._engine._caps.textureFloatLinearFiltering) {\r\n type = Constants.TEXTURETYPE_FLOAT;\r\n } else if (this._engine._caps.textureHalfFloat && this._engine._caps.textureHalfFloatLinearFiltering) {\r\n type = Constants.TEXTURETYPE_HALF_FLOAT;\r\n }\r\n\r\n if (type !== Constants.TEXTURETYPE_FLOAT) {\r\n for (let i = 0; i < PrePassRenderer.TextureFormats.length; ++i) {\r\n if (PrePassRenderer.TextureFormats[i].type === Constants.TEXTURETYPE_FLOAT) {\r\n PrePassRenderer.TextureFormats[Constants.PREPASS_DEPTH_TEXTURE_TYPE].type = type;\r\n }\r\n }\r\n }\r\n\r\n PrePassRenderer._SceneComponentInitialization(this._scene);\r\n this.defaultRT = this._createRenderTarget(\"sceneprePassRT\", null);\r\n this._currentTarget = this.defaultRT;\r\n }\r\n\r\n /**\r\n * Creates a new PrePassRenderTarget\r\n * This should be the only way to instantiate a `PrePassRenderTarget`\r\n * @param name Name of the `PrePassRenderTarget`\r\n * @param renderTargetTexture RenderTarget the `PrePassRenderTarget` will be attached to.\r\n * Can be `null` if the created `PrePassRenderTarget` is attached to the scene (default framebuffer).\r\n * @internal\r\n */\r\n public _createRenderTarget(name: string, renderTargetTexture: Nullable<RenderTargetTexture>): PrePassRenderTarget {\r\n const rt = new PrePassRenderTarget(name, renderTargetTexture, { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() }, 0, this._scene, {\r\n generateMipMaps: false,\r\n generateStencilBuffer: this._engine.isStencilEnable,\r\n defaultType: Constants.TEXTURETYPE_UNSIGNED_INT,\r\n types: [],\r\n drawOnlyOnFirstAttachmentByDefault: true,\r\n });\r\n\r\n this.renderTargets.push(rt);\r\n\r\n if (this._enabled) {\r\n // The pre-pass renderer is already enabled, so make sure we create the render target with the correct number of textures\r\n this._update();\r\n }\r\n\r\n return rt;\r\n }\r\n\r\n /**\r\n * Indicates if rendering a prepass is supported\r\n */\r\n public get isSupported() {\r\n return this._scene.getEngine().getCaps().drawBuffersExtension;\r\n }\r\n\r\n /**\r\n * Sets the proper output textures to draw in the engine.\r\n * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.\r\n * @param subMesh Submesh on which the effect is applied\r\n */\r\n public bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh) {\r\n const material = subMesh.getMaterial();\r\n const isPrePassCapable = material && material.isPrePassCapable;\r\n const excluded = material && this.excludedMaterials.indexOf(material) !== -1;\r\n\r\n if (this.enabled && this._currentTarget.enabled) {\r\n if (effect._multiTarget && isPrePassCapable && !excluded) {\r\n this._engine.bindAttachments(this._multiRenderAttachments);\r\n } else {\r\n if (this._engine._currentRenderTarget) {\r\n this._engine.bindAttachments(this._defaultAttachments);\r\n } else {\r\n this._engine.restoreSingleAttachment();\r\n }\r\n\r\n if (this._geometryBuffer && this.currentRTisSceneRT && !excluded) {\r\n this._geometryBuffer.renderList!.push(subMesh.getRenderingMesh());\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _reinitializeAttachments() {\r\n const multiRenderLayout = [];\r\n const clearLayout = [false];\r\n const clearDepthLayout = [false];\r\n const defaultLayout = [true];\r\n\r\n for (let i = 0; i < this.mrtCount; i++) {\r\n multiRenderLayout.push(true);\r\n\r\n if (i > 0) {\r\n if (this._useSpecificClearForDepthTexture && this._mrtLayout[i] === Constants.PREPASS_DEPTH_TEXTURE_TYPE) {\r\n clearLayout.push(false);\r\n clearDepthLayout.push(true);\r\n } else {\r\n clearLayout.push(true);\r\n clearDepthLayout.push(false);\r\n }\r\n defaultLayout.push(false);\r\n }\r\n }\r\n\r\n this._multiRenderAttachments = this._engine.buildTextureLayout(multiRenderLayout);\r\n this._clearAttachments = this._engine.buildTextureLayout(clearLayout);\r\n this._clearDepthAttachments = this._engine.buildTextureLayout(clearDepthLayout);\r\n this._defaultAttachments = this._engine.buildTextureLayout(defaultLayout);\r\n }\r\n\r\n private _resetLayout() {\r\n for (let i = 0; i < PrePassRenderer.TextureFormats.length; i++) {\r\n this._textureIndices[PrePassRenderer.TextureFormats[i].purpose] = -1;\r\n }\r\n\r\n this._textureIndices[Constants.PREPASS_COLOR_TEXTURE_TYPE] = 0;\r\n this._mrtLayout = [Constants.PREPASS_COLOR_TEXTURE_TYPE];\r\n this._mrtTypes = [PrePassRenderer.TextureFormats[Constants.PREPASS_COLOR_TEXTURE_TYPE].type];\r\n this._mrtFormats = [PrePassRenderer.TextureFormats[Constants.PREPASS_COLOR_TEXTURE_TYPE].format];\r\n this._mrtNames = [PrePassRenderer.TextureFormats[Constants.PREPASS_COLOR_TEXTURE_TYPE].name];\r\n this.mrtCount = 1;\r\n }\r\n\r\n private _updateGeometryBufferLayout() {\r\n this._refreshGeometryBufferRendererLink();\r\n\r\n if (this._geometryBuffer) {\r\n this._geometryBuffer._resetLayout();\r\n\r\n const texturesActivated = [];\r\n\r\n for (let i = 0; i < this._mrtLayout.length; i++) {\r\n texturesActivated.push(false);\r\n }\r\n\r\n this._geometryBuffer._linkInternalTexture(this.defaultRT.getInternalTexture()!);\r\n\r\n const matches = [\r\n {\r\n prePassConstant: Constants.PREPASS_DEPTH_TEXTURE_TYPE,\r\n geometryBufferConstant: GeometryBufferRenderer.DEPTH_TEXTURE_TYPE,\r\n },\r\n {\r\n prePassConstant: Constants.PREPASS_NORMAL_TEXTURE_TYPE,\r\n geometryBufferConstant: GeometryBufferRenderer.NORMAL_TEXTURE_TYPE,\r\n },\r\n {\r\n prePassConstant: Constants.PREPASS_POSITION_TEXTURE_TYPE,\r\n geometryBufferConstant: GeometryBufferRenderer.POSITION_TEXTURE_TYPE,\r\n },\r\n {\r\n prePassConstant: Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE,\r\n geometryBufferConstant: GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE,\r\n },\r\n {\r\n prePassConstant: Constants.PREPASS_VELOCITY_TEXTURE_TYPE,\r\n geometryBufferConstant: GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE,\r\n },\r\n ];\r\n\r\n // replace textures in the geometryBuffer RT\r\n for (let i = 0; i < matches.length; i++) {\r\n const index = this._mrtLayout.indexOf(matches[i].prePassConstant);\r\n if (index !== -1) {\r\n this._geometryBuffer._forceTextureType(matches[i].geometryBufferConstant, index);\r\n texturesActivated[index] = true;\r\n }\r\n }\r\n\r\n this._geometryBuffer._setAttachments(this._engine.buildTextureLayout(texturesActivated));\r\n }\r\n }\r\n\r\n /**\r\n * Restores attachments for single texture draw.\r\n */\r\n public restoreAttachments() {\r\n if (this.enabled && this._currentTarget.enabled && this._defaultAttachments) {\r\n if (this._engine._currentRenderTarget) {\r\n this._engine.bindAttachments(this._defaultAttachments);\r\n } else {\r\n this._engine.restoreSingleAttachment();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public _beforeDraw(camera?: Camera, faceIndex?: number, layer?: number) {\r\n // const previousEnabled = this._enabled && this._currentTarget.enabled;\r\n\r\n if (this._isDirty) {\r\n this._update();\r\n }\r\n\r\n if (!this._enabled || !this._currentTarget.enabled) {\r\n return;\r\n }\r\n\r\n if (this._geometryBuffer) {\r\n this._geometryBuffer.renderList = [];\r\n }\r\n\r\n this._setupOutputForThisPass(this._currentTarget, camera);\r\n }\r\n\r\n private _prepareFrame(prePassRenderTarget: PrePassRenderTarget, faceIndex?: number, layer?: number) {\r\n if (prePassRenderTarget.renderTargetTexture) {\r\n prePassRenderTarget.renderTargetTexture._prepareFrame(this._scene, faceIndex, layer, prePassRenderTarget.renderTargetTexture.useCameraPostProcesses);\r\n } else if (this._postProcessesSourceForThisPass.length) {\r\n this._scene.postProcessManager._prepareFrame();\r\n } else {\r\n this._engine.restoreDefaultFramebuffer();\r\n }\r\n }\r\n\r\n /**\r\n * Sets an intermediary texture between prepass and postprocesses. This texture\r\n * will be used as input for post processes\r\n * @param rt\r\n * @returns true if there are postprocesses that will use this texture,\r\n * false if there is no postprocesses - and the function has no effect\r\n */\r\n public setCustomOutput(rt: RenderTargetTexture) {\r\n const firstPP = this._postProcessesSourceForThisPass[0];\r\n if (!firstPP) {\r\n return false;\r\n }\r\n\r\n firstPP.inputTexture = rt.renderTarget!;\r\n\r\n return true;\r\n }\r\n\r\n private _renderPostProcesses(prePassRenderTarget: PrePassRenderTarget, faceIndex?: number) {\r\n const firstPP = this._postProcessesSourceForThisPass[0];\r\n const outputTexture = firstPP ? firstPP.inputTexture : prePassRenderTarget.renderTargetTexture ? prePassRenderTarget.renderTargetTexture.renderTarget : null;\r\n\r\n // Build post process chain for this prepass post draw\r\n let postProcessChain = this._currentTarget._beforeCompositionPostProcesses;\r\n\r\n if (this._needsCompositionForThisPass) {\r\n postProcessChain = postProcessChain.concat([this._currentTarget.imageProcessingPostProcess]);\r\n }\r\n\r\n // Activates and renders the chain\r\n if (postProcessChain.length) {\r\n this._scene.postProcessManager._prepareFrame(this._currentTarget.renderTarget?.texture, postProcessChain);\r\n this._scene.postProcessManager.directRender(postProcessChain, outputTexture, false, faceIndex);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _afterDraw(faceIndex?: number, layer?: number) {\r\n if (this._enabled && this._currentTarget.enabled) {\r\n this._prepareFrame(this._currentTarget, faceIndex, layer);\r\n this._renderPostProcesses(this._currentTarget, faceIndex);\r\n }\r\n }\r\n\r\n /**\r\n * Clears the current prepass render target (in the sense of settings pixels to the scene clear color value)\r\n * @internal\r\n */\r\n public _clear() {\r\n if (this._enabled && this._currentTarget.enabled) {\r\n this._bindFrameBuffer();\r\n\r\n // Clearing other attachment with 0 on all other attachments\r\n this._engine.bindAttachments(this._clearAttachments);\r\n this._engine.clear(this._clearColor, true, false, false);\r\n if (this._useSpecificClearForDepthTexture) {\r\n this._engine.bindAttachments(this._clearDepthAttachments);\r\n this._engine.clear(this._clearDepthColor, true, false, false);\r\n }\r\n // Regular clear color with the scene clear color of the 1st attachment\r\n this._engine.bindAttachments(this._defaultAttachments);\r\n }\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _bindFrameBuffer() {\r\n if (this._enabled && this._currentTarget.enabled) {\r\n this._currentTarget._checkSize();\r\n const internalTexture = this._currentTarget.renderTarget;\r\n if (internalTexture) {\r\n this._engine.bindFramebuffer(internalTexture);\r\n }\r\n }\r\n }\r\n\r\n private _setEnabled(enabled: boolean) {\r\n this._enabled = enabled;\r\n }\r\n\r\n private _setRenderTargetEnabled(prePassRenderTarget: PrePassRenderTarget, enabled: boolean) {\r\n prePassRenderTarget.enabled = enabled;\r\n if (!enabled) {\r\n this._unlinkInternalTexture(prePassRenderTarget);\r\n }\r\n }\r\n\r\n /**\r\n * Adds an effect configuration to the prepass render target.\r\n * If an effect has already been added, it won't add it twice and will return the configuration\r\n * already present.\r\n * @param cfg the effect configuration\r\n * @returns the effect configuration now used by the prepass\r\n */\r\n public addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration {\r\n // Do not add twice\r\n for (let i = 0; i < this._effectConfigurations.length; i++) {\r\n if (this._effectConfigurations[i].name === cfg.name) {\r\n return this._effectConfigurations[i];\r\n }\r\n }\r\n\r\n this._effectConfigurations.push(cfg);\r\n return cfg;\r\n }\r\n\r\n /**\r\n * Retrieves an effect configuration by name\r\n * @param name\r\n * @returns the effect configuration, or null if not present\r\n */\r\n public getEffectConfiguration(name: string): Nullable<PrePassEffectConfiguration> {\r\n for (let i = 0; i < this._effectConfigurations.length; i++) {\r\n if (this._effectConfigurations[i].name === name) {\r\n return this._effectConfigurations[i];\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n private _enable() {\r\n const previousMrtCount = this.mrtCount;\r\n\r\n for (let i = 0; i < this._effectConfigurations.length; i++) {\r\n if (this._effectConfigurations[i].enabled) {\r\n this._enableTextures(this._effectConfigurations[i].texturesRequired);\r\n }\r\n }\r\n\r\n for (let i = 0; i < this.renderTargets.length; i++) {\r\n if (this.mrtCount !== previousMrtCount || this.renderTargets[i].count !== this.mrtCount) {\r\n this.renderTargets[i].updateCount(this.mrtCount, { types: this._mrtTypes, formats: this._mrtFormats }, this._mrtNames.concat(\"prePass_DepthBuffer\"));\r\n }\r\n\r\n this.renderTargets[i]._resetPostProcessChain();\r\n\r\n for (let j = 0; j < this._effectConfigurations.length; j++) {\r\n if (this._effectConfigurations[j].enabled) {\r\n // TODO : subsurface scattering has 1 scene-wide effect configuration\r\n // solution : do not stock postProcess on effectConfiguration, but in the prepassRenderTarget (hashmap configuration => postProcess)\r\n // And call createPostProcess whenever the post process does not exist in the RT\r\n if (!this._effectConfigurations[j].postProcess && this._effectConfigurations[j].createPostProcess) {\r\n this._effectConfigurations[j].createPostProcess!();\r\n }\r\n\r\n if (this._effectConfigurations[j].postProcess) {\r\n this.renderTargets[i]._beforeCompositionPostProcesses.push(this._effectConfigurations[j].postProcess!);\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._reinitializeAttachments();\r\n this._setEnabled(true);\r\n this._updateGeometryBufferLayout();\r\n }\r\n\r\n private _disable() {\r\n this._setEnabled(false);\r\n\r\n for (let i = 0; i < this.renderTargets.length; i++) {\r\n this._setRenderTargetEnabled(this.renderTargets[i], false);\r\n }\r\n\r\n this._resetLayout();\r\n\r\n for (let i = 0; i < this._effectConfigurations.length; i++) {\r\n this._effectConfigurations[i].enabled = false;\r\n }\r\n }\r\n\r\n private _getPostProcessesSource(prePassRenderTarget: PrePassRenderTarget, camera?: Camera): Nullable<PostProcess>[] {\r\n if (camera) {\r\n return camera._postProcesses;\r\n } else if (prePassRenderTarget.renderTargetTexture) {\r\n if (prePassRenderTarget.renderTargetTexture.useCameraPostProcesses) {\r\n const camera = prePassRenderTarget.renderTargetTexture.activeCamera ? prePassRenderTarget.renderTargetTexture.activeCamera : this._scene.activeCamera;\r\n return camera ? camera._postProcesses : [];\r\n } else if (prePassRenderTarget.renderTargetTexture.postProcesses) {\r\n return prePassRenderTarget.renderTargetTexture.postProcesses;\r\n } else {\r\n return [];\r\n }\r\n } else {\r\n return this._scene.activeCamera ? this._scene.activeCamera._postProcesses : [];\r\n }\r\n }\r\n\r\n private _setupOutputForThisPass(prePassRenderTarget: PrePassRenderTarget, camera?: Camera) {\r\n // Order is : draw ===> prePassRenderTarget._postProcesses ==> ipp ==> camera._postProcesses\r\n const secondaryCamera = camera && this._scene.activeCameras && !!this._scene.activeCameras.length && this._scene.activeCameras.indexOf(camera) !== 0;\r\n this._postProcessesSourceForThisPass = this._getPostProcessesSource(prePassRenderTarget, camera);\r\n this._postProcessesSourceForThisPass = this._postProcessesSourceForThisPass.filter((pp) => {\r\n return pp != null;\r\n });\r\n this._scene.autoClear = true;\r\n\r\n const cameraHasImageProcessing = this._hasImageProcessing(this._postProcessesSourceForThisPass);\r\n this._needsCompositionForThisPass = !cameraHasImageProcessing && !this.disableGammaTransform && this._needsImageProcessing() && !secondaryCamera;\r\n\r\n const firstCameraPP = this._getFirstPostProcess(this._postProcessesSourceForThisPass);\r\n const firstPrePassPP = prePassRenderTarget._beforeCompositionPostProcesses && prePassRenderTarget._beforeCompositionPostProcesses[0];\r\n let firstPP = null;\r\n\r\n // Setting the scene-wide post process configuration\r\n this._scene.imageProcessingConfiguration.applyByPostProcess = this._needsCompositionForThisPass || cameraHasImageProcessing;\r\n\r\n // Create composition effect if needed\r\n if (this._needsCompositionForThisPass && !prePassRenderTarget.imageProcessingPostProcess) {\r\n prePassRenderTarget._createCompositionEffect();\r\n }\r\n\r\n // Setting the prePassRenderTarget as input texture of the first PP\r\n if (firstPrePassPP) {\r\n firstPP = firstPrePassPP;\r\n } else if (this._needsCompositionForThisPass) {\r\n firstPP = prePassRenderTarget.imageProcessingPostProcess;\r\n } else if (firstCameraPP) {\r\n firstPP = firstCameraPP;\r\n }\r\n\r\n this._bindFrameBuffer();\r\n this._linkInternalTexture(prePassRenderTarget, firstPP);\r\n }\r\n\r\n private _linkInternalTexture(prePassRenderTarget: PrePassRenderTarget, postProcess: Nullable<PostProcess>) {\r\n if (postProcess) {\r\n postProcess.autoClear = false;\r\n postProcess.inputTexture = prePassRenderTarget.renderTarget!;\r\n }\r\n\r\n if (prePassRenderTarget._outputPostProcess !== postProcess) {\r\n if (prePassRenderTarget._outputPostProcess) {\r\n this._unlinkInternalTexture(prePassRenderTarget);\r\n }\r\n prePassRenderTarget._outputPostProcess = postProcess;\r\n }\r\n\r\n if (prePassRenderTarget._internalTextureDirty) {\r\n this._updateGeometryBufferLayout();\r\n prePassRenderTarget._internalTextureDirty = false;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _unlinkInternalTexture(prePassRenderTarget: PrePassRenderTarget) {\r\n if (prePassRenderTarget._outputPostProcess) {\r\n prePassRenderTarget._outputPostProcess.autoClear = true;\r\n prePassRenderTarget._outputPostProcess.restoreDefaultInputTexture();\r\n prePassRenderTarget._outputPostProcess = null;\r\n }\r\n }\r\n\r\n private _needsImageProcessing(): boolean {\r\n for (let i = 0; i < this._effectConfigurations.length; i++) {\r\n if (this._effectConfigurations[i].enabled && this._effectConfigurations[i].needsImageProcessing) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n private _hasImageProcessing(postProcesses: Nullable<PostProcess>[]): boolean {\r\n let isIPPAlreadyPresent = false;\r\n if (postProcesses) {\r\n for (let i = 0; i < postProcesses.length; i++) {\r\n if (postProcesses[i]?.getClassName() === \"ImageProcessingPostProcess\") {\r\n isIPPAlreadyPresent = true;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return isIPPAlreadyPresent;\r\n }\r\n\r\n /**\r\n * Internal, gets the first post proces.\r\n * @param postProcesses\r\n * @returns the first post process to be run on this camera.\r\n */\r\n private _getFirstPostProcess(postProcesses: Nullable<PostProcess>[]): Nullable<PostProcess> {\r\n for (let ppIndex = 0; ppIndex < postProcesses.length; ppIndex++) {\r\n if (postProcesses[ppIndex] !== null) {\r\n return postProcesses[ppIndex];\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.\r\n */\r\n public markAsDirty() {\r\n this._isDirty = true;\r\n }\r\n\r\n /**\r\n * Enables a texture on the MultiRenderTarget for prepass\r\n * @param types\r\n */\r\n private _enableTextures(types: number[]) {\r\n // For velocity : enable storage of previous matrices for instances\r\n this._scene.needsPreviousWorldMatrices = false;\r\n\r\n for (let i = 0; i < types.length; i++) {\r\n const type = types[i];\r\n\r\n if (this._textureIndices[type] === -1) {\r\n this._textureIndices[type] = this._mrtLayout.length;\r\n this._mrtLayout.push(type);\r\n\r\n this._mrtTypes.push(PrePassRenderer.TextureFormats[type].type);\r\n this._mrtFormats.push(PrePassRenderer.TextureFormats[type].format);\r\n this._mrtNames.push(PrePassRenderer.TextureFormats[type].name);\r\n this.mrtCount++;\r\n }\r\n\r\n if (type === Constants.PREPASS_VELOCITY_TEXTURE_TYPE) {\r\n this._scene.needsPreviousWorldMatrices = true;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Makes sure that the prepass renderer is up to date if it has been dirtified.\r\n */\r\n public update() {\r\n if (this._isDirty) {\r\n this._update();\r\n }\r\n }\r\n\r\n private _update() {\r\n this._disable();\r\n let enablePrePass = false;\r\n this._scene.imageProcessingConfiguration.applyByPostProcess = false;\r\n\r\n if (this._scene._depthPeelingRenderer && this._scene.useOrderIndependentTransparency) {\r\n this._scene._depthPeelingRenderer.setPrePassRenderer(this);\r\n enablePrePass = true;\r\n }\r\n\r\n for (let i = 0; i < this._scene.materials.length; i++) {\r\n if (this._scene.materials[i].setPrePassRenderer(this)) {\r\n enablePrePass = true;\r\n }\r\n }\r\n\r\n if (enablePrePass) {\r\n this._setRenderTargetEnabled(this.defaultRT, true);\r\n }\r\n\r\n let postProcesses;\r\n\r\n for (let i = 0; i < this.renderTargets.length; i++) {\r\n if (this.renderTargets[i].renderTargetTexture) {\r\n postProcesses = this._getPostProcessesSource(this.renderTargets[i]);\r\n } else {\r\n const camera = this._scene.activeCamera;\r\n if (!camera) {\r\n continue;\r\n }\r\n\r\n postProcesses = camera._postProcesses;\r\n }\r\n\r\n if (!postProcesses) {\r\n continue;\r\n }\r\n\r\n postProcesses = <Nullable<PostProcess[]>>postProcesses.filter((pp) => {\r\n return pp != null;\r\n });\r\n\r\n if (postProcesses) {\r\n for (let j = 0; j < postProcesses.length; j++) {\r\n if (postProcesses[j].setPrePassRenderer(this)) {\r\n this._setRenderTargetEnabled(this.renderTargets[i], true);\r\n enablePrePass = true;\r\n }\r\n }\r\n\r\n if (this._hasImageProcessing(postProcesses)) {\r\n this._scene.imageProcessingConfiguration.applyByPostProcess = true;\r\n }\r\n }\r\n }\r\n\r\n this._markAllMaterialsAsPrePassDirty();\r\n this._isDirty = false;\r\n\r\n if (enablePrePass) {\r\n this._enable();\r\n }\r\n }\r\n\r\n private _markAllMaterialsAsPrePassDirty() {\r\n const materials = this._scene.materials;\r\n\r\n for (let i = 0; i < materials.length; i++) {\r\n materials[i].markAsDirty(Material.PrePassDirtyFlag);\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the prepass renderer.\r\n */\r\n public dispose() {\r\n for (let i = this.renderTargets.length - 1; i >= 0; i--) {\r\n this.renderTargets[i].dispose();\r\n }\r\n\r\n for (let i = 0; i < this._effectConfigurations.length; i++) {\r\n if (this._effectConfigurations[i].dispose) {\r\n this._effectConfigurations[i].dispose!();\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"prePassRenderer.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/prePassRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAGhF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAIjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAwCxB;;OAEG;IACH,IAAW,2BAA2B;QAClC,OAAO,IAAI,CAAC,4BAA4B,CAAC;IAC7C,CAAC;IAED,IAAW,2BAA2B,CAAC,KAAc;QACjD,IAAI,IAAI,CAAC,4BAA4B,KAAK,KAAK,EAAE;YAC7C,OAAO;SACV;QAED,IAAI,CAAC,4BAA4B,GAAG,KAAK,CAAC;QAC1C,IAAI,CAAC,+BAA+B,EAAE,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACI,QAAQ,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,IAAW,OAAO,CAAC,CAAS;QACxB,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,CAAC,CAAC;IAC/B,CAAC;IAID;;;OAGG;IACH,IAAW,+BAA+B;QACtC,OAAO,IAAI,CAAC,gCAAgC,CAAC;IACjD,CAAC;IAED,IAAW,+BAA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,gCAAgC;QACnD,IAAI,EAAE,SAAS,CAAC,wBAAwB;QACxC,MAAM,EAAE,SAAS,CAAC,kBAAkB;QACpC,IAAI,EAAE,gBAAgB;KACzB;CACJ,AAjD2B,CAiD1B","sourcesContent":["import { PrePassRenderTarget } from \"../Materials/Textures/prePassRenderTarget\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Material } from \"../Materials/material\";\r\nimport type { SubMesh } from \"../Meshes/subMesh\";\r\nimport type { PrePassEffectConfiguration } from \"./prePassEffectConfiguration\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { GeometryBufferRenderer } from \"../Rendering/geometryBufferRenderer\";\r\n\r\n/**\r\n * Renders a pre pass of the scene\r\n * This means every mesh in the scene will be rendered to a render target texture\r\n * And then this texture will be composited to the rendering canvas with post processes\r\n * It is necessary for effects like subsurface scattering or deferred shading\r\n */\r\nexport class PrePassRenderer {\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"PrePassRendererSceneComponent\");\r\n };\r\n\r\n /**\r\n * To save performance, we can excluded skinned meshes from the prepass\r\n */\r\n public excludedSkinnedMesh: AbstractMesh[] = [];\r\n\r\n /**\r\n * Force material to be excluded from the prepass\r\n * Can be useful when `useGeometryBufferFallback` is set to `true`\r\n * and you don't want a material to show in the effect.\r\n */\r\n public excludedMaterials: Material[] = [];\r\n\r\n private _scene: Scene;\r\n private _engine: Engine;\r\n\r\n /**\r\n * Number of textures in the multi render target texture where the scene is directly rendered\r\n */\r\n public mrtCount: number = 0;\r\n\r\n private _mrtTypes: number[] = [];\r\n private _mrtFormats: number[] = [];\r\n private _mrtLayout: number[] = [];\r\n private _mrtNames: string[] = [];\r\n private _textureIndices: number[] = [];\r\n\r\n private _multiRenderAttachments: number[];\r\n private _defaultAttachments: number[];\r\n private _clearAttachments: number[];\r\n private _clearDepthAttachments: number[];\r\n private _generateNormalsInWorldSpace = false;\r\n\r\n /**\r\n * Indicates if the prepass renderer is generating normals in world space or camera space (default: camera space)\r\n */\r\n public get generateNormalsInWorldSpace() {\r\n return this._generateNormalsInWorldSpace;\r\n }\r\n\r\n public set generateNormalsInWorldSpace(value: boolean) {\r\n if (this._generateNormalsInWorldSpace === value) {\r\n return;\r\n }\r\n\r\n this._generateNormalsInWorldSpace = value;\r\n this._markAllMaterialsAsPrePassDirty();\r\n }\r\n\r\n /**\r\n * Returns the index of a texture in the multi render target texture array.\r\n * @param type Texture type\r\n * @returns The index\r\n */\r\n public getIndex(type: number): number {\r\n return this._textureIndices[type];\r\n }\r\n\r\n /**\r\n * How many samples are used for MSAA of the scene render target\r\n */\r\n public get samples() {\r\n return this.defaultRT.samples;\r\n }\r\n\r\n public set samples(n: number) {\r\n this.defaultRT.samples = n;\r\n }\r\n\r\n private _useSpecificClearForDepthTexture = false;\r\n\r\n /**\r\n * If set to true (default: false), the depth texture will be cleared with the depth value corresponding to the far plane (1 in normal mode, 0 in reverse depth buffer mode)\r\n * If set to false, the depth texture is always cleared with 0.\r\n */\r\n public get useSpecificClearForDepthTexture() {\r\n return this._useSpecificClearForDepthTexture;\r\n }\r\n\r\n public set useSpecificClearForDepthTexture(value: boolean) {\r\n if (this._useSpecificClearForDepthTexture === value) {\r\n return;\r\n }\r\n\r\n this._useSpecificClearForDepthTexture = value;\r\n this._isDirty = true;\r\n }\r\n\r\n /**\r\n * Describes the types and formats of the textures used by the pre-pass renderer\r\n */\r\n public static TextureFormats = [\r\n {\r\n purpose: Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Irradiance\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_POSITION_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Position\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_VELOCITY_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_UNSIGNED_INT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Velocity\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_UNSIGNED_INT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Reflectivity\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_COLOR_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Color\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_DEPTH_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_FLOAT,\r\n format: Constants.TEXTUREFORMAT_R,\r\n name: \"prePass_Depth\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_NORMAL_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Normal\",\r\n },\r\n {\r\n purpose: Constants.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,\r\n type: Constants.TEXTURETYPE_UNSIGNED_INT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n name: \"prePass_Albedo\",\r\n },\r\n ];\r\n\r\n private _isDirty: boolean = true;\r\n\r\n /**\r\n * The render target where the scene is directly rendered\r\n */\r\n public defaultRT: PrePassRenderTarget;\r\n\r\n /**\r\n * Configuration for prepass effects\r\n */\r\n private _effectConfigurations: PrePassEffectConfiguration[] = [];\r\n\r\n /**\r\n * @returns the prepass render target for the rendering pass.\r\n * If we are currently rendering a render target, it returns the PrePassRenderTarget\r\n * associated with that render target. Otherwise, it returns the scene default PrePassRenderTarget\r\n */\r\n public getRenderTarget(): PrePassRenderTarget {\r\n return this._currentTarget;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Managed by the scene component\r\n * @param prePassRenderTarget\r\n */\r\n public _setRenderTarget(prePassRenderTarget: Nullable<PrePassRenderTarget>): void {\r\n if (prePassRenderTarget) {\r\n this._currentTarget = prePassRenderTarget;\r\n } else {\r\n this._currentTarget = this.defaultRT;\r\n this._engine.currentRenderPassId = this._scene.activeCamera?.renderPassId ?? this._currentTarget.renderPassId;\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if the currently rendered prePassRenderTarget is the one\r\n * associated with the scene.\r\n */\r\n public get currentRTisSceneRT(): boolean {\r\n return this._currentTarget === this.defaultRT;\r\n }\r\n\r\n private _geometryBuffer: Nullable<GeometryBufferRenderer>;\r\n\r\n /**\r\n * Prevents the PrePassRenderer from using the GeometryBufferRenderer as a fallback\r\n */\r\n public doNotUseGeometryRendererFallback = true;\r\n\r\n private _refreshGeometryBufferRendererLink() {\r\n if (!this.doNotUseGeometryRendererFallback) {\r\n this._geometryBuffer = this._scene.enableGeometryBufferRenderer();\r\n\r\n if (!this._geometryBuffer) {\r\n // Not supported\r\n this.doNotUseGeometryRendererFallback = true;\r\n return;\r\n }\r\n\r\n this._geometryBuffer._linkPrePassRenderer(this);\r\n } else {\r\n if (this._geometryBuffer) {\r\n this._geometryBuffer._unlinkPrePassRenderer();\r\n }\r\n this._geometryBuffer = null;\r\n this._scene.disableGeometryBufferRenderer();\r\n }\r\n }\r\n\r\n private _currentTarget: PrePassRenderTarget;\r\n\r\n /**\r\n * All the render targets generated by prepass\r\n */\r\n public renderTargets: PrePassRenderTarget[] = [];\r\n\r\n private readonly _clearColor = new Color4(0, 0, 0, 0);\r\n private readonly _clearDepthColor = new Color4(1e8, 0, 0, 1); // \"infinity\" value - depth in the depth texture is view.z, not a 0..1 value!\r\n\r\n private _enabled: boolean = false;\r\n\r\n private _needsCompositionForThisPass = false;\r\n private _postProcessesSourceForThisPass: Nullable<PostProcess>[];\r\n\r\n /**\r\n * Indicates if the prepass is enabled\r\n */\r\n public get enabled() {\r\n return this._enabled;\r\n }\r\n\r\n /**\r\n * Set to true to disable gamma transform in PrePass.\r\n * Can be useful in case you already proceed to gamma transform on a material level\r\n * and your post processes don't need to be in linear color space.\r\n */\r\n public disableGammaTransform = false;\r\n\r\n /**\r\n * Instantiates a prepass renderer\r\n * @param scene The scene\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n\r\n let type = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (this._engine._caps.textureFloat && this._engine._caps.textureFloatLinearFiltering) {\r\n type = Constants.TEXTURETYPE_FLOAT;\r\n } else if (this._engine._caps.textureHalfFloat && this._engine._caps.textureHalfFloatLinearFiltering) {\r\n type = Constants.TEXTURETYPE_HALF_FLOAT;\r\n }\r\n\r\n if (type !== Constants.TEXTURETYPE_FLOAT) {\r\n for (let i = 0; i < PrePassRenderer.TextureFormats.length; ++i) {\r\n if (PrePassRenderer.TextureFormats[i].type === Constants.TEXTURETYPE_FLOAT) {\r\n PrePassRenderer.TextureFormats[Constants.PREPASS_DEPTH_TEXTURE_TYPE].type = type;\r\n }\r\n }\r\n }\r\n\r\n PrePassRenderer._SceneComponentInitialization(this._scene);\r\n this.defaultRT = this._createRenderTarget(\"sceneprePassRT\", null);\r\n this._currentTarget = this.defaultRT;\r\n }\r\n\r\n /**\r\n * Creates a new PrePassRenderTarget\r\n * This should be the only way to instantiate a `PrePassRenderTarget`\r\n * @param name Name of the `PrePassRenderTarget`\r\n * @param renderTargetTexture RenderTarget the `PrePassRenderTarget` will be attached to.\r\n * Can be `null` if the created `PrePassRenderTarget` is attached to the scene (default framebuffer).\r\n * @internal\r\n */\r\n public _createRenderTarget(name: string, renderTargetTexture: Nullable<RenderTargetTexture>): PrePassRenderTarget {\r\n const rt = new PrePassRenderTarget(name, renderTargetTexture, { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() }, 0, this._scene, {\r\n generateMipMaps: false,\r\n generateStencilBuffer: this._engine.isStencilEnable,\r\n defaultType: Constants.TEXTURETYPE_UNSIGNED_INT,\r\n types: [],\r\n drawOnlyOnFirstAttachmentByDefault: true,\r\n });\r\n\r\n this.renderTargets.push(rt);\r\n\r\n if (this._enabled) {\r\n // The pre-pass renderer is already enabled, so make sure we create the render target with the correct number of textures\r\n this._update();\r\n }\r\n\r\n return rt;\r\n }\r\n\r\n /**\r\n * Indicates if rendering a prepass is supported\r\n */\r\n public get isSupported() {\r\n return this._scene.getEngine().getCaps().drawBuffersExtension;\r\n }\r\n\r\n /**\r\n * Sets the proper output textures to draw in the engine.\r\n * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.\r\n * @param subMesh Submesh on which the effect is applied\r\n */\r\n public bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh) {\r\n const material = subMesh.getMaterial();\r\n const isPrePassCapable = material && material.isPrePassCapable;\r\n const excluded = material && this.excludedMaterials.indexOf(material) !== -1;\r\n\r\n if (this.enabled && this._currentTarget.enabled) {\r\n if (effect._multiTarget && isPrePassCapable && !excluded) {\r\n this._engine.bindAttachments(this._multiRenderAttachments);\r\n } else {\r\n if (this._engine._currentRenderTarget) {\r\n this._engine.bindAttachments(this._defaultAttachments);\r\n } else {\r\n this._engine.restoreSingleAttachment();\r\n }\r\n\r\n if (this._geometryBuffer && this.currentRTisSceneRT && !excluded) {\r\n this._geometryBuffer.renderList!.push(subMesh.getRenderingMesh());\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _reinitializeAttachments() {\r\n const multiRenderLayout = [];\r\n const clearLayout = [false];\r\n const clearDepthLayout = [false];\r\n const defaultLayout = [true];\r\n\r\n for (let i = 0; i < this.mrtCount; i++) {\r\n multiRenderLayout.push(true);\r\n\r\n if (i > 0) {\r\n if (this._useSpecificClearForDepthTexture && this._mrtLayout[i] === Constants.PREPASS_DEPTH_TEXTURE_TYPE) {\r\n clearLayout.push(false);\r\n clearDepthLayout.push(true);\r\n } else {\r\n clearLayout.push(true);\r\n clearDepthLayout.push(false);\r\n }\r\n defaultLayout.push(false);\r\n }\r\n }\r\n\r\n this._multiRenderAttachments = this._engine.buildTextureLayout(multiRenderLayout);\r\n this._clearAttachments = this._engine.buildTextureLayout(clearLayout);\r\n this._clearDepthAttachments = this._engine.buildTextureLayout(clearDepthLayout);\r\n this._defaultAttachments = this._engine.buildTextureLayout(defaultLayout);\r\n }\r\n\r\n private _resetLayout() {\r\n for (let i = 0; i < PrePassRenderer.TextureFormats.length; i++) {\r\n this._textureIndices[PrePassRenderer.TextureFormats[i].purpose] = -1;\r\n }\r\n\r\n this._textureIndices[Constants.PREPASS_COLOR_TEXTURE_TYPE] = 0;\r\n this._mrtLayout = [Constants.PREPASS_COLOR_TEXTURE_TYPE];\r\n this._mrtTypes = [PrePassRenderer.TextureFormats[Constants.PREPASS_COLOR_TEXTURE_TYPE].type];\r\n this._mrtFormats = [PrePassRenderer.TextureFormats[Constants.PREPASS_COLOR_TEXTURE_TYPE].format];\r\n this._mrtNames = [PrePassRenderer.TextureFormats[Constants.PREPASS_COLOR_TEXTURE_TYPE].name];\r\n this.mrtCount = 1;\r\n }\r\n\r\n private _updateGeometryBufferLayout() {\r\n this._refreshGeometryBufferRendererLink();\r\n\r\n if (this._geometryBuffer) {\r\n this._geometryBuffer._resetLayout();\r\n\r\n const texturesActivated = [];\r\n\r\n for (let i = 0; i < this._mrtLayout.length; i++) {\r\n texturesActivated.push(false);\r\n }\r\n\r\n this._geometryBuffer._linkInternalTexture(this.defaultRT.getInternalTexture()!);\r\n\r\n const matches = [\r\n {\r\n prePassConstant: Constants.PREPASS_DEPTH_TEXTURE_TYPE,\r\n geometryBufferConstant: GeometryBufferRenderer.DEPTH_TEXTURE_TYPE,\r\n },\r\n {\r\n prePassConstant: Constants.PREPASS_NORMAL_TEXTURE_TYPE,\r\n geometryBufferConstant: GeometryBufferRenderer.NORMAL_TEXTURE_TYPE,\r\n },\r\n {\r\n prePassConstant: Constants.PREPASS_POSITION_TEXTURE_TYPE,\r\n geometryBufferConstant: GeometryBufferRenderer.POSITION_TEXTURE_TYPE,\r\n },\r\n {\r\n prePassConstant: Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE,\r\n geometryBufferConstant: GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE,\r\n },\r\n {\r\n prePassConstant: Constants.PREPASS_VELOCITY_TEXTURE_TYPE,\r\n geometryBufferConstant: GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE,\r\n },\r\n ];\r\n\r\n // replace textures in the geometryBuffer RT\r\n for (let i = 0; i < matches.length; i++) {\r\n const index = this._mrtLayout.indexOf(matches[i].prePassConstant);\r\n if (index !== -1) {\r\n this._geometryBuffer._forceTextureType(matches[i].geometryBufferConstant, index);\r\n texturesActivated[index] = true;\r\n }\r\n }\r\n\r\n this._geometryBuffer._setAttachments(this._engine.buildTextureLayout(texturesActivated));\r\n }\r\n }\r\n\r\n /**\r\n * Restores attachments for single texture draw.\r\n */\r\n public restoreAttachments() {\r\n if (this.enabled && this._currentTarget.enabled && this._defaultAttachments) {\r\n if (this._engine._currentRenderTarget) {\r\n this._engine.bindAttachments(this._defaultAttachments);\r\n } else {\r\n this._engine.restoreSingleAttachment();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public _beforeDraw(camera?: Camera, faceIndex?: number, layer?: number) {\r\n // const previousEnabled = this._enabled && this._currentTarget.enabled;\r\n\r\n if (this._isDirty) {\r\n this._update();\r\n }\r\n\r\n if (!this._enabled || !this._currentTarget.enabled) {\r\n return;\r\n }\r\n\r\n if (this._geometryBuffer) {\r\n this._geometryBuffer.renderList = [];\r\n }\r\n\r\n this._setupOutputForThisPass(this._currentTarget, camera);\r\n }\r\n\r\n private _prepareFrame(prePassRenderTarget: PrePassRenderTarget, faceIndex?: number, layer?: number) {\r\n if (prePassRenderTarget.renderTargetTexture) {\r\n prePassRenderTarget.renderTargetTexture._prepareFrame(this._scene, faceIndex, layer, prePassRenderTarget.renderTargetTexture.useCameraPostProcesses);\r\n } else if (this._postProcessesSourceForThisPass.length) {\r\n this._scene.postProcessManager._prepareFrame();\r\n } else {\r\n this._engine.restoreDefaultFramebuffer();\r\n }\r\n }\r\n\r\n /**\r\n * Sets an intermediary texture between prepass and postprocesses. This texture\r\n * will be used as input for post processes\r\n * @param rt\r\n * @returns true if there are postprocesses that will use this texture,\r\n * false if there is no postprocesses - and the function has no effect\r\n */\r\n public setCustomOutput(rt: RenderTargetTexture) {\r\n const firstPP = this._postProcessesSourceForThisPass[0];\r\n if (!firstPP) {\r\n return false;\r\n }\r\n\r\n firstPP.inputTexture = rt.renderTarget!;\r\n\r\n return true;\r\n }\r\n\r\n private _renderPostProcesses(prePassRenderTarget: PrePassRenderTarget, faceIndex?: number) {\r\n const firstPP = this._postProcessesSourceForThisPass[0];\r\n const outputTexture = firstPP ? firstPP.inputTexture : prePassRenderTarget.renderTargetTexture ? prePassRenderTarget.renderTargetTexture.renderTarget : null;\r\n\r\n // Build post process chain for this prepass post draw\r\n let postProcessChain = this._currentTarget._beforeCompositionPostProcesses;\r\n\r\n if (this._needsCompositionForThisPass) {\r\n postProcessChain = postProcessChain.concat([this._currentTarget.imageProcessingPostProcess]);\r\n }\r\n\r\n // Activates and renders the chain\r\n if (postProcessChain.length) {\r\n this._scene.postProcessManager._prepareFrame(this._currentTarget.renderTarget?.texture, postProcessChain);\r\n this._scene.postProcessManager.directRender(postProcessChain, outputTexture, false, faceIndex);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _afterDraw(faceIndex?: number, layer?: number) {\r\n if (this._enabled && this._currentTarget.enabled) {\r\n this._prepareFrame(this._currentTarget, faceIndex, layer);\r\n this._renderPostProcesses(this._currentTarget, faceIndex);\r\n }\r\n }\r\n\r\n /**\r\n * Clears the current prepass render target (in the sense of settings pixels to the scene clear color value)\r\n * @internal\r\n */\r\n public _clear() {\r\n if (this._enabled && this._currentTarget.enabled) {\r\n this._bindFrameBuffer();\r\n\r\n // Clearing other attachment with 0 on all other attachments\r\n this._engine.bindAttachments(this._clearAttachments);\r\n this._engine.clear(this._clearColor, true, false, false);\r\n if (this._useSpecificClearForDepthTexture) {\r\n this._engine.bindAttachments(this._clearDepthAttachments);\r\n this._engine.clear(this._clearDepthColor, true, false, false);\r\n }\r\n // Regular clear color with the scene clear color of the 1st attachment\r\n this._engine.bindAttachments(this._defaultAttachments);\r\n }\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _bindFrameBuffer() {\r\n if (this._enabled && this._currentTarget.enabled) {\r\n this._currentTarget._checkSize();\r\n const internalTexture = this._currentTarget.renderTarget;\r\n if (internalTexture) {\r\n this._engine.bindFramebuffer(internalTexture);\r\n }\r\n }\r\n }\r\n\r\n private _setEnabled(enabled: boolean) {\r\n this._enabled = enabled;\r\n }\r\n\r\n private _setRenderTargetEnabled(prePassRenderTarget: PrePassRenderTarget, enabled: boolean) {\r\n prePassRenderTarget.enabled = enabled;\r\n if (!enabled) {\r\n this._unlinkInternalTexture(prePassRenderTarget);\r\n }\r\n }\r\n\r\n /**\r\n * Adds an effect configuration to the prepass render target.\r\n * If an effect has already been added, it won't add it twice and will return the configuration\r\n * already present.\r\n * @param cfg the effect configuration\r\n * @returns the effect configuration now used by the prepass\r\n */\r\n public addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration {\r\n // Do not add twice\r\n for (let i = 0; i < this._effectConfigurations.length; i++) {\r\n if (this._effectConfigurations[i].name === cfg.name) {\r\n return this._effectConfigurations[i];\r\n }\r\n }\r\n\r\n this._effectConfigurations.push(cfg);\r\n return cfg;\r\n }\r\n\r\n /**\r\n * Retrieves an effect configuration by name\r\n * @param name\r\n * @returns the effect configuration, or null if not present\r\n */\r\n public getEffectConfiguration(name: string): Nullable<PrePassEffectConfiguration> {\r\n for (let i = 0; i < this._effectConfigurations.length; i++) {\r\n if (this._effectConfigurations[i].name === name) {\r\n return this._effectConfigurations[i];\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n private _enable() {\r\n const previousMrtCount = this.mrtCount;\r\n\r\n for (let i = 0; i < this._effectConfigurations.length; i++) {\r\n if (this._effectConfigurations[i].enabled) {\r\n this._enableTextures(this._effectConfigurations[i].texturesRequired);\r\n }\r\n }\r\n\r\n for (let i = 0; i < this.renderTargets.length; i++) {\r\n if (this.mrtCount !== previousMrtCount || this.renderTargets[i].count !== this.mrtCount) {\r\n this.renderTargets[i].updateCount(this.mrtCount, { types: this._mrtTypes, formats: this._mrtFormats }, this._mrtNames.concat(\"prePass_DepthBuffer\"));\r\n }\r\n\r\n this.renderTargets[i]._resetPostProcessChain();\r\n\r\n for (let j = 0; j < this._effectConfigurations.length; j++) {\r\n if (this._effectConfigurations[j].enabled) {\r\n // TODO : subsurface scattering has 1 scene-wide effect configuration\r\n // solution : do not stock postProcess on effectConfiguration, but in the prepassRenderTarget (hashmap configuration => postProcess)\r\n // And call createPostProcess whenever the post process does not exist in the RT\r\n if (!this._effectConfigurations[j].postProcess && this._effectConfigurations[j].createPostProcess) {\r\n this._effectConfigurations[j].createPostProcess!();\r\n }\r\n\r\n if (this._effectConfigurations[j].postProcess) {\r\n this.renderTargets[i]._beforeCompositionPostProcesses.push(this._effectConfigurations[j].postProcess!);\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._reinitializeAttachments();\r\n this._setEnabled(true);\r\n this._updateGeometryBufferLayout();\r\n }\r\n\r\n private _disable() {\r\n this._setEnabled(false);\r\n\r\n for (let i = 0; i < this.renderTargets.length; i++) {\r\n this._setRenderTargetEnabled(this.renderTargets[i], false);\r\n }\r\n\r\n this._resetLayout();\r\n\r\n for (let i = 0; i < this._effectConfigurations.length; i++) {\r\n this._effectConfigurations[i].enabled = false;\r\n }\r\n }\r\n\r\n private _getPostProcessesSource(prePassRenderTarget: PrePassRenderTarget, camera?: Camera): Nullable<PostProcess>[] {\r\n if (camera) {\r\n return camera._postProcesses;\r\n } else if (prePassRenderTarget.renderTargetTexture) {\r\n if (prePassRenderTarget.renderTargetTexture.useCameraPostProcesses) {\r\n const camera = prePassRenderTarget.renderTargetTexture.activeCamera ? prePassRenderTarget.renderTargetTexture.activeCamera : this._scene.activeCamera;\r\n return camera ? camera._postProcesses : [];\r\n } else if (prePassRenderTarget.renderTargetTexture.postProcesses) {\r\n return prePassRenderTarget.renderTargetTexture.postProcesses;\r\n } else {\r\n return [];\r\n }\r\n } else {\r\n return this._scene.activeCamera ? this._scene.activeCamera._postProcesses : [];\r\n }\r\n }\r\n\r\n private _setupOutputForThisPass(prePassRenderTarget: PrePassRenderTarget, camera?: Camera) {\r\n // Order is : draw ===> prePassRenderTarget._postProcesses ==> ipp ==> camera._postProcesses\r\n const secondaryCamera = camera && this._scene.activeCameras && !!this._scene.activeCameras.length && this._scene.activeCameras.indexOf(camera) !== 0;\r\n this._postProcessesSourceForThisPass = this._getPostProcessesSource(prePassRenderTarget, camera);\r\n this._postProcessesSourceForThisPass = this._postProcessesSourceForThisPass.filter((pp) => {\r\n return pp != null;\r\n });\r\n this._scene.autoClear = true;\r\n\r\n const cameraHasImageProcessing = this._hasImageProcessing(this._postProcessesSourceForThisPass);\r\n this._needsCompositionForThisPass = !cameraHasImageProcessing && !this.disableGammaTransform && this._needsImageProcessing() && !secondaryCamera;\r\n\r\n const firstCameraPP = this._getFirstPostProcess(this._postProcessesSourceForThisPass);\r\n const firstPrePassPP = prePassRenderTarget._beforeCompositionPostProcesses && prePassRenderTarget._beforeCompositionPostProcesses[0];\r\n let firstPP = null;\r\n\r\n // Setting the scene-wide post process configuration\r\n this._scene.imageProcessingConfiguration.applyByPostProcess = this._needsCompositionForThisPass || cameraHasImageProcessing;\r\n\r\n // Create composition effect if needed\r\n if (this._needsCompositionForThisPass && !prePassRenderTarget.imageProcessingPostProcess) {\r\n prePassRenderTarget._createCompositionEffect();\r\n }\r\n\r\n // Setting the prePassRenderTarget as input texture of the first PP\r\n if (firstPrePassPP) {\r\n firstPP = firstPrePassPP;\r\n } else if (this._needsCompositionForThisPass) {\r\n firstPP = prePassRenderTarget.imageProcessingPostProcess;\r\n } else if (firstCameraPP) {\r\n firstPP = firstCameraPP;\r\n }\r\n\r\n this._bindFrameBuffer();\r\n this._linkInternalTexture(prePassRenderTarget, firstPP);\r\n }\r\n\r\n private _linkInternalTexture(prePassRenderTarget: PrePassRenderTarget, postProcess: Nullable<PostProcess>) {\r\n if (postProcess) {\r\n postProcess.autoClear = false;\r\n postProcess.inputTexture = prePassRenderTarget.renderTarget!;\r\n }\r\n\r\n if (prePassRenderTarget._outputPostProcess !== postProcess) {\r\n if (prePassRenderTarget._outputPostProcess) {\r\n this._unlinkInternalTexture(prePassRenderTarget);\r\n }\r\n prePassRenderTarget._outputPostProcess = postProcess;\r\n }\r\n\r\n if (prePassRenderTarget._internalTextureDirty) {\r\n this._updateGeometryBufferLayout();\r\n prePassRenderTarget._internalTextureDirty = false;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _unlinkInternalTexture(prePassRenderTarget: PrePassRenderTarget) {\r\n if (prePassRenderTarget._outputPostProcess) {\r\n prePassRenderTarget._outputPostProcess.autoClear = true;\r\n prePassRenderTarget._outputPostProcess.restoreDefaultInputTexture();\r\n prePassRenderTarget._outputPostProcess = null;\r\n }\r\n }\r\n\r\n private _needsImageProcessing(): boolean {\r\n for (let i = 0; i < this._effectConfigurations.length; i++) {\r\n if (this._effectConfigurations[i].enabled && this._effectConfigurations[i].needsImageProcessing) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n private _hasImageProcessing(postProcesses: Nullable<PostProcess>[]): boolean {\r\n let isIPPAlreadyPresent = false;\r\n if (postProcesses) {\r\n for (let i = 0; i < postProcesses.length; i++) {\r\n if (postProcesses[i]?.getClassName() === \"ImageProcessingPostProcess\") {\r\n isIPPAlreadyPresent = true;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return isIPPAlreadyPresent;\r\n }\r\n\r\n /**\r\n * Internal, gets the first post proces.\r\n * @param postProcesses\r\n * @returns the first post process to be run on this camera.\r\n */\r\n private _getFirstPostProcess(postProcesses: Nullable<PostProcess>[]): Nullable<PostProcess> {\r\n for (let ppIndex = 0; ppIndex < postProcesses.length; ppIndex++) {\r\n if (postProcesses[ppIndex] !== null) {\r\n return postProcesses[ppIndex];\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.\r\n */\r\n public markAsDirty() {\r\n this._isDirty = true;\r\n }\r\n\r\n /**\r\n * Enables a texture on the MultiRenderTarget for prepass\r\n * @param types\r\n */\r\n private _enableTextures(types: number[]) {\r\n // For velocity : enable storage of previous matrices for instances\r\n this._scene.needsPreviousWorldMatrices = false;\r\n\r\n for (let i = 0; i < types.length; i++) {\r\n const type = types[i];\r\n\r\n if (this._textureIndices[type] === -1) {\r\n this._textureIndices[type] = this._mrtLayout.length;\r\n this._mrtLayout.push(type);\r\n\r\n this._mrtTypes.push(PrePassRenderer.TextureFormats[type].type);\r\n this._mrtFormats.push(PrePassRenderer.TextureFormats[type].format);\r\n this._mrtNames.push(PrePassRenderer.TextureFormats[type].name);\r\n this.mrtCount++;\r\n }\r\n\r\n if (type === Constants.PREPASS_VELOCITY_TEXTURE_TYPE) {\r\n this._scene.needsPreviousWorldMatrices = true;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Makes sure that the prepass renderer is up to date if it has been dirtified.\r\n */\r\n public update() {\r\n if (this._isDirty) {\r\n this._update();\r\n }\r\n }\r\n\r\n private _update() {\r\n this._disable();\r\n let enablePrePass = false;\r\n this._scene.imageProcessingConfiguration.applyByPostProcess = false;\r\n\r\n if (this._scene._depthPeelingRenderer && this._scene.useOrderIndependentTransparency) {\r\n this._scene._depthPeelingRenderer.setPrePassRenderer(this);\r\n enablePrePass = true;\r\n }\r\n\r\n for (let i = 0; i < this._scene.materials.length; i++) {\r\n if (this._scene.materials[i].setPrePassRenderer(this)) {\r\n enablePrePass = true;\r\n }\r\n }\r\n\r\n if (enablePrePass) {\r\n this._setRenderTargetEnabled(this.defaultRT, true);\r\n }\r\n\r\n let postProcesses;\r\n\r\n for (let i = 0; i < this.renderTargets.length; i++) {\r\n if (this.renderTargets[i].renderTargetTexture) {\r\n postProcesses = this._getPostProcessesSource(this.renderTargets[i]);\r\n } else {\r\n const camera = this._scene.activeCamera;\r\n if (!camera) {\r\n continue;\r\n }\r\n\r\n postProcesses = camera._postProcesses;\r\n }\r\n\r\n if (!postProcesses) {\r\n continue;\r\n }\r\n\r\n postProcesses = <Nullable<PostProcess[]>>postProcesses.filter((pp) => {\r\n return pp != null;\r\n });\r\n\r\n if (postProcesses) {\r\n for (let j = 0; j < postProcesses.length; j++) {\r\n if (postProcesses[j].setPrePassRenderer(this)) {\r\n this._setRenderTargetEnabled(this.renderTargets[i], true);\r\n enablePrePass = true;\r\n }\r\n }\r\n\r\n if (this._hasImageProcessing(postProcesses)) {\r\n this._scene.imageProcessingConfiguration.applyByPostProcess = true;\r\n }\r\n }\r\n }\r\n\r\n this._markAllMaterialsAsPrePassDirty();\r\n this._isDirty = false;\r\n\r\n if (enablePrePass) {\r\n this._enable();\r\n }\r\n }\r\n\r\n private _markAllMaterialsAsPrePassDirty() {\r\n const materials = this._scene.materials;\r\n\r\n for (let i = 0; i < materials.length; i++) {\r\n materials[i].markAsDirty(Material.PrePassDirtyFlag);\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the prepass renderer.\r\n */\r\n public dispose() {\r\n for (let i = this.renderTargets.length - 1; i >= 0; i--) {\r\n this.renderTargets[i].dispose();\r\n }\r\n\r\n for (let i = 0; i < this._effectConfigurations.length; i++) {\r\n if (this._effectConfigurations[i].dispose) {\r\n this._effectConfigurations[i].dispose!();\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -329,8 +329,12 @@ gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
329
329
  gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
330
330
  #endif
331
331
  #ifdef PREPASS_NORMAL
332
+ #ifdef PREPASS_NORMAL_WORLDSPACE
333
+ gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo);
334
+ #else
332
335
  gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo);
333
336
  #endif
337
+ #endif
334
338
  #ifdef PREPASS_ALBEDO_SQRT
335
339
  gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
336
340
  #endif
@@ -1 +1 @@
1
- {"version":3,"file":"default.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/default.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,6CAA6C,CAAC;AACrD,OAAO,wCAAwC,CAAC;AAChD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,iCAAiC,CAAC;AACzC,OAAO,2CAA2C,CAAC;AACnD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,2CAA2C,CAAC;AACnD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,0CAA0C,CAAC;AAClD,OAAO,2CAA2C,CAAC;AACnD,OAAO,6CAA6C,CAAC;AACrD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,6CAA6C,CAAC;AACrD,OAAO,2CAA2C,CAAC;AACnD,OAAO,4CAA4C,CAAC;AACpD,OAAO,wCAAwC,CAAC;AAChD,OAAO,+CAA+C,CAAC;AACvD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,yCAAyC,CAAC;AACjD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,+BAA+B,CAAC;AACvC,OAAO,gCAAgC,CAAC;AACxC,OAAO,+BAA+B,CAAC;AACvC,OAAO,gCAAgC,CAAC;AACxC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,8BAA8B,CAAC;AACtC,OAAO,8BAA8B,CAAC;AAEtC,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsUd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/defaultFragmentDeclaration\";\nimport \"./ShadersInclude/defaultUboDeclaration\";\nimport \"./ShadersInclude/prePassDeclaration\";\nimport \"./ShadersInclude/oitDeclaration\";\nimport \"./ShadersInclude/mainUVVaryingDeclaration\";\nimport \"./ShadersInclude/helperFunctions\";\nimport \"./ShadersInclude/lightFragmentDeclaration\";\nimport \"./ShadersInclude/lightUboDeclaration\";\nimport \"./ShadersInclude/lightsFragmentFunctions\";\nimport \"./ShadersInclude/shadowsFragmentFunctions\";\nimport \"./ShadersInclude/samplerFragmentDeclaration\";\nimport \"./ShadersInclude/fresnelFunction\";\nimport \"./ShadersInclude/reflectionFunction\";\nimport \"./ShadersInclude/imageProcessingDeclaration\";\nimport \"./ShadersInclude/imageProcessingFunctions\";\nimport \"./ShadersInclude/bumpFragmentMainFunctions\";\nimport \"./ShadersInclude/bumpFragmentFunctions\";\nimport \"./ShadersInclude/clipPlaneFragmentDeclaration\";\nimport \"./ShadersInclude/logDepthDeclaration\";\nimport \"./ShadersInclude/fogFragmentDeclaration\";\nimport \"./ShadersInclude/clipPlaneFragment\";\nimport \"./ShadersInclude/bumpFragment\";\nimport \"./ShadersInclude/decalFragment\";\nimport \"./ShadersInclude/depthPrePass\";\nimport \"./ShadersInclude/lightFragment\";\nimport \"./ShadersInclude/logDepthFragment\";\nimport \"./ShadersInclude/fogFragment\";\nimport \"./ShadersInclude/oitFragment\";\n\nconst name = \"defaultPixelShader\";\nconst shader = `#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#include<prePassDeclaration>[SCENE_MRT_COUNT]\n#include<oitDeclaration>\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#define RECIPROCAL_PI2 0.15915494\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#include<mainUVVaryingDeclaration>[1..7]\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULARTERM)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)\n#endif\n#include<fresnelFunction>\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#if defined(DECAL) && !defined(DECAL_AFTER_DETAIL)\nvec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);\n#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)\n#endif\n#include<depthPrePass>\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef DETAIL\nbaseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);\n#endif\n#if defined(DECAL) && defined(DECAL_AFTER_DETAIL)\nvec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);\n#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;vec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);specularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;float aggShadow=0.;float numLights=0.;\n#ifdef LIGHTMAP\nvec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);\n#ifdef RGBDLIGHTMAP\nlightmapColor.rgb=fromRGBD(lightmapColor);\n#endif\nlightmapColor.rgb*=vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\naggShadow=aggShadow/numLights;vec4 refractionColor=vec4(0.,0.,0.,1.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\n#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC\nrefractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition);\n#endif\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;vec4 refractionLookup=textureCube(refractionCubeSampler,refractionVector);if (dot(refractionVector,viewDirectionW)<1.0) {refractionColor=refractionLookup;}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;refractionColor=texture2D(refraction2DSampler,refractionCoords);\n#endif\n#ifdef RGBDREFRACTION\nrefractionColor.rgb=fromRGBD(refractionColor);\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor.rgb=toGammaSpace(refractionColor.rgb);\n#endif\nrefractionColor.rgb*=vRefractionInfos.x;\n#endif\nvec4 reflectionColor=vec4(0.,0.,0.,1.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nvReflectionUVW.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;reflectionColor=texture2D(reflection2DSampler,coords);\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor.rgb=toGammaSpace(reflectionColor.rgb);\n#endif\nreflectionColor.rgb*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n#ifdef ALPHATEST\n#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS\nif (alpha<alphaCutOff)\ndiscard;\n#endif\n#ifndef ALPHABLEND\nalpha=1.0;\n#endif\n#endif\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);emissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);diffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);\n#endif\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor.rgb;\n#else\ncolor.rgb+=lightmapColor.rgb;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);color=applyImageProcessing(color);\n#endif\n#endif\ncolor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\n#ifdef PREPASS\nfloat writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0;gl_FragData[0]=color; \n#ifdef PREPASS_POSITION\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);\n#endif\n#ifdef PREPASS_VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);\n#endif\n#ifdef PREPASS_IRRADIANCE\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_DEPTH\ngl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_NORMAL\ngl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo); \n#endif\n#ifdef PREPASS_ALBEDO_SQRT\ngl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_REFLECTIVITY\n#if defined(SPECULARTERM)\n#if defined(SPECULAR)\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularMapColor))*writeGeometryInfo; \n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularColor),1.0)*writeGeometryInfo;\n#endif\n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0)*writeGeometryInfo;\n#endif\n#endif\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=color;\n#endif\n#include<oitFragment>\n#if ORDER_INDEPENDENT_TRANSPARENCY\nif (fragDepth==nearestDepth) {frontColor.rgb+=color.rgb*color.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-color.a);} else {backColor+=color;}\n#endif\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const defaultPixelShader = { name, shader };\n"]}
1
+ {"version":3,"file":"default.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/default.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,6CAA6C,CAAC;AACrD,OAAO,wCAAwC,CAAC;AAChD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,iCAAiC,CAAC;AACzC,OAAO,2CAA2C,CAAC;AACnD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,2CAA2C,CAAC;AACnD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,0CAA0C,CAAC;AAClD,OAAO,2CAA2C,CAAC;AACnD,OAAO,6CAA6C,CAAC;AACrD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,6CAA6C,CAAC;AACrD,OAAO,2CAA2C,CAAC;AACnD,OAAO,4CAA4C,CAAC;AACpD,OAAO,wCAAwC,CAAC;AAChD,OAAO,+CAA+C,CAAC;AACvD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,yCAAyC,CAAC;AACjD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,+BAA+B,CAAC;AACvC,OAAO,gCAAgC,CAAC;AACxC,OAAO,+BAA+B,CAAC;AACvC,OAAO,gCAAgC,CAAC;AACxC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,8BAA8B,CAAC;AACtC,OAAO,8BAA8B,CAAC;AAEtC,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Ud,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/defaultFragmentDeclaration\";\nimport \"./ShadersInclude/defaultUboDeclaration\";\nimport \"./ShadersInclude/prePassDeclaration\";\nimport \"./ShadersInclude/oitDeclaration\";\nimport \"./ShadersInclude/mainUVVaryingDeclaration\";\nimport \"./ShadersInclude/helperFunctions\";\nimport \"./ShadersInclude/lightFragmentDeclaration\";\nimport \"./ShadersInclude/lightUboDeclaration\";\nimport \"./ShadersInclude/lightsFragmentFunctions\";\nimport \"./ShadersInclude/shadowsFragmentFunctions\";\nimport \"./ShadersInclude/samplerFragmentDeclaration\";\nimport \"./ShadersInclude/fresnelFunction\";\nimport \"./ShadersInclude/reflectionFunction\";\nimport \"./ShadersInclude/imageProcessingDeclaration\";\nimport \"./ShadersInclude/imageProcessingFunctions\";\nimport \"./ShadersInclude/bumpFragmentMainFunctions\";\nimport \"./ShadersInclude/bumpFragmentFunctions\";\nimport \"./ShadersInclude/clipPlaneFragmentDeclaration\";\nimport \"./ShadersInclude/logDepthDeclaration\";\nimport \"./ShadersInclude/fogFragmentDeclaration\";\nimport \"./ShadersInclude/clipPlaneFragment\";\nimport \"./ShadersInclude/bumpFragment\";\nimport \"./ShadersInclude/decalFragment\";\nimport \"./ShadersInclude/depthPrePass\";\nimport \"./ShadersInclude/lightFragment\";\nimport \"./ShadersInclude/logDepthFragment\";\nimport \"./ShadersInclude/fogFragment\";\nimport \"./ShadersInclude/oitFragment\";\n\nconst name = \"defaultPixelShader\";\nconst shader = `#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#include<prePassDeclaration>[SCENE_MRT_COUNT]\n#include<oitDeclaration>\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#define RECIPROCAL_PI2 0.15915494\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#include<mainUVVaryingDeclaration>[1..7]\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULARTERM)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)\n#endif\n#include<fresnelFunction>\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#if defined(DECAL) && !defined(DECAL_AFTER_DETAIL)\nvec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);\n#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)\n#endif\n#include<depthPrePass>\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef DETAIL\nbaseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);\n#endif\n#if defined(DECAL) && defined(DECAL_AFTER_DETAIL)\nvec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);\n#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;vec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);specularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;float aggShadow=0.;float numLights=0.;\n#ifdef LIGHTMAP\nvec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);\n#ifdef RGBDLIGHTMAP\nlightmapColor.rgb=fromRGBD(lightmapColor);\n#endif\nlightmapColor.rgb*=vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\naggShadow=aggShadow/numLights;vec4 refractionColor=vec4(0.,0.,0.,1.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\n#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC\nrefractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition);\n#endif\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;vec4 refractionLookup=textureCube(refractionCubeSampler,refractionVector);if (dot(refractionVector,viewDirectionW)<1.0) {refractionColor=refractionLookup;}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;refractionColor=texture2D(refraction2DSampler,refractionCoords);\n#endif\n#ifdef RGBDREFRACTION\nrefractionColor.rgb=fromRGBD(refractionColor);\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor.rgb=toGammaSpace(refractionColor.rgb);\n#endif\nrefractionColor.rgb*=vRefractionInfos.x;\n#endif\nvec4 reflectionColor=vec4(0.,0.,0.,1.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nvReflectionUVW.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;reflectionColor=texture2D(reflection2DSampler,coords);\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor.rgb=toGammaSpace(reflectionColor.rgb);\n#endif\nreflectionColor.rgb*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n#ifdef ALPHATEST\n#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS\nif (alpha<alphaCutOff)\ndiscard;\n#endif\n#ifndef ALPHABLEND\nalpha=1.0;\n#endif\n#endif\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);emissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);diffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);\n#endif\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor.rgb;\n#else\ncolor.rgb+=lightmapColor.rgb;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);color=applyImageProcessing(color);\n#endif\n#endif\ncolor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\n#ifdef PREPASS\nfloat writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0;gl_FragData[0]=color; \n#ifdef PREPASS_POSITION\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);\n#endif\n#ifdef PREPASS_VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);\n#endif\n#ifdef PREPASS_IRRADIANCE\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_DEPTH\ngl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_NORMAL\n#ifdef PREPASS_NORMAL_WORLDSPACE\ngl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo); \n#else\ngl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo); \n#endif\n#endif\n#ifdef PREPASS_ALBEDO_SQRT\ngl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_REFLECTIVITY\n#if defined(SPECULARTERM)\n#if defined(SPECULAR)\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularMapColor))*writeGeometryInfo; \n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularColor),1.0)*writeGeometryInfo;\n#endif\n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0)*writeGeometryInfo;\n#endif\n#endif\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=color;\n#endif\n#include<oitFragment>\n#if ORDER_INDEPENDENT_TRANSPARENCY\nif (fragDepth==nearestDepth) {frontColor.rgb+=color.rgb*color.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-color.a);} else {backColor+=color;}\n#endif\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const defaultPixelShader = { name, shader };\n"]}
@@ -0,0 +1,5 @@
1
+ /** @internal */
2
+ export declare const equirectangularPanoramaPixelShader: {
3
+ name: string;
4
+ shader: string;
5
+ };