super-three 0.164.0 → 0.167.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 (416) hide show
  1. package/README.md +3 -3
  2. package/build/three.cjs +1273 -503
  3. package/build/three.module.js +1269 -504
  4. package/build/three.module.min.js +1 -1
  5. package/build/three.webgpu.js +76086 -0
  6. package/build/three.webgpu.min.js +6 -0
  7. package/examples/jsm/Addons.js +2 -1
  8. package/examples/jsm/controls/TransformControls.js +1 -1
  9. package/examples/jsm/csm/CSMShader.js +4 -4
  10. package/examples/jsm/environments/RoomEnvironment.js +1 -5
  11. package/examples/jsm/exporters/GLTFExporter.js +8 -4
  12. package/examples/jsm/exporters/USDZExporter.js +6 -4
  13. package/examples/jsm/geometries/TeapotGeometry.js +1 -1
  14. package/examples/jsm/helpers/ViewHelper.js +75 -61
  15. package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
  16. package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
  17. package/examples/jsm/lines/LineMaterial.js +1 -15
  18. package/examples/jsm/lines/LineSegments2.js +15 -0
  19. package/examples/jsm/lines/Wireframe.js +16 -1
  20. package/examples/jsm/lines/webgpu/Line2.js +20 -0
  21. package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
  22. package/examples/jsm/loaders/DRACOLoader.js +1 -1
  23. package/examples/jsm/loaders/FBXLoader.js +47 -58
  24. package/examples/jsm/loaders/GLTFLoader.js +12 -4
  25. package/examples/jsm/loaders/LDrawLoader.js +3 -2
  26. package/examples/jsm/loaders/MMDLoader.js +31 -12
  27. package/examples/jsm/loaders/MaterialXLoader.js +2 -9
  28. package/examples/jsm/loaders/USDZLoader.js +124 -76
  29. package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
  30. package/examples/jsm/loaders/VTKLoader.js +76 -3
  31. package/examples/jsm/misc/GPUComputationRenderer.js +9 -19
  32. package/examples/jsm/modifiers/CurveModifier.js +11 -9
  33. package/examples/jsm/modifiers/SimplifyModifier.js +2 -1
  34. package/examples/jsm/objects/InstancedPoints.js +2 -2
  35. package/examples/jsm/objects/Lensflare.js +2 -2
  36. package/examples/jsm/postprocessing/RenderPass.js +1 -1
  37. package/examples/jsm/postprocessing/RenderTransitionPass.js +13 -38
  38. package/examples/jsm/postprocessing/SSAOPass.js +6 -9
  39. package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
  40. package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
  41. package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
  42. package/examples/jsm/shaders/ColorifyShader.js +1 -2
  43. package/examples/jsm/shaders/FXAAShader.js +0 -2
  44. package/examples/jsm/shaders/GTAOShader.js +1 -1
  45. package/examples/jsm/shaders/LuminosityHighPassShader.js +1 -3
  46. package/examples/jsm/transpiler/GLSLDecoder.js +46 -4
  47. package/examples/jsm/transpiler/TSLEncoder.js +17 -15
  48. package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
  49. package/examples/jsm/utils/GPUStatsPanel.js +2 -0
  50. package/examples/jsm/utils/SortUtils.js +8 -5
  51. package/package.json +9 -7
  52. package/src/Three.WebGPU.js +194 -0
  53. package/src/Three.js +2 -0
  54. package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
  55. package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
  56. package/src/animation/tracks/StringKeyframeTrack.js +10 -1
  57. package/src/constants.js +4 -1
  58. package/src/core/Object3D.js +24 -22
  59. package/src/core/Raycaster.js +6 -2
  60. package/src/extras/TextureUtils.js +210 -0
  61. package/src/lights/Light.js +1 -0
  62. package/src/lights/LightShadow.js +5 -0
  63. package/{examples/jsm/lights → src/lights/webgpu}/IESSpotLight.js +1 -1
  64. package/src/loaders/FileLoader.js +4 -0
  65. package/src/loaders/LoaderUtils.js +3 -1
  66. package/src/loaders/ObjectLoader.js +34 -2
  67. package/src/materials/Material.js +13 -4
  68. package/src/math/Box2.js +4 -4
  69. package/src/math/Box3.js +6 -6
  70. package/src/math/ColorManagement.js +10 -0
  71. package/src/math/Matrix2.js +54 -0
  72. package/src/math/Vector4.js +13 -0
  73. package/{examples/jsm → src}/nodes/Nodes.js +39 -20
  74. package/{examples/jsm → src}/nodes/accessors/BatchNode.js +28 -10
  75. package/src/nodes/accessors/BitangentNode.js +13 -0
  76. package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +36 -1
  77. package/{examples/jsm → src}/nodes/accessors/BufferNode.js +6 -0
  78. package/src/nodes/accessors/CameraNode.js +19 -0
  79. package/{examples/jsm → src}/nodes/accessors/CubeTextureNode.js +22 -5
  80. package/src/nodes/accessors/InstanceNode.js +140 -0
  81. package/{examples/jsm → src}/nodes/accessors/MaterialNode.js +24 -2
  82. package/{examples/jsm → src}/nodes/accessors/ModelNode.js +4 -0
  83. package/{examples/jsm → src}/nodes/accessors/MorphNode.js +24 -20
  84. package/src/nodes/accessors/NormalNode.js +14 -0
  85. package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +1 -1
  86. package/src/nodes/accessors/PositionNode.js +10 -0
  87. package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +7 -1
  88. package/src/nodes/accessors/ReflectVectorNode.js +10 -0
  89. package/{examples/jsm → src}/nodes/accessors/StorageBufferNode.js +50 -1
  90. package/{examples/jsm/nodes/accessors/TextureStoreNode.js → src/nodes/accessors/StorageTextureNode.js} +28 -6
  91. package/src/nodes/accessors/TangentNode.js +23 -0
  92. package/src/nodes/accessors/Texture3DNode.js +100 -0
  93. package/{examples/jsm → src}/nodes/accessors/TextureNode.js +55 -18
  94. package/src/nodes/accessors/UVNode.js +3 -0
  95. package/{examples/jsm → src}/nodes/accessors/UniformsNode.js +7 -1
  96. package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +2 -1
  97. package/{examples/jsm → src}/nodes/code/ScriptableNode.js +14 -0
  98. package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +2 -1
  99. package/{examples/jsm → src}/nodes/core/AttributeNode.js +34 -8
  100. package/{examples/jsm → src}/nodes/core/CacheNode.js +7 -10
  101. package/{examples/jsm → src}/nodes/core/ContextNode.js +6 -0
  102. package/{examples/jsm → src}/nodes/core/IndexNode.js +6 -0
  103. package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
  104. package/src/nodes/core/MRTNode.js +76 -0
  105. package/{examples/jsm → src}/nodes/core/Node.js +33 -14
  106. package/{examples/jsm → src}/nodes/core/NodeBuilder.js +194 -45
  107. package/src/nodes/core/NodeCache.js +36 -0
  108. package/{examples/jsm → src}/nodes/core/NodeFrame.js +42 -0
  109. package/{examples/jsm → src}/nodes/core/NodeFunction.js +2 -2
  110. package/{examples/jsm → src}/nodes/core/NodeKeywords.js +1 -1
  111. package/{examples/jsm → src}/nodes/core/NodeUniform.js +1 -2
  112. package/{examples/jsm → src}/nodes/core/NodeUtils.js +6 -1
  113. package/{examples/jsm → src}/nodes/core/OutputStructNode.js +1 -5
  114. package/{examples/jsm → src}/nodes/core/PropertyNode.js +2 -0
  115. package/{examples/jsm → src}/nodes/core/TempNode.js +2 -2
  116. package/{examples/jsm → src}/nodes/core/UniformGroupNode.js +20 -0
  117. package/{examples/jsm → src}/nodes/core/UniformNode.js +10 -1
  118. package/{examples/jsm → src}/nodes/core/VarNode.js +2 -6
  119. package/src/nodes/core/VaryingNode.js +104 -0
  120. package/{examples/jsm → src}/nodes/display/AfterImageNode.js +24 -20
  121. package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +18 -21
  122. package/src/nodes/display/BloomNode.js +333 -0
  123. package/{examples/jsm → src}/nodes/display/ColorAdjustmentNode.js +7 -2
  124. package/{examples/jsm → src}/nodes/display/ColorSpaceNode.js +1 -1
  125. package/src/nodes/display/DenoiseNode.js +198 -0
  126. package/src/nodes/display/DepthOfFieldNode.js +119 -0
  127. package/src/nodes/display/DotScreenNode.js +75 -0
  128. package/src/nodes/display/FXAANode.js +327 -0
  129. package/src/nodes/display/FilmNode.js +52 -0
  130. package/{examples/jsm → src}/nodes/display/FrontFacingNode.js +2 -1
  131. package/src/nodes/display/GTAONode.js +324 -0
  132. package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +34 -17
  133. package/src/nodes/display/Lut3DNode.js +53 -0
  134. package/{examples/jsm → src}/nodes/display/NormalMapNode.js +1 -1
  135. package/src/nodes/display/PassNode.js +291 -0
  136. package/src/nodes/display/PixelationPassNode.js +201 -0
  137. package/src/nodes/display/RGBShiftNode.js +49 -0
  138. package/src/nodes/display/RenderOutputNode.js +56 -0
  139. package/src/nodes/display/SobelOperatorNode.js +121 -0
  140. package/{examples/jsm → src}/nodes/display/ToneMappingNode.js +44 -5
  141. package/src/nodes/display/TransitionNode.js +76 -0
  142. package/{examples/jsm → src}/nodes/display/ViewportDepthNode.js +39 -16
  143. package/{examples/jsm → src}/nodes/display/ViewportDepthTextureNode.js +2 -1
  144. package/{examples/jsm → src}/nodes/display/ViewportNode.js +3 -2
  145. package/{examples/jsm → src}/nodes/display/ViewportSharedTextureNode.js +2 -1
  146. package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +5 -2
  147. package/src/nodes/functions/BSDF/LTC.js +131 -0
  148. package/src/nodes/functions/BasicLightingModel.js +78 -0
  149. package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +5 -3
  150. package/{examples/jsm → src}/nodes/functions/PhysicalLightingModel.js +103 -18
  151. package/src/nodes/functions/ToonLightingModel.js +51 -0
  152. package/{examples/jsm → src}/nodes/geometry/RangeNode.js +19 -6
  153. package/{examples/jsm → src}/nodes/lighting/AONode.js +1 -4
  154. package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +1 -1
  155. package/src/nodes/lighting/AnalyticLightNode.js +333 -0
  156. package/src/nodes/lighting/BasicEnvironmentNode.js +26 -0
  157. package/src/nodes/lighting/BasicLightMapNode.js +29 -0
  158. package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +2 -3
  159. package/{examples/jsm → src}/nodes/lighting/EnvironmentNode.js +5 -4
  160. package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +2 -1
  161. package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +1 -1
  162. package/{examples/jsm → src}/nodes/lighting/LightingNode.js +2 -0
  163. package/{examples/jsm → src}/nodes/lighting/LightsNode.js +18 -3
  164. package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +2 -3
  165. package/src/nodes/lighting/RectAreaLightNode.js +97 -0
  166. package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +2 -3
  167. package/{examples/jsm → src}/nodes/loaders/NodeLoader.js +3 -1
  168. package/{examples/jsm → src}/nodes/loaders/NodeMaterialLoader.js +2 -1
  169. package/{examples/jsm → src}/nodes/loaders/NodeObjectLoader.js +2 -1
  170. package/{examples/jsm → src}/nodes/materials/InstancedPointsNodeMaterial.js +3 -3
  171. package/{examples/jsm → src}/nodes/materials/Line2NodeMaterial.js +4 -4
  172. package/{examples/jsm → src}/nodes/materials/LineBasicNodeMaterial.js +3 -3
  173. package/{examples/jsm → src}/nodes/materials/LineDashedNodeMaterial.js +4 -3
  174. package/{examples/jsm → src}/nodes/materials/Materials.js +3 -0
  175. package/src/nodes/materials/MeshBasicNodeMaterial.js +73 -0
  176. package/{examples/jsm → src}/nodes/materials/MeshLambertNodeMaterial.js +12 -3
  177. package/src/nodes/materials/MeshMatcapNodeMaterial.js +53 -0
  178. package/{examples/jsm → src}/nodes/materials/MeshNormalNodeMaterial.js +5 -3
  179. package/{examples/jsm → src}/nodes/materials/MeshPhongNodeMaterial.js +11 -3
  180. package/{examples/jsm → src}/nodes/materials/MeshPhysicalNodeMaterial.js +26 -8
  181. package/{examples/jsm → src}/nodes/materials/MeshStandardNodeMaterial.js +14 -3
  182. package/src/nodes/materials/MeshToonNodeMaterial.js +34 -0
  183. package/{examples/jsm → src}/nodes/materials/NodeMaterial.js +97 -24
  184. package/{examples/jsm → src}/nodes/materials/PointsNodeMaterial.js +3 -3
  185. package/{examples/jsm → src}/nodes/materials/ShadowNodeMaterial.js +3 -3
  186. package/{examples/jsm → src}/nodes/materials/SpriteNodeMaterial.js +3 -3
  187. package/src/nodes/materials/VolumeNodeMaterial.js +106 -0
  188. package/{examples/jsm → src}/nodes/materialx/lib/mx_hsv.js +9 -17
  189. package/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +474 -577
  190. package/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +2 -8
  191. package/{examples/jsm → src}/nodes/math/CondNode.js +13 -6
  192. package/{examples/jsm → src}/nodes/math/HashNode.js +2 -2
  193. package/{examples/jsm → src}/nodes/math/MathNode.js +14 -1
  194. package/{examples/jsm → src}/nodes/math/OperatorNode.js +6 -6
  195. package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
  196. package/{examples/jsm → src}/nodes/pmrem/PMREMNode.js +2 -1
  197. package/{examples/jsm → src}/nodes/shadernode/ShaderNode.js +57 -33
  198. package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +1 -1
  199. package/{examples/jsm → src}/nodes/utils/DiscardNode.js +1 -0
  200. package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +2 -0
  201. package/{examples/jsm → src}/nodes/utils/LoopNode.js +7 -6
  202. package/{examples/jsm → src}/nodes/utils/MatcapUVNode.js +1 -1
  203. package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +8 -2
  204. package/src/nodes/utils/RTTNode.js +130 -0
  205. package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +9 -1
  206. package/{examples/jsm → src}/nodes/utils/TimerNode.js +1 -1
  207. package/src/objects/BatchedMesh.js +232 -162
  208. package/src/objects/InstancedMesh.js +1 -1
  209. package/src/renderers/WebGLRenderer.js +312 -68
  210. package/{examples/jsm → src}/renderers/common/Attributes.js +4 -1
  211. package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
  212. package/{examples/jsm → src}/renderers/common/Background.js +9 -3
  213. package/src/renderers/common/BindGroup.js +16 -0
  214. package/{examples/jsm → src}/renderers/common/Bindings.js +54 -22
  215. package/src/renderers/common/ChainMap.js +59 -0
  216. package/{examples/jsm → src}/renderers/common/ClippingContext.js +8 -6
  217. package/{examples/jsm → src}/renderers/common/Color4.js +1 -1
  218. package/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +7 -1
  219. package/{examples/jsm → src}/renderers/common/Geometries.js +37 -5
  220. package/{examples/jsm → src}/renderers/common/Info.js +34 -6
  221. package/{examples/jsm → src}/renderers/common/Pipelines.js +2 -2
  222. package/src/renderers/common/PostProcessing.js +87 -0
  223. package/{examples/jsm/objects → src/renderers/common}/QuadMesh.js +6 -3
  224. package/src/renderers/common/RenderBundle.js +18 -0
  225. package/src/renderers/common/RenderBundles.js +38 -0
  226. package/{examples/jsm → src}/renderers/common/RenderContext.js +1 -1
  227. package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
  228. package/{examples/jsm → src}/renderers/common/RenderList.js +9 -0
  229. package/{examples/jsm → src}/renderers/common/RenderObject.js +50 -11
  230. package/{examples/jsm → src}/renderers/common/Renderer.js +220 -40
  231. package/{examples/jsm → src}/renderers/common/SampledTexture.js +2 -2
  232. package/{examples/jsm → src}/renderers/common/StorageBufferAttribute.js +1 -1
  233. package/{examples/jsm → src}/renderers/common/StorageInstancedBufferAttribute.js +1 -1
  234. package/{examples/jsm → src}/renderers/common/StorageTexture.js +2 -1
  235. package/{examples/jsm → src}/renderers/common/Textures.js +6 -2
  236. package/{examples/jsm → src}/renderers/common/Uniform.js +10 -5
  237. package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
  238. package/{examples/jsm → src}/renderers/common/extras/PMREMGenerator.js +13 -12
  239. package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
  240. package/{examples/jsm → src}/renderers/common/nodes/NodeSampledTexture.js +19 -4
  241. package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +8 -1
  242. package/{examples/jsm → src}/renderers/common/nodes/NodeStorageBuffer.js +5 -1
  243. package/{examples/jsm → src}/renderers/common/nodes/NodeUniform.js +3 -3
  244. package/{examples/jsm → src}/renderers/common/nodes/NodeUniformBuffer.js +2 -1
  245. package/{examples/jsm → src}/renderers/common/nodes/NodeUniformsGroup.js +2 -8
  246. package/{examples/jsm → src}/renderers/common/nodes/Nodes.js +37 -16
  247. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +31 -1
  248. package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
  249. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
  250. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
  251. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +0 -9
  252. package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -10
  253. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
  254. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
  255. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
  256. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
  257. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
  258. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
  259. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
  260. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +45 -13
  261. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -4
  262. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +3 -0
  263. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +3 -3
  264. package/src/renderers/shaders/ShaderLib/depth.glsl.js +8 -0
  265. package/src/renderers/shaders/UniformsLib.js +3 -0
  266. package/src/renderers/webgl/WebGLAttributes.js +2 -2
  267. package/src/renderers/webgl/WebGLBackground.js +6 -0
  268. package/src/renderers/webgl/WebGLBufferRenderer.js +6 -19
  269. package/src/renderers/webgl/WebGLExtensions.js +3 -1
  270. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +6 -18
  271. package/src/renderers/webgl/WebGLLights.js +15 -12
  272. package/src/renderers/webgl/WebGLMaterials.js +1 -5
  273. package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
  274. package/src/renderers/webgl/WebGLProgram.js +28 -31
  275. package/src/renderers/webgl/WebGLPrograms.js +15 -15
  276. package/src/renderers/webgl/WebGLRenderStates.js +2 -2
  277. package/src/renderers/webgl/WebGLTextures.js +100 -70
  278. package/src/renderers/webgl/WebGLUniforms.js +12 -2
  279. package/src/renderers/webgl/WebGLUniformsGroups.js +7 -7
  280. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +156 -54
  281. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +188 -41
  282. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +2 -2
  283. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +1 -0
  284. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLExtensions.js +2 -0
  285. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLState.js +1 -1
  286. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +126 -7
  287. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +1 -1
  288. package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +212 -78
  289. package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +2 -2
  290. package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +245 -49
  291. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
  292. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
  293. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +30 -14
  294. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +9 -1
  295. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +74 -24
  296. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +101 -25
  297. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +24 -3
  298. package/src/renderers/webxr/WebXRDepthSensing.js +9 -3
  299. package/src/renderers/webxr/WebXRManager.js +12 -2
  300. package/src/textures/CompressedArrayTexture.js +14 -0
  301. package/src/textures/DataArrayTexture.js +14 -0
  302. package/src/textures/DepthTexture.js +1 -3
  303. package/src/utils.js +30 -1
  304. package/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
  305. package/examples/jsm/nodes/accessors/CameraNode.js +0 -119
  306. package/examples/jsm/nodes/accessors/InstanceNode.js +0 -94
  307. package/examples/jsm/nodes/accessors/NormalNode.js +0 -106
  308. package/examples/jsm/nodes/accessors/PositionNode.js +0 -104
  309. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
  310. package/examples/jsm/nodes/accessors/TangentNode.js +0 -109
  311. package/examples/jsm/nodes/accessors/UVNode.js +0 -47
  312. package/examples/jsm/nodes/core/NodeCache.js +0 -26
  313. package/examples/jsm/nodes/core/VaryingNode.js +0 -65
  314. package/examples/jsm/nodes/display/PassNode.js +0 -199
  315. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -255
  316. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
  317. package/examples/jsm/renderers/common/ChainMap.js +0 -89
  318. package/examples/jsm/renderers/common/PostProcessing.js +0 -33
  319. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
  320. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
  321. /package/{examples/jsm → src}/nodes/accessors/AccessorsUtils.js +0 -0
  322. /package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +0 -0
  323. /package/{examples/jsm → src}/nodes/accessors/InstancedPointsMaterialNode.js +0 -0
  324. /package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +0 -0
  325. /package/{examples/jsm → src}/nodes/accessors/ModelViewProjectionNode.js +0 -0
  326. /package/{examples/jsm → src}/nodes/accessors/PointUVNode.js +0 -0
  327. /package/{examples/jsm → src}/nodes/accessors/RendererReferenceNode.js +0 -0
  328. /package/{examples/jsm → src}/nodes/accessors/SceneNode.js +0 -0
  329. /package/{examples/jsm → src}/nodes/accessors/SkinningNode.js +0 -0
  330. /package/{examples/jsm → src}/nodes/accessors/TextureBicubicNode.js +0 -0
  331. /package/{examples/jsm → src}/nodes/accessors/TextureSizeNode.js +0 -0
  332. /package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +0 -0
  333. /package/{examples/jsm → src}/nodes/code/CodeNode.js +0 -0
  334. /package/{examples/jsm → src}/nodes/code/ExpressionNode.js +0 -0
  335. /package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +0 -0
  336. /package/{examples/jsm → src}/nodes/code/FunctionNode.js +0 -0
  337. /package/{examples/jsm → src}/nodes/core/AssignNode.js +0 -0
  338. /package/{examples/jsm → src}/nodes/core/BypassNode.js +0 -0
  339. /package/{examples/jsm → src}/nodes/core/ConstNode.js +0 -0
  340. /package/{examples/jsm → src}/nodes/core/InputNode.js +0 -0
  341. /package/{examples/jsm → src}/nodes/core/NodeAttribute.js +0 -0
  342. /package/{examples/jsm → src}/nodes/core/NodeCode.js +0 -0
  343. /package/{examples/jsm → src}/nodes/core/NodeFunctionInput.js +0 -0
  344. /package/{examples/jsm → src}/nodes/core/NodeParser.js +0 -0
  345. /package/{examples/jsm → src}/nodes/core/NodeVar.js +0 -0
  346. /package/{examples/jsm → src}/nodes/core/NodeVarying.js +0 -0
  347. /package/{examples/jsm → src}/nodes/core/ParameterNode.js +0 -0
  348. /package/{examples/jsm → src}/nodes/core/StackNode.js +0 -0
  349. /package/{examples/jsm → src}/nodes/core/StructTypeNode.js +0 -0
  350. /package/{examples/jsm → src}/nodes/core/UniformGroup.js +0 -0
  351. /package/{examples/jsm → src}/nodes/core/constants.js +0 -0
  352. /package/{examples/jsm → src}/nodes/display/BlendModeNode.js +0 -0
  353. /package/{examples/jsm → src}/nodes/display/BumpMapNode.js +0 -0
  354. /package/{examples/jsm → src}/nodes/display/PosterizeNode.js +0 -0
  355. /package/{examples/jsm → src}/nodes/fog/FogExp2Node.js +0 -0
  356. /package/{examples/jsm → src}/nodes/fog/FogNode.js +0 -0
  357. /package/{examples/jsm → src}/nodes/fog/FogRangeNode.js +0 -0
  358. /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_GGX.js +0 -0
  359. /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +0 -0
  360. /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +0 -0
  361. /package/{examples/jsm → src}/nodes/functions/BSDF/DFGApprox.js +0 -0
  362. /package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +0 -0
  363. /package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX_Anisotropic.js +0 -0
  364. /package/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +0 -0
  365. /package/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +0 -0
  366. /package/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +0 -0
  367. /package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +0 -0
  368. /package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +0 -0
  369. /package/{examples/jsm → src}/nodes/functions/ShadowMaskModel.js +0 -0
  370. /package/{examples/jsm → src}/nodes/functions/material/getGeometryRoughness.js +0 -0
  371. /package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +0 -0
  372. /package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +0 -0
  373. /package/{examples/jsm → src}/nodes/lighting/IrradianceNode.js +0 -0
  374. /package/{examples/jsm → src}/nodes/lighting/LightNode.js +0 -0
  375. /package/{examples/jsm → src}/nodes/lighting/LightUtils.js +0 -0
  376. /package/{examples/jsm → src}/nodes/lighting/LightingContextNode.js +0 -0
  377. /package/{examples/jsm → src}/nodes/materials/MeshSSSNodeMaterial.js +0 -0
  378. /package/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
  379. /package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +0 -0
  380. /package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -0
  381. /package/{examples/jsm → src}/nodes/math/TriNoise3D.js +0 -0
  382. /package/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +0 -0
  383. /package/{examples/jsm → src}/nodes/pmrem/PMREMUtils.js +0 -0
  384. /package/{examples/jsm → src}/nodes/procedural/CheckerNode.js +0 -0
  385. /package/{examples/jsm → src}/nodes/utils/ConvertNode.js +0 -0
  386. /package/{examples/jsm → src}/nodes/utils/EquirectUVNode.js +0 -0
  387. /package/{examples/jsm → src}/nodes/utils/JoinNode.js +0 -0
  388. /package/{examples/jsm → src}/nodes/utils/OscNode.js +0 -0
  389. /package/{examples/jsm → src}/nodes/utils/PackingNode.js +0 -0
  390. /package/{examples/jsm → src}/nodes/utils/RemapNode.js +0 -0
  391. /package/{examples/jsm → src}/nodes/utils/RotateNode.js +0 -0
  392. /package/{examples/jsm → src}/nodes/utils/RotateUVNode.js +0 -0
  393. /package/{examples/jsm → src}/nodes/utils/SetNode.js +0 -0
  394. /package/{examples/jsm → src}/nodes/utils/SplitNode.js +0 -0
  395. /package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +0 -0
  396. /package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +0 -0
  397. /package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +0 -0
  398. /package/{examples/jsm → src}/renderers/common/Animation.js +0 -0
  399. /package/{examples/jsm → src}/renderers/common/Binding.js +0 -0
  400. /package/{examples/jsm → src}/renderers/common/Buffer.js +0 -0
  401. /package/{examples/jsm → src}/renderers/common/BufferUtils.js +0 -0
  402. /package/{examples/jsm → src}/renderers/common/ComputePipeline.js +0 -0
  403. /package/{examples/jsm → src}/renderers/common/Constants.js +0 -0
  404. /package/{examples/jsm → src}/renderers/common/DataMap.js +0 -0
  405. /package/{examples/jsm → src}/renderers/common/Pipeline.js +0 -0
  406. /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
  407. /package/{examples/jsm → src}/renderers/common/RenderLists.js +0 -0
  408. /package/{examples/jsm → src}/renderers/common/RenderObjects.js +0 -0
  409. /package/{examples/jsm → src}/renderers/common/RenderPipeline.js +0 -0
  410. /package/{examples/jsm → src}/renderers/common/Sampler.js +0 -0
  411. /package/{examples/jsm → src}/renderers/common/StorageBuffer.js +0 -0
  412. /package/{examples/jsm → src}/renderers/common/UniformBuffer.js +0 -0
  413. /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBufferRenderer.js +0 -0
  414. /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLCapabilities.js +0 -0
  415. /package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeParser.js +0 -0
  416. /package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +0 -0
@@ -0,0 +1,159 @@
1
+ import NodeFunction from '../../../nodes/core/NodeFunction.js';
2
+ import NodeFunctionInput from '../../../nodes/core/NodeFunctionInput.js';
3
+
4
+ const declarationRegexp = /^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i;
5
+ const propertiesRegexp = /([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig;
6
+
7
+ const wgslTypeLib = {
8
+ 'f32': 'float',
9
+ 'i32': 'int',
10
+ 'u32': 'uint',
11
+ 'bool': 'bool',
12
+
13
+ 'vec2<f32>': 'vec2',
14
+ 'vec2<i32>': 'ivec2',
15
+ 'vec2<u32>': 'uvec2',
16
+ 'vec2<bool>': 'bvec2',
17
+
18
+ 'vec2f': 'vec2',
19
+ 'vec2i': 'ivec2',
20
+ 'vec2u': 'uvec2',
21
+ 'vec2b': 'bvec2',
22
+
23
+ 'vec3<f32>': 'vec3',
24
+ 'vec3<i32>': 'ivec3',
25
+ 'vec3<u32>': 'uvec3',
26
+ 'vec3<bool>': 'bvec3',
27
+
28
+ 'vec3f': 'vec3',
29
+ 'vec3i': 'ivec3',
30
+ 'vec3u': 'uvec3',
31
+ 'vec3b': 'bvec3',
32
+
33
+ 'vec4<f32>': 'vec4',
34
+ 'vec4<i32>': 'ivec4',
35
+ 'vec4<u32>': 'uvec4',
36
+ 'vec4<bool>': 'bvec4',
37
+
38
+ 'vec4f': 'vec4',
39
+ 'vec4i': 'ivec4',
40
+ 'vec4u': 'uvec4',
41
+ 'vec4b': 'bvec4',
42
+
43
+ 'mat2x2<f32>': 'mat2',
44
+ 'mat2x2f': 'mat2',
45
+
46
+ 'mat3x3<f32>': 'mat3',
47
+ 'mat3x3f': 'mat3',
48
+
49
+ 'mat4x4<f32>': 'mat4',
50
+ 'mat4x4f': 'mat4',
51
+
52
+ 'sampler': 'sampler',
53
+
54
+ 'texture_1d': 'texture',
55
+
56
+ 'texture_2d': 'texture',
57
+ 'texture_2d_array': 'texture',
58
+ 'texture_multisampled_2d': 'cubeTexture',
59
+
60
+ 'texture_depth_2d': 'depthTexture',
61
+
62
+ 'texture_3d': 'texture3D',
63
+
64
+ 'texture_cube': 'cubeTexture',
65
+ 'texture_cube_array': 'cubeTexture',
66
+
67
+ 'texture_storage_1d': 'storageTexture',
68
+ 'texture_storage_2d': 'storageTexture',
69
+ 'texture_storage_2d_array': 'storageTexture',
70
+ 'texture_storage_3d': 'storageTexture'
71
+
72
+ };
73
+
74
+ const parse = ( source ) => {
75
+
76
+ source = source.trim();
77
+
78
+ const declaration = source.match( declarationRegexp );
79
+
80
+ if ( declaration !== null && declaration.length === 4 ) {
81
+
82
+ const inputsCode = declaration[ 2 ];
83
+ const propsMatches = [];
84
+ let match = null;
85
+
86
+ while ( ( match = propertiesRegexp.exec( inputsCode ) ) !== null ) {
87
+
88
+ propsMatches.push( { name: match[ 1 ], type: match[ 2 ] } );
89
+
90
+ }
91
+
92
+ // Process matches to correctly pair names and types
93
+ const inputs = [];
94
+ for ( let i = 0; i < propsMatches.length; i ++ ) {
95
+
96
+ const { name, type } = propsMatches[ i ];
97
+
98
+ let resolvedType = type;
99
+
100
+ if ( resolvedType.startsWith( 'texture' ) ) {
101
+
102
+ resolvedType = type.split( '<' )[ 0 ];
103
+
104
+ }
105
+
106
+ resolvedType = wgslTypeLib[ resolvedType ] || resolvedType;
107
+
108
+ inputs.push( new NodeFunctionInput( resolvedType, name ) );
109
+
110
+ }
111
+
112
+ const blockCode = source.substring( declaration[ 0 ].length );
113
+ const outputType = declaration[ 3 ] || 'void';
114
+
115
+ const name = declaration[ 1 ] !== undefined ? declaration[ 1 ] : '';
116
+ const type = wgslTypeLib[ outputType ] || outputType;
117
+
118
+ return {
119
+ type,
120
+ inputs,
121
+ name,
122
+ inputsCode,
123
+ blockCode,
124
+ outputType
125
+ };
126
+
127
+ } else {
128
+
129
+ throw new Error( 'FunctionNode: Function is not a WGSL code.' );
130
+
131
+ }
132
+
133
+ };
134
+
135
+ class WGSLNodeFunction extends NodeFunction {
136
+
137
+ constructor( source ) {
138
+
139
+ const { type, inputs, name, inputsCode, blockCode, outputType } = parse( source );
140
+
141
+ super( type, inputs, name );
142
+
143
+ this.inputsCode = inputsCode;
144
+ this.blockCode = blockCode;
145
+ this.outputType = outputType;
146
+
147
+ }
148
+
149
+ getCode( name = this.name ) {
150
+
151
+ const outputType = this.outputType !== 'void' ? '-> ' + this.outputType : '';
152
+
153
+ return `fn ${ name } ( ${ this.inputsCode.trim() } ) ${ outputType }` + this.blockCode;
154
+
155
+ }
156
+
157
+ }
158
+
159
+ export default WGSLNodeFunction;
@@ -1,6 +1,7 @@
1
- import { Float16BufferAttribute } from 'three';
2
1
  import { GPUInputStepMode } from './WebGPUConstants.js';
3
2
 
3
+ import { Float16BufferAttribute } from '../../../core/BufferAttribute.js';
4
+
4
5
  const typedArraysToVertexFormatPrefix = new Map( [
5
6
  [ Int8Array, [ 'sint8', 'snorm8' ]],
6
7
  [ Uint8Array, [ 'uint8', 'unorm8' ]],
@@ -1,7 +1,8 @@
1
1
  import {
2
- GPUTextureAspect, GPUTextureViewDimension, GPUBufferBindingType, GPUTextureSampleType
2
+ GPUTextureAspect, GPUTextureViewDimension, GPUTextureSampleType
3
3
  } from './WebGPUConstants.js';
4
- import { FloatType, IntType, UnsignedIntType } from 'three';
4
+
5
+ import { FloatType, IntType, UnsignedIntType } from '../../../constants.js';
5
6
 
6
7
  class WebGPUBindingUtils {
7
8
 
@@ -11,7 +12,7 @@ class WebGPUBindingUtils {
11
12
 
12
13
  }
13
14
 
14
- createBindingsLayout( bindings ) {
15
+ createBindingsLayout( bindGroup ) {
15
16
 
16
17
  const backend = this.backend;
17
18
  const device = backend.device;
@@ -20,7 +21,7 @@ class WebGPUBindingUtils {
20
21
 
21
22
  let index = 0;
22
23
 
23
- for ( const binding of bindings ) {
24
+ for ( const binding of bindGroup.bindings ) {
24
25
 
25
26
  const bindingGPU = {
26
27
  binding: index ++,
@@ -33,7 +34,7 @@ class WebGPUBindingUtils {
33
34
 
34
35
  if ( binding.isStorageBuffer ) {
35
36
 
36
- buffer.type = GPUBufferBindingType.Storage;
37
+ buffer.type = binding.access;
37
38
 
38
39
  }
39
40
 
@@ -62,18 +63,25 @@ class WebGPUBindingUtils {
62
63
  } else if ( binding.isSampledTexture && binding.store ) {
63
64
 
64
65
  const format = this.backend.get( binding.texture ).texture.format;
66
+ const access = binding.access;
65
67
 
66
- bindingGPU.storageTexture = { format }; // GPUStorageTextureBindingLayout
68
+ bindingGPU.storageTexture = { format, access }; // GPUStorageTextureBindingLayout
67
69
 
68
70
  } else if ( binding.isSampledTexture ) {
69
71
 
70
72
  const texture = {}; // GPUTextureBindingLayout
71
73
 
74
+ if ( binding.texture.isMultisampleRenderTargetTexture === true ) {
75
+
76
+ texture.multisampled = true;
77
+
78
+ }
79
+
72
80
  if ( binding.texture.isDepthTexture ) {
73
81
 
74
82
  texture.sampleType = GPUTextureSampleType.Depth;
75
83
 
76
- } else if ( binding.texture.isDataTexture ) {
84
+ } else if ( binding.texture.isDataTexture || binding.texture.isDataArrayTexture || binding.texture.isData3DTexture ) {
77
85
 
78
86
  const type = binding.texture.type;
79
87
 
@@ -103,6 +111,10 @@ class WebGPUBindingUtils {
103
111
 
104
112
  texture.viewDimension = GPUTextureViewDimension.TwoDArray;
105
113
 
114
+ } else if ( binding.isSampledTexture3D ) {
115
+
116
+ texture.viewDimension = GPUTextureViewDimension.ThreeD;
117
+
106
118
  }
107
119
 
108
120
  bindingGPU.texture = texture;
@@ -121,19 +133,18 @@ class WebGPUBindingUtils {
121
133
 
122
134
  }
123
135
 
124
- createBindings( bindings ) {
136
+ createBindings( bindGroup ) {
125
137
 
126
138
  const backend = this.backend;
127
- const bindingsData = backend.get( bindings );
139
+ const bindingsData = backend.get( bindGroup );
128
140
 
129
141
  // setup (static) binding layout and (dynamic) binding group
130
142
 
131
- const bindLayoutGPU = this.createBindingsLayout( bindings );
132
- const bindGroupGPU = this.createBindGroup( bindings, bindLayoutGPU );
143
+ const bindLayoutGPU = this.createBindingsLayout( bindGroup );
144
+ const bindGroupGPU = this.createBindGroup( bindGroup, bindLayoutGPU );
133
145
 
134
146
  bindingsData.layout = bindLayoutGPU;
135
147
  bindingsData.group = bindGroupGPU;
136
- bindingsData.bindings = bindings;
137
148
 
138
149
  }
139
150
 
@@ -149,7 +160,7 @@ class WebGPUBindingUtils {
149
160
 
150
161
  }
151
162
 
152
- createBindGroup( bindings, layoutGPU ) {
163
+ createBindGroup( bindGroup, layoutGPU ) {
153
164
 
154
165
  const backend = this.backend;
155
166
  const device = backend.device;
@@ -157,7 +168,7 @@ class WebGPUBindingUtils {
157
168
  let bindingPoint = 0;
158
169
  const entriesGPU = [];
159
170
 
160
- for ( const binding of bindings ) {
171
+ for ( const binding of bindGroup.bindings ) {
161
172
 
162
173
  if ( binding.isUniformBuffer ) {
163
174
 
@@ -214,6 +225,10 @@ class WebGPUBindingUtils {
214
225
 
215
226
  dimensionViewGPU = GPUTextureViewDimension.Cube;
216
227
 
228
+ } else if ( binding.isSampledTexture3D ) {
229
+
230
+ dimensionViewGPU = GPUTextureViewDimension.ThreeD;
231
+
217
232
  } else if ( binding.texture.isDataArrayTexture ) {
218
233
 
219
234
  dimensionViewGPU = GPUTextureViewDimension.TwoDArray;
@@ -247,6 +262,7 @@ class WebGPUBindingUtils {
247
262
  }
248
263
 
249
264
  return device.createBindGroup( {
265
+ label: 'bindGroup_' + bindGroup.name,
250
266
  layout: layoutGPU,
251
267
  entries: entriesGPU
252
268
  } );
@@ -269,6 +269,12 @@ export const GPUBufferBindingType = {
269
269
  ReadOnlyStorage: 'read-only-storage'
270
270
  };
271
271
 
272
+ export const GPUStorageTextureAccess = {
273
+ WriteOnly: 'write-only',
274
+ ReadOnly: 'read-only',
275
+ ReadWrite: 'read-write',
276
+ };
277
+
272
278
  export const GPUSamplerBindingType = {
273
279
  Filtering: 'filtering',
274
280
  NonFiltering: 'non-filtering',
@@ -320,5 +326,7 @@ export const GPUFeatureName = {
320
326
  ShaderF16: 'shader-f16',
321
327
  RG11B10UFloat: 'rg11b10ufloat-renderable',
322
328
  BGRA8UNormStorage: 'bgra8unorm-storage',
323
- Float32Filterable: 'float32-filterable'
329
+ Float32Filterable: 'float32-filterable',
330
+ ClipDistances: 'clip-distances',
331
+ DualSourceBlending: 'dual-source-blending'
324
332
  };
@@ -13,7 +13,7 @@ import {
13
13
  AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation,
14
14
  KeepStencilOp, ZeroStencilOp, ReplaceStencilOp, InvertStencilOp, IncrementStencilOp, DecrementStencilOp, IncrementWrapStencilOp, DecrementWrapStencilOp,
15
15
  NeverStencilFunc, AlwaysStencilFunc, LessStencilFunc, LessEqualStencilFunc, EqualStencilFunc, GreaterEqualStencilFunc, GreaterStencilFunc, NotEqualStencilFunc
16
- } from 'three';
16
+ } from '../../../constants.js';
17
17
 
18
18
  class WebGPUPipelineUtils {
19
19
 
@@ -23,6 +23,12 @@ class WebGPUPipelineUtils {
23
23
 
24
24
  }
25
25
 
26
+ _getSampleCount( renderObjectContext ) {
27
+
28
+ return this.backend.utils.getSampleCountRenderContext( renderObjectContext );
29
+
30
+ }
31
+
26
32
  createRenderPipeline( renderObject, promises ) {
27
33
 
28
34
  const { object, material, geometry, pipeline } = renderObject;
@@ -33,7 +39,18 @@ class WebGPUPipelineUtils {
33
39
  const utils = backend.utils;
34
40
 
35
41
  const pipelineData = backend.get( pipeline );
36
- const bindingsData = backend.get( renderObject.getBindings() );
42
+
43
+ // bind group layouts
44
+
45
+ const bindGroupLayouts = [];
46
+
47
+ for ( const bindGroup of renderObject.getBindings() ) {
48
+
49
+ const bindingsData = backend.get( bindGroup );
50
+
51
+ bindGroupLayouts.push( bindingsData.layout );
52
+
53
+ }
37
54
 
38
55
  // vertex buffers
39
56
 
@@ -102,22 +119,11 @@ class WebGPUPipelineUtils {
102
119
  const primitiveState = this._getPrimitiveState( object, geometry, material );
103
120
  const depthCompare = this._getDepthCompare( material );
104
121
  const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderObject.context );
105
- let sampleCount = utils.getSampleCount( renderObject.context );
106
-
107
- if ( sampleCount > 1 ) {
108
-
109
- // WebGPU only supports power-of-two sample counts and 2 is not a valid value
110
- sampleCount = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
111
122
 
112
- if ( sampleCount === 2 ) {
113
-
114
- sampleCount = 4;
115
-
116
- }
117
-
118
- }
123
+ const sampleCount = this._getSampleCount( renderObject.context );
119
124
 
120
125
  const pipelineDescriptor = {
126
+ label: 'renderPipeline',
121
127
  vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),
122
128
  fragment: Object.assign( {}, fragmentModule, { targets } ),
123
129
  primitive: primitiveState,
@@ -135,7 +141,7 @@ class WebGPUPipelineUtils {
135
141
  alphaToCoverageEnabled: material.alphaToCoverage
136
142
  },
137
143
  layout: device.createPipelineLayout( {
138
- bindGroupLayouts: [ bindingsData.layout ]
144
+ bindGroupLayouts
139
145
  } )
140
146
  };
141
147
 
@@ -162,6 +168,35 @@ class WebGPUPipelineUtils {
162
168
 
163
169
  }
164
170
 
171
+ createBundleEncoder( renderContext, renderObject ) {
172
+
173
+ const backend = this.backend;
174
+ const { utils, device } = backend;
175
+
176
+ const renderContextData = backend.get( renderContext );
177
+ const renderObjectData = backend.get( renderObject );
178
+
179
+ const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderContext );
180
+ const colorFormat = utils.getCurrentColorFormat( renderContext );
181
+ const sampleCount = this._getSampleCount( renderObject.context );
182
+
183
+ const descriptor = {
184
+ label: 'renderBundleEncoder',
185
+ colorFormats: [ colorFormat ],
186
+ depthStencilFormat,
187
+ sampleCount
188
+ };
189
+
190
+ const bundleEncoder = device.createRenderBundleEncoder( descriptor );
191
+
192
+ renderObjectData.bundleEncoder = bundleEncoder;
193
+ renderContextData.currentSets = { attributes: {} };
194
+ renderContextData._renderBundleViewport = renderContext.width + '_' + renderContext.height;
195
+
196
+ return bundleEncoder;
197
+
198
+ }
199
+
165
200
  createComputePipeline( pipeline, bindings ) {
166
201
 
167
202
  const backend = this.backend;
@@ -170,12 +205,23 @@ class WebGPUPipelineUtils {
170
205
  const computeProgram = backend.get( pipeline.computeProgram ).module;
171
206
 
172
207
  const pipelineGPU = backend.get( pipeline );
173
- const bindingsData = backend.get( bindings );
208
+
209
+ // bind group layouts
210
+
211
+ const bindGroupLayouts = [];
212
+
213
+ for ( const bindingsGroup of bindings ) {
214
+
215
+ const bindingsData = backend.get( bindingsGroup );
216
+
217
+ bindGroupLayouts.push( bindingsData.layout );
218
+
219
+ }
174
220
 
175
221
  pipelineGPU.pipeline = device.createComputePipeline( {
176
222
  compute: computeProgram,
177
223
  layout: device.createPipelineLayout( {
178
- bindGroupLayouts: [ bindingsData.layout ]
224
+ bindGroupLayouts
179
225
  } )
180
226
  } );
181
227
 
@@ -186,17 +232,21 @@ class WebGPUPipelineUtils {
186
232
  let color, alpha;
187
233
 
188
234
  const blending = material.blending;
235
+ const blendSrc = material.blendSrc;
236
+ const blendDst = material.blendDst;
237
+ const blendEquation = material.blendEquation;
238
+
189
239
 
190
240
  if ( blending === CustomBlending ) {
191
241
 
192
- const blendSrcAlpha = material.blendSrcAlpha !== null ? material.blendSrcAlpha : GPUBlendFactor.One;
193
- const blendDstAlpha = material.blendDstAlpha !== null ? material.blendDstAlpha : GPUBlendFactor.Zero;
194
- const blendEquationAlpha = material.blendEquationAlpha !== null ? material.blendEquationAlpha : GPUBlendFactor.Add;
242
+ const blendSrcAlpha = material.blendSrcAlpha !== null ? material.blendSrcAlpha : blendSrc;
243
+ const blendDstAlpha = material.blendDstAlpha !== null ? material.blendDstAlpha : blendDst;
244
+ const blendEquationAlpha = material.blendEquationAlpha !== null ? material.blendEquationAlpha : blendEquation;
195
245
 
196
246
  color = {
197
- srcFactor: this._getBlendFactor( material.blendSrc ),
198
- dstFactor: this._getBlendFactor( material.blendDst ),
199
- operation: this._getBlendOperation( material.blendEquation )
247
+ srcFactor: this._getBlendFactor( blendSrc ),
248
+ dstFactor: this._getBlendFactor( blendDst ),
249
+ operation: this._getBlendOperation( blendEquation )
200
250
  };
201
251
 
202
252
  alpha = {
@@ -2,20 +2,22 @@ import {
2
2
  GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension, GPUFeatureName
3
3
  } from './WebGPUConstants.js';
4
4
 
5
+ import WebGPUTexturePassUtils from './WebGPUTexturePassUtils.js';
6
+
5
7
  import {
6
- CubeTexture, Texture,
8
+ ByteType, ShortType,
7
9
  NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter,
8
10
  RepeatWrapping, MirroredRepeatWrapping,
9
11
  RGB_ETC2_Format, RGBA_ETC2_EAC_Format,
10
12
  RGBAFormat, RGBFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBColorSpace, DepthFormat, DepthStencilFormat,
11
13
  RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format,
12
14
  RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, UnsignedIntType, UnsignedShortType, UnsignedInt248Type, UnsignedInt5999Type,
13
- NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, IntType, RedIntegerFormat, RGIntegerFormat, RGBAIntegerFormat
14
- } from 'three';
15
-
16
- import { CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping, DepthTexture } from 'three';
17
-
18
- import WebGPUTexturePassUtils from './WebGPUTexturePassUtils.js';
15
+ NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, IntType, RedIntegerFormat, RGIntegerFormat, RGBAIntegerFormat,
16
+ CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping
17
+ } from '../../../constants.js';
18
+ import { CubeTexture } from '../../../textures/CubeTexture.js';
19
+ import { DepthTexture } from '../../../textures/DepthTexture.js';
20
+ import { Texture } from '../../../textures/Texture.js';
19
21
 
20
22
  const _compareToWebGPU = {
21
23
  [ NeverCompare ]: 'never',
@@ -40,6 +42,7 @@ class WebGPUTextureUtils {
40
42
 
41
43
  this.defaultTexture = {};
42
44
  this.defaultCubeTexture = {};
45
+ this.defaultVideoFrame = null;
43
46
 
44
47
  this.colorBuffer = null;
45
48
 
@@ -85,6 +88,10 @@ class WebGPUTextureUtils {
85
88
 
86
89
  textureGPU = this._getDefaultCubeTextureGPU( format );
87
90
 
91
+ } else if ( texture.isVideoTexture ) {
92
+
93
+ this.backend.get( texture ).externalTexture = this._getDefaultVideoFrame();
94
+
88
95
  } else {
89
96
 
90
97
  textureGPU = this._getDefaultTextureGPU( format );
@@ -117,20 +124,9 @@ class WebGPUTextureUtils {
117
124
 
118
125
  let sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
119
126
 
120
- if ( sampleCount > 1 ) {
121
-
122
- // WebGPU only supports power-of-two sample counts and 2 is not a valid value
123
- sampleCount = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
127
+ sampleCount = backend.utils.getSampleCount( sampleCount );
124
128
 
125
- if ( sampleCount === 2 ) {
126
-
127
- sampleCount = 4;
128
-
129
- }
130
-
131
- }
132
-
133
- const primarySampleCount = texture.isRenderTargetTexture ? 1 : sampleCount;
129
+ const primarySampleCount = texture.isRenderTargetTexture && ! texture.isMultisampleRenderTargetTexture ? 1 : sampleCount;
134
130
 
135
131
  let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC;
136
132
 
@@ -188,7 +184,7 @@ class WebGPUTextureUtils {
188
184
 
189
185
  }
190
186
 
191
- if ( texture.isRenderTargetTexture && sampleCount > 1 ) {
187
+ if ( texture.isRenderTargetTexture && sampleCount > 1 && ! texture.isMultisampleRenderTargetTexture ) {
192
188
 
193
189
  const msaaTextureDescriptorGPU = Object.assign( {}, textureDescriptorGPU );
194
190
 
@@ -261,7 +257,7 @@ class WebGPUTextureUtils {
261
257
  height: height,
262
258
  depthOrArrayLayers: 1
263
259
  },
264
- sampleCount: backend.parameters.sampleCount,
260
+ sampleCount: backend.utils.getSampleCount( backend.renderer.samples ),
265
261
  format: GPUTextureFormat.BGRA8Unorm,
266
262
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC
267
263
  } );
@@ -310,7 +306,7 @@ class WebGPUTextureUtils {
310
306
  depthTexture.image.width = width;
311
307
  depthTexture.image.height = height;
312
308
 
313
- this.createTexture( depthTexture, { sampleCount: backend.parameters.sampleCount, width, height } );
309
+ this.createTexture( depthTexture, { sampleCount: backend.utils.getSampleCount( backend.renderer.samples ), width, height } );
314
310
 
315
311
  return backend.get( depthTexture ).texture;
316
312
 
@@ -327,11 +323,11 @@ class WebGPUTextureUtils {
327
323
 
328
324
  // transfer texture data
329
325
 
330
- if ( texture.isDataTexture || texture.isData3DTexture ) {
326
+ if ( texture.isDataTexture ) {
331
327
 
332
328
  this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
333
329
 
334
- } else if ( texture.isDataArrayTexture ) {
330
+ } else if ( texture.isDataArrayTexture || texture.isData3DTexture ) {
335
331
 
336
332
  for ( let i = 0; i < options.image.depth; i ++ ) {
337
333
 
@@ -464,6 +460,27 @@ class WebGPUTextureUtils {
464
460
 
465
461
  }
466
462
 
463
+ _getDefaultVideoFrame() {
464
+
465
+ let defaultVideoFrame = this.defaultVideoFrame;
466
+
467
+ if ( defaultVideoFrame === null ) {
468
+
469
+ const init = {
470
+ timestamp: 0,
471
+ codedWidth: 1,
472
+ codedHeight: 1,
473
+ format: 'RGBA',
474
+ };
475
+
476
+ this.defaultVideoFrame = defaultVideoFrame = new VideoFrame( new Uint8Array( [ 0, 0, 0, 0xff ] ), init );
477
+
478
+ }
479
+
480
+ return defaultVideoFrame;
481
+
482
+ }
483
+
467
484
  _copyCubeMapToTexture( images, textureGPU, textureDescriptorGPU, flipY ) {
468
485
 
469
486
  for ( let i = 0; i < 6; i ++ ) {
@@ -913,6 +930,25 @@ export function getFormat( texture, device = null ) {
913
930
 
914
931
  switch ( type ) {
915
932
 
933
+ case ByteType:
934
+ formatGPU = GPUTextureFormat.RGBA8Snorm;
935
+ break;
936
+
937
+ case ShortType:
938
+ formatGPU = GPUTextureFormat.RGBA16Sint;
939
+ break;
940
+
941
+ case UnsignedShortType:
942
+ formatGPU = GPUTextureFormat.RGBA16Uint;
943
+ break;
944
+ case UnsignedIntType:
945
+ formatGPU = GPUTextureFormat.RGBA32Uint;
946
+ break;
947
+
948
+ case IntType:
949
+ formatGPU = GPUTextureFormat.RGBA32Sint;
950
+ break;
951
+
916
952
  case UnsignedByteType:
917
953
  formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
918
954
  break;
@@ -951,6 +987,26 @@ export function getFormat( texture, device = null ) {
951
987
 
952
988
  switch ( type ) {
953
989
 
990
+ case ByteType:
991
+ formatGPU = GPUTextureFormat.R8Snorm;
992
+ break;
993
+
994
+ case ShortType:
995
+ formatGPU = GPUTextureFormat.R16Sint;
996
+ break;
997
+
998
+ case UnsignedShortType:
999
+ formatGPU = GPUTextureFormat.R16Uint;
1000
+ break;
1001
+
1002
+ case UnsignedIntType:
1003
+ formatGPU = GPUTextureFormat.R32Uint;
1004
+ break;
1005
+
1006
+ case IntType:
1007
+ formatGPU = GPUTextureFormat.R32Sint;
1008
+ break;
1009
+
954
1010
  case UnsignedByteType:
955
1011
  formatGPU = GPUTextureFormat.R8Unorm;
956
1012
  break;
@@ -974,6 +1030,26 @@ export function getFormat( texture, device = null ) {
974
1030
 
975
1031
  switch ( type ) {
976
1032
 
1033
+ case ByteType:
1034
+ formatGPU = GPUTextureFormat.RG8Snorm;
1035
+ break;
1036
+
1037
+ case ShortType:
1038
+ formatGPU = GPUTextureFormat.RG16Sint;
1039
+ break;
1040
+
1041
+ case UnsignedShortType:
1042
+ formatGPU = GPUTextureFormat.RG16Uint;
1043
+ break;
1044
+
1045
+ case UnsignedIntType:
1046
+ formatGPU = GPUTextureFormat.RG32Uint;
1047
+ break;
1048
+
1049
+ case IntType:
1050
+ formatGPU = GPUTextureFormat.RG32Sint;
1051
+ break;
1052
+
977
1053
  case UnsignedByteType:
978
1054
  formatGPU = GPUTextureFormat.RG8Unorm;
979
1055
  break;