@needle-tools/three 0.162.12 → 0.169.2
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.
- package/README.md +3 -3
- package/build/three.cjs +29789 -1941
- package/build/three.module.js +29095 -1933
- package/build/three.module.min.js +2 -2
- package/build/three.webgpu.js +80003 -0
- package/build/three.webgpu.min.js +6 -0
- package/build/three.webgpu.nodes.js +79951 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +2 -5
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/animation/CCDIKSolver.js +4 -2
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +790 -797
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +98 -63
- package/examples/jsm/csm/CSMShader.js +4 -4
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +2 -6
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +77 -8
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +55 -11
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/helpers/ViewHelper.js +75 -61
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/draco/README.md +2 -2
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/LineMaterial.js +1 -17
- package/examples/jsm/lines/LineSegments2.js +15 -0
- package/examples/jsm/lines/Wireframe.js +16 -1
- package/examples/jsm/lines/webgpu/Line2.js +20 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +4 -2
- package/examples/jsm/loaders/EXRLoader.js +351 -97
- package/examples/jsm/loaders/FBXLoader.js +77 -78
- package/examples/jsm/loaders/GLTFLoader.js +76 -14
- package/examples/jsm/loaders/KTX2Loader.js +30 -22
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +45 -21
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/USDZLoader.js +124 -76
- package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
- package/examples/jsm/loaders/VRMLLoader.js +11 -11
- package/examples/jsm/loaders/VTKLoader.js +80 -6
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
- package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
- package/examples/jsm/math/Octree.js +26 -20
- package/examples/jsm/misc/GPUComputationRenderer.js +9 -25
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -1
- package/examples/jsm/objects/InstancedPoints.js +2 -2
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +281 -0
- package/examples/jsm/physics/RapierPhysics.js +25 -5
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/RenderTransitionPass.js +168 -0
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/postprocessing/SSAOPass.js +6 -12
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
- package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +7 -4
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +19 -5
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/ColorifyShader.js +1 -2
- package/examples/jsm/shaders/FXAAShader.js +0 -2
- package/examples/jsm/shaders/GTAOShader.js +1 -1
- package/examples/jsm/shaders/LuminosityHighPassShader.js +1 -3
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +47 -5
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +24 -22
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/SceneUtils.js +60 -1
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/examples/jsm/utils/TextureUtils.js +3 -2
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/OculusHandModel.js +3 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
- package/package.json +11 -8
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +201 -0
- package/src/Three.js +23 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
- package/src/animation/tracks/StringKeyframeTrack.js +10 -1
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +6 -7
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/core/Object3D.js +34 -29
- package/src/core/Raycaster.js +6 -2
- package/src/core/RenderTarget.js +8 -0
- package/src/extras/Controls.js +32 -0
- package/src/extras/PMREMGenerator.js +12 -11
- package/src/extras/TextureUtils.js +210 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/lights/Light.js +1 -0
- package/src/lights/LightShadow.js +5 -0
- package/{examples/jsm/lights → src/lights/webgpu}/IESSpotLight.js +1 -1
- package/src/loaders/FileLoader.js +5 -1
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/MaterialLoader.js +8 -1
- package/src/loaders/ObjectLoader.js +36 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeLoader.js +27 -5
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeMaterialLoader.js +22 -18
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeObjectLoader.js +21 -1
- package/src/materials/Material.js +4 -0
- package/src/materials/MeshPhysicalMaterial.js +20 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/Line2NodeMaterial.js +69 -68
- package/src/materials/nodes/LineBasicNodeMaterial.js +31 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/LineDashedNodeMaterial.js +15 -12
- package/src/materials/nodes/MeshBasicNodeMaterial.js +77 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +47 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +57 -0
- package/src/materials/nodes/MeshNormalNodeMaterial.js +44 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +78 -0
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +248 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/materials/nodes/MeshStandardNodeMaterial.js +108 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +38 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/NodeMaterial.js +198 -157
- package/{examples/jsm/nodes/materials/Materials.js → src/materials/nodes/NodeMaterials.js} +7 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/PointsNodeMaterial.js +10 -7
- package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +123 -0
- package/src/materials/nodes/VolumeNodeMaterial.js +108 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Box2.js +4 -4
- package/src/math/Box3.js +6 -6
- package/src/math/ColorManagement.js +10 -0
- package/src/math/Matrix2.js +54 -0
- package/src/math/Spherical.js +4 -5
- package/src/math/Triangle.js +24 -0
- package/src/math/Vector4.js +13 -0
- package/src/nodes/Nodes.js +164 -0
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +25 -0
- package/src/nodes/accessors/BatchNode.js +128 -0
- package/src/nodes/accessors/Bitangent.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +44 -6
- package/{examples/jsm → src}/nodes/accessors/BufferNode.js +13 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +22 -15
- package/src/nodes/accessors/CubeTextureNode.js +79 -0
- package/src/nodes/accessors/InstanceNode.js +144 -0
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +24 -0
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +441 -0
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +10 -5
- package/src/nodes/accessors/ModelNode.js +72 -0
- package/src/nodes/accessors/ModelViewProjectionNode.js +42 -0
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +51 -33
- package/src/nodes/accessors/Normal.js +88 -0
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +18 -34
- package/src/nodes/accessors/PointUVNode.js +30 -0
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +58 -9
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +35 -0
- package/{examples/jsm → src}/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +191 -0
- package/src/nodes/accessors/StorageBufferNode.js +147 -0
- package/{examples/jsm/nodes/accessors/TextureStoreNode.js → src/nodes/accessors/StorageTextureNode.js} +35 -10
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +103 -0
- package/{examples/jsm/nodes/accessors/TextureBicubicNode.js → src/nodes/accessors/TextureBicubic.js} +3 -32
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +123 -39
- package/src/nodes/accessors/TextureSizeNode.js +36 -0
- package/src/nodes/accessors/UV.js +3 -0
- package/{examples/jsm/nodes/accessors/UniformsNode.js → src/nodes/accessors/UniformArrayNode.js} +33 -15
- package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +9 -5
- package/{examples/jsm → src}/nodes/code/CodeNode.js +9 -5
- package/{examples/jsm → src}/nodes/code/ExpressionNode.js +10 -6
- package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +8 -5
- package/{examples/jsm → src}/nodes/code/FunctionNode.js +8 -31
- package/{examples/jsm → src}/nodes/code/ScriptableNode.js +24 -7
- package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +11 -8
- package/{examples/jsm → src}/nodes/core/AssignNode.js +12 -9
- package/{examples/jsm → src}/nodes/core/AttributeNode.js +29 -12
- package/{examples/jsm → src}/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +50 -0
- package/{examples/jsm → src}/nodes/core/ConstNode.js +6 -3
- package/{examples/jsm → src}/nodes/core/ContextNode.js +27 -11
- package/src/nodes/core/IndexNode.js +99 -0
- package/{examples/jsm → src}/nodes/core/InputNode.js +7 -3
- package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
- package/src/nodes/core/MRTNode.js +85 -0
- package/{examples/jsm → src}/nodes/core/Node.js +114 -57
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +327 -90
- package/src/nodes/core/NodeCache.js +36 -0
- package/{examples/jsm → src}/nodes/core/NodeFrame.js +52 -10
- package/{examples/jsm → src}/nodes/core/NodeFunction.js +2 -2
- package/{examples/jsm → src}/nodes/core/NodeUniform.js +1 -2
- package/{examples/jsm → src}/nodes/core/NodeUtils.js +56 -8
- package/{examples/jsm → src}/nodes/core/OutputStructNode.js +13 -12
- package/{examples/jsm → src}/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +88 -0
- package/{examples/jsm → src}/nodes/core/StackNode.js +31 -11
- package/{examples/jsm → src}/nodes/core/StructTypeNode.js +7 -3
- package/{examples/jsm → src}/nodes/core/TempNode.js +10 -6
- package/src/nodes/core/UniformGroupNode.js +59 -0
- package/{examples/jsm → src}/nodes/core/UniformNode.js +37 -5
- package/{examples/jsm → src}/nodes/core/VarNode.js +14 -14
- package/src/nodes/core/VaryingNode.js +108 -0
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +38 -28
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +33 -30
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +341 -0
- package/{examples/jsm → src}/nodes/display/BumpMapNode.js +20 -38
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +114 -0
- package/src/nodes/display/DenoiseNode.js +204 -0
- package/src/nodes/display/DepthOfFieldNode.js +124 -0
- package/src/nodes/display/DotScreenNode.js +66 -0
- package/src/nodes/display/FXAANode.js +332 -0
- package/src/nodes/display/FilmNode.js +56 -0
- package/src/nodes/display/FrontFacingNode.js +45 -0
- package/src/nodes/display/GTAONode.js +331 -0
- package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +47 -24
- package/src/nodes/display/Lut3DNode.js +57 -0
- package/src/nodes/display/MotionBlur.js +25 -0
- package/{examples/jsm → src}/nodes/display/NormalMapNode.js +14 -14
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +378 -0
- package/src/nodes/display/PixelationPassNode.js +213 -0
- package/{examples/jsm → src}/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +53 -0
- package/src/nodes/display/RenderOutputNode.js +60 -0
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +126 -0
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +67 -0
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +80 -0
- package/src/nodes/display/ViewportDepthNode.js +125 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +33 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +39 -0
- package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +20 -14
- package/src/nodes/fog/FogExp2Node.js +35 -0
- package/src/nodes/fog/FogNode.js +50 -0
- package/src/nodes/fog/FogRangeNode.js +36 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +59 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/{examples/jsm → src}/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +131 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -4
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
- package/src/nodes/functions/BasicLightingModel.js +78 -0
- package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +11 -9
- package/src/nodes/functions/PhysicalLightingModel.js +633 -0
- package/src/nodes/functions/ShadowMaskModel.js +31 -0
- package/src/nodes/functions/ToonLightingModel.js +51 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +13 -0
- package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/{examples/jsm → src}/nodes/geometry/RangeNode.js +28 -11
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +27 -0
- package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +522 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +30 -0
- package/src/nodes/lighting/BasicLightMapNode.js +32 -0
- package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +138 -0
- package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +12 -11
- package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +27 -0
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/{examples/jsm → src}/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +67 -0
- package/{examples/jsm → src}/nodes/lighting/LightingNode.js +9 -3
- package/src/nodes/lighting/LightsNode.js +250 -0
- package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +97 -0
- package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +14 -16
- package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +127 -0
- package/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +500 -603
- package/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +3 -9
- package/{examples/jsm/nodes/math/CondNode.js → src/nodes/math/ConditionalNode.js} +48 -13
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +407 -0
- package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +319 -0
- package/{examples/jsm → src}/nodes/math/TriNoise3D.js +19 -29
- package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
- package/src/nodes/pmrem/PMREMNode.js +240 -0
- package/src/nodes/pmrem/PMREMUtils.js +288 -0
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/{examples/jsm/nodes/shadernode/ShaderNode.js → src/nodes/tsl/TSLCore.js} +122 -96
- package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +9 -5
- package/{examples/jsm → src}/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +36 -0
- package/src/nodes/utils/FlipNode.js +68 -0
- package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +11 -5
- package/{examples/jsm → src}/nodes/utils/JoinNode.js +6 -3
- package/{examples/jsm → src}/nodes/utils/LoopNode.js +23 -12
- package/src/nodes/utils/MatcapUVNode.js +33 -0
- package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +16 -7
- package/{examples/jsm → src}/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +133 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +21 -5
- package/{examples/jsm → src}/nodes/utils/RemapNode.js +12 -8
- package/{examples/jsm → src}/nodes/utils/RotateNode.js +8 -13
- package/{examples/jsm → src}/nodes/utils/SetNode.js +7 -4
- package/{examples/jsm → src}/nodes/utils/SplitNode.js +7 -3
- package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +11 -12
- package/{examples/jsm → src}/nodes/utils/TimerNode.js +8 -5
- package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +302 -144
- package/src/objects/InstancedMesh.js +11 -1
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +67 -43
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +473 -224
- package/{examples/jsm → src}/renderers/common/Animation.js +3 -0
- package/{examples/jsm → src}/renderers/common/Attributes.js +4 -1
- package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
- package/{examples/jsm → src}/renderers/common/Background.js +18 -10
- package/src/renderers/common/BindGroup.js +18 -0
- package/src/renderers/common/Bindings.js +203 -0
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ChainMap.js +59 -0
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +24 -12
- package/{examples/jsm → src}/renderers/common/Color4.js +1 -1
- package/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +16 -4
- package/{examples/jsm → src}/renderers/common/Geometries.js +37 -5
- package/{examples/jsm → src}/renderers/common/Info.js +35 -15
- package/{examples/jsm → src}/renderers/common/Pipelines.js +2 -2
- package/src/renderers/common/PostProcessing.js +90 -0
- package/src/renderers/common/QuadMesh.js +55 -0
- package/src/renderers/common/RenderBundle.js +18 -0
- package/src/renderers/common/RenderBundles.js +38 -0
- package/{examples/jsm → src}/renderers/common/RenderContext.js +25 -2
- package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderList.js +11 -2
- package/src/renderers/common/RenderObject.js +413 -0
- package/{examples/jsm → src}/renderers/common/RenderObjects.js +9 -2
- package/{examples/jsm → src}/renderers/common/Renderer.js +431 -83
- package/{examples/jsm → src}/renderers/common/SampledTexture.js +14 -5
- package/{examples/jsm → src}/renderers/common/StorageBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageInstancedBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageTexture.js +2 -1
- package/{examples/jsm → src}/renderers/common/Textures.js +15 -15
- package/{examples/jsm → src}/renderers/common/Uniform.js +10 -5
- package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
- package/src/renderers/common/extras/PMREMGenerator.js +771 -0
- package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +64 -0
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +8 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeStorageBuffer.js +5 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniform.js +3 -3
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformBuffer.js +2 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformsGroup.js +2 -8
- package/{examples/jsm → src}/renderers/common/nodes/Nodes.js +106 -68
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +31 -1
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -10
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +45 -13
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +38 -25
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +3 -0
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +19 -11
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
- package/src/renderers/shaders/ShaderChunk.js +0 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +8 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/shaders/ShaderLib.js +2 -1
- package/src/renderers/shaders/UniformsLib.js +3 -0
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +42 -38
- package/src/renderers/webgl/WebGLBackground.js +24 -3
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +23 -22
- package/src/renderers/webgl/WebGLCapabilities.js +44 -13
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +7 -20
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +23 -21
- package/src/renderers/webgl/WebGLLights.js +21 -44
- package/src/renderers/webgl/WebGLMaterials.js +9 -8
- package/src/renderers/webgl/WebGLMorphtargets.js +78 -217
- package/src/renderers/webgl/WebGLProgram.js +46 -78
- package/src/renderers/webgl/WebGLPrograms.js +37 -40
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLRenderStates.js +15 -9
- package/src/renderers/webgl/WebGLShadowMap.js +25 -25
- package/src/renderers/webgl/WebGLState.js +35 -58
- package/src/renderers/webgl/WebGLTextures.js +313 -358
- package/src/renderers/webgl/WebGLUniforms.js +12 -2
- package/src/renderers/webgl/WebGLUniformsGroups.js +8 -8
- package/src/renderers/webgl/WebGLUtils.js +9 -78
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +389 -152
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +145 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +245 -44
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +7 -1
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +2 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLExtensions.js +2 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLState.js +21 -3
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +271 -43
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +6 -23
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +318 -141
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +10 -7
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +424 -95
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +37 -18
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +86 -32
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +10 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +68 -27
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +235 -68
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +43 -5
- package/src/renderers/webxr/WebXRDepthSensing.js +11 -6
- package/src/renderers/webxr/WebXRManager.js +53 -38
- package/src/scenes/Scene.js +7 -1
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/textures/Texture.js +12 -2
- package/src/utils.js +62 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/nodes/Nodes.js +0 -195
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +0 -10
- package/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -119
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -61
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -71
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +0 -21
- package/examples/jsm/nodes/accessors/MaterialNode.js +0 -314
- package/examples/jsm/nodes/accessors/ModelNode.js +0 -33
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +0 -39
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -96
- package/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -104
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
- package/examples/jsm/nodes/accessors/SkinningNode.js +0 -124
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +0 -72
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -109
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +0 -35
- package/examples/jsm/nodes/accessors/UVNode.js +0 -47
- package/examples/jsm/nodes/core/CacheNode.js +0 -49
- package/examples/jsm/nodes/core/IndexNode.js +0 -66
- package/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/examples/jsm/nodes/core/NodeKeywords.js +0 -80
- package/examples/jsm/nodes/core/PropertyNode.js +0 -72
- package/examples/jsm/nodes/core/UniformGroupNode.js +0 -36
- package/examples/jsm/nodes/core/VaryingNode.js +0 -65
- package/examples/jsm/nodes/display/BlendModeNode.js +0 -128
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +0 -99
- package/examples/jsm/nodes/display/ColorSpaceNode.js +0 -108
- package/examples/jsm/nodes/display/FrontFacingNode.js +0 -27
- package/examples/jsm/nodes/display/PassNode.js +0 -183
- package/examples/jsm/nodes/display/ToneMappingNode.js +0 -184
- package/examples/jsm/nodes/display/ViewportDepthNode.js +0 -97
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -31
- package/examples/jsm/nodes/display/ViewportNode.js +0 -134
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -31
- package/examples/jsm/nodes/fog/FogExp2Node.js +0 -35
- package/examples/jsm/nodes/fog/FogNode.js +0 -38
- package/examples/jsm/nodes/fog/FogRangeNode.js +0 -34
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +0 -40
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +0 -393
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +0 -13
- package/examples/jsm/nodes/lighting/AONode.js +0 -27
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -241
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +0 -181
- package/examples/jsm/nodes/lighting/LightNode.js +0 -57
- package/examples/jsm/nodes/lighting/LightingContextNode.js +0 -66
- package/examples/jsm/nodes/lighting/LightsNode.js +0 -188
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +0 -34
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +0 -155
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +0 -80
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -90
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +0 -130
- package/examples/jsm/nodes/math/HashNode.js +0 -34
- package/examples/jsm/nodes/math/MathNode.js +0 -391
- package/examples/jsm/nodes/math/OperatorNode.js +0 -274
- package/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
- package/examples/jsm/nodes/utils/DiscardNode.js +0 -27
- package/examples/jsm/nodes/utils/EquirectUVNode.js +0 -33
- package/examples/jsm/nodes/utils/MatcapUVNode.js +0 -30
- package/examples/jsm/nodes/utils/PackingNode.js +0 -55
- package/examples/jsm/nodes/utils/RotateUVNode.js +0 -35
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/examples/jsm/objects/QuadMesh.js +0 -66
- package/examples/jsm/renderers/common/Bindings.js +0 -173
- package/examples/jsm/renderers/common/ChainMap.js +0 -89
- package/examples/jsm/renderers/common/PostProcessing.js +0 -25
- package/examples/jsm/renderers/common/RenderObject.js +0 -221
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +0 -49
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- package/examples/jsm/utils/GPUStatsPanel.js +0 -128
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/renderers/WebGL1Renderer.js +0 -7
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
- /package/{examples/jsm → src}/nodes/core/NodeAttribute.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeCode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeFunctionInput.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeParser.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVar.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVarying.js +0 -0
- /package/{examples/jsm → src}/nodes/core/UniformGroup.js +0 -0
- /package/{examples/jsm → src}/nodes/core/constants.js +0 -0
- /package/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
- /package/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Binding.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Buffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/BufferUtils.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ComputePipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Constants.js +0 -0
- /package/{examples/jsm → src}/renderers/common/DataMap.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Pipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderLists.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderPipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Sampler.js +0 -0
- /package/{examples/jsm → src}/renderers/common/StorageBuffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/UniformBuffer.js +0 -0
- /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLCapabilities.js +0 -0
- /package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeParser.js +0 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { NoColorSpace, FloatType } from 'three';
|
|
2
|
-
|
|
3
1
|
import NodeUniformsGroup from '../../common/nodes/NodeUniformsGroup.js';
|
|
4
2
|
|
|
5
3
|
import NodeSampler from '../../common/nodes/NodeSampler.js';
|
|
6
|
-
import { NodeSampledTexture, NodeSampledCubeTexture } from '../../common/nodes/NodeSampledTexture.js';
|
|
4
|
+
import { NodeSampledTexture, NodeSampledCubeTexture, NodeSampledTexture3D } from '../../common/nodes/NodeSampledTexture.js';
|
|
7
5
|
|
|
8
6
|
import NodeUniformBuffer from '../../common/nodes/NodeUniformBuffer.js';
|
|
9
7
|
import NodeStorageBuffer from '../../common/nodes/NodeStorageBuffer.js';
|
|
@@ -13,6 +11,9 @@ import { NodeBuilder, CodeNode } from '../../../nodes/Nodes.js';
|
|
|
13
11
|
import { getFormat } from '../utils/WebGPUTextureUtils.js';
|
|
14
12
|
|
|
15
13
|
import WGSLNodeParser from './WGSLNodeParser.js';
|
|
14
|
+
import { GPUBufferBindingType, GPUStorageTextureAccess } from '../utils/WebGPUConstants.js';
|
|
15
|
+
|
|
16
|
+
import { NoColorSpace, FloatType } from '../../../constants.js';
|
|
16
17
|
|
|
17
18
|
// GPUShaderStage is not defined in browsers not supporting WebGPU
|
|
18
19
|
const GPUShaderStage = self.GPUShaderStage;
|
|
@@ -25,11 +26,12 @@ const gpuShaderStageLib = {
|
|
|
25
26
|
|
|
26
27
|
const supports = {
|
|
27
28
|
instance: true,
|
|
29
|
+
swizzleAssign: false,
|
|
28
30
|
storageBuffer: true
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
const wgslFnOpLib = {
|
|
32
|
-
'^^': '
|
|
34
|
+
'^^': 'tsl_xor'
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
const wgslTypeLib = {
|
|
@@ -70,77 +72,111 @@ const wgslTypeLib = {
|
|
|
70
72
|
bmat4: 'mat4x4<bool>'
|
|
71
73
|
};
|
|
72
74
|
|
|
75
|
+
const wgslPolyfill = {
|
|
76
|
+
tsl_xor: new CodeNode( 'fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }' ),
|
|
77
|
+
mod_float: new CodeNode( 'fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }' ),
|
|
78
|
+
mod_vec2: new CodeNode( 'fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }' ),
|
|
79
|
+
mod_vec3: new CodeNode( 'fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }' ),
|
|
80
|
+
mod_vec4: new CodeNode( 'fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }' ),
|
|
81
|
+
equals_bool: new CodeNode( 'fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }' ),
|
|
82
|
+
equals_bvec2: new CodeNode( 'fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }' ),
|
|
83
|
+
equals_bvec3: new CodeNode( 'fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }' ),
|
|
84
|
+
equals_bvec4: new CodeNode( 'fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }' ),
|
|
85
|
+
repeatWrapping: new CodeNode( `
|
|
86
|
+
fn tsl_repeatWrapping( uv : vec2<f32>, dimension : vec2<u32> ) -> vec2<u32> {
|
|
87
|
+
|
|
88
|
+
let uvScaled = vec2<u32>( uv * vec2<f32>( dimension ) );
|
|
89
|
+
|
|
90
|
+
return ( ( uvScaled % dimension ) + dimension ) % dimension;
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
` ),
|
|
94
|
+
biquadraticTexture: new CodeNode( `
|
|
95
|
+
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, level : i32 ) -> vec4f {
|
|
96
|
+
|
|
97
|
+
let iRes = vec2i( textureDimensions( map, level ) );
|
|
98
|
+
let res = vec2f( iRes );
|
|
99
|
+
|
|
100
|
+
let uvScaled = coord * res;
|
|
101
|
+
let uvWrapping = ( ( uvScaled % res ) + res ) % res;
|
|
102
|
+
|
|
103
|
+
// https://www.shadertoy.com/view/WtyXRy
|
|
104
|
+
|
|
105
|
+
let uv = uvWrapping - 0.5;
|
|
106
|
+
let iuv = floor( uv );
|
|
107
|
+
let f = fract( uv );
|
|
108
|
+
|
|
109
|
+
let rg1 = textureLoad( map, vec2i( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
|
|
110
|
+
let rg2 = textureLoad( map, vec2i( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
|
|
111
|
+
let rg3 = textureLoad( map, vec2i( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
|
|
112
|
+
let rg4 = textureLoad( map, vec2i( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
|
|
113
|
+
|
|
114
|
+
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
` )
|
|
118
|
+
};
|
|
119
|
+
|
|
73
120
|
const wgslMethods = {
|
|
74
121
|
dFdx: 'dpdx',
|
|
75
122
|
dFdy: '- dpdy',
|
|
76
|
-
mod_float: '
|
|
77
|
-
mod_vec2: '
|
|
78
|
-
mod_vec3: '
|
|
79
|
-
mod_vec4: '
|
|
80
|
-
equals_bool: '
|
|
81
|
-
equals_bvec2: '
|
|
82
|
-
equals_bvec3: '
|
|
83
|
-
equals_bvec4: '
|
|
84
|
-
lessThanEqual: 'threejs_lessThanEqual',
|
|
85
|
-
greaterThan: 'threejs_greaterThan',
|
|
123
|
+
mod_float: 'tsl_mod_float',
|
|
124
|
+
mod_vec2: 'tsl_mod_vec2',
|
|
125
|
+
mod_vec3: 'tsl_mod_vec3',
|
|
126
|
+
mod_vec4: 'tsl_mod_vec4',
|
|
127
|
+
equals_bool: 'tsl_equals_bool',
|
|
128
|
+
equals_bvec2: 'tsl_equals_bvec2',
|
|
129
|
+
equals_bvec3: 'tsl_equals_bvec3',
|
|
130
|
+
equals_bvec4: 'tsl_equals_bvec4',
|
|
86
131
|
inversesqrt: 'inverseSqrt',
|
|
87
132
|
bitcast: 'bitcast<f32>'
|
|
88
133
|
};
|
|
89
134
|
|
|
90
|
-
|
|
91
|
-
threejs_xor: new CodeNode( `
|
|
92
|
-
fn threejs_xor( a : bool, b : bool ) -> bool {
|
|
135
|
+
// WebGPU issue: does not support pow() with negative base on Windows
|
|
93
136
|
|
|
94
|
-
|
|
137
|
+
if ( /Windows/g.test( navigator.userAgent ) ) {
|
|
95
138
|
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
fn
|
|
139
|
+
wgslPolyfill.pow_float = new CodeNode( 'fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }' );
|
|
140
|
+
wgslPolyfill.pow_vec2 = new CodeNode( 'fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }', [ wgslPolyfill.pow_float ] );
|
|
141
|
+
wgslPolyfill.pow_vec3 = new CodeNode( 'fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }', [ wgslPolyfill.pow_float ] );
|
|
142
|
+
wgslPolyfill.pow_vec4 = new CodeNode( 'fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }', [ wgslPolyfill.pow_float ] );
|
|
100
143
|
|
|
101
|
-
|
|
144
|
+
wgslMethods.pow_float = 'tsl_pow_float';
|
|
145
|
+
wgslMethods.pow_vec2 = 'tsl_pow_vec2';
|
|
146
|
+
wgslMethods.pow_vec3 = 'tsl_pow_vec3';
|
|
147
|
+
wgslMethods.pow_vec4 = 'tsl_pow_vec4';
|
|
102
148
|
|
|
103
149
|
}
|
|
104
|
-
` ),
|
|
105
|
-
greaterThan: new CodeNode( `
|
|
106
|
-
fn threejs_greaterThan( a : vec3<f32>, b : vec3<f32> ) -> vec3<bool> {
|
|
107
150
|
|
|
108
|
-
|
|
151
|
+
//
|
|
109
152
|
|
|
110
|
-
|
|
111
|
-
` ),
|
|
112
|
-
mod_float: new CodeNode( 'fn threejs_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }' ),
|
|
113
|
-
mod_vec2: new CodeNode( 'fn threejs_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }' ),
|
|
114
|
-
mod_vec3: new CodeNode( 'fn threejs_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }' ),
|
|
115
|
-
mod_vec4: new CodeNode( 'fn threejs_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }' ),
|
|
116
|
-
equals_bool: new CodeNode( 'fn threejs_equals_bool( a : bool, b : bool ) -> bool { return a == b; }' ),
|
|
117
|
-
equals_bvec2: new CodeNode( 'fn threejs_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }' ),
|
|
118
|
-
equals_bvec3: new CodeNode( 'fn threejs_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }' ),
|
|
119
|
-
equals_bvec4: new CodeNode( 'fn threejs_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }' ),
|
|
120
|
-
repeatWrapping: new CodeNode( `
|
|
121
|
-
fn threejs_repeatWrapping( uv : vec2<f32>, dimension : vec2<u32> ) -> vec2<u32> {
|
|
153
|
+
let diagnostics = '';
|
|
122
154
|
|
|
123
|
-
|
|
155
|
+
if ( /Firefox/g.test( navigator.userAgent ) !== true ) {
|
|
124
156
|
|
|
125
|
-
|
|
157
|
+
diagnostics += 'diagnostic( off, derivative_uniformity );\n';
|
|
126
158
|
|
|
127
159
|
}
|
|
128
|
-
|
|
129
|
-
|
|
160
|
+
|
|
161
|
+
//
|
|
130
162
|
|
|
131
163
|
class WGSLNodeBuilder extends NodeBuilder {
|
|
132
164
|
|
|
133
|
-
constructor( object, renderer
|
|
165
|
+
constructor( object, renderer ) {
|
|
134
166
|
|
|
135
|
-
super( object, renderer, new WGSLNodeParser()
|
|
167
|
+
super( object, renderer, new WGSLNodeParser() );
|
|
136
168
|
|
|
137
169
|
this.uniformGroups = {};
|
|
138
170
|
|
|
139
171
|
this.builtins = {};
|
|
140
172
|
|
|
173
|
+
this.directives = {};
|
|
174
|
+
|
|
175
|
+
this.scopedArrays = new Map();
|
|
176
|
+
|
|
141
177
|
}
|
|
142
178
|
|
|
143
|
-
|
|
179
|
+
needsToWorkingColorSpace( texture ) {
|
|
144
180
|
|
|
145
181
|
return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace;
|
|
146
182
|
|
|
@@ -160,9 +196,13 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
160
196
|
|
|
161
197
|
}
|
|
162
198
|
|
|
199
|
+
} else if ( this.isFilteredTexture( texture ) ) {
|
|
200
|
+
|
|
201
|
+
return this.generateFilteredTexture( texture, textureProperty, uvSnippet );
|
|
202
|
+
|
|
163
203
|
} else {
|
|
164
204
|
|
|
165
|
-
return this.generateTextureLod( texture, textureProperty, uvSnippet );
|
|
205
|
+
return this.generateTextureLod( texture, textureProperty, uvSnippet, '0' );
|
|
166
206
|
|
|
167
207
|
}
|
|
168
208
|
|
|
@@ -188,6 +228,10 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
188
228
|
|
|
189
229
|
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ levelSnippet } )`;
|
|
190
230
|
|
|
231
|
+
} else if ( this.isFilteredTexture( texture ) ) {
|
|
232
|
+
|
|
233
|
+
return this.generateFilteredTexture( texture, textureProperty, uvSnippet, levelSnippet );
|
|
234
|
+
|
|
191
235
|
} else {
|
|
192
236
|
|
|
193
237
|
return this.generateTextureLod( texture, textureProperty, uvSnippet, levelSnippet );
|
|
@@ -196,13 +240,21 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
196
240
|
|
|
197
241
|
}
|
|
198
242
|
|
|
243
|
+
generateFilteredTexture( texture, textureProperty, uvSnippet, levelSnippet = '0' ) {
|
|
244
|
+
|
|
245
|
+
this._include( 'biquadraticTexture' );
|
|
246
|
+
|
|
247
|
+
return `tsl_biquadraticTexture( ${ textureProperty }, ${ uvSnippet }, i32( ${ levelSnippet } ) )`;
|
|
248
|
+
|
|
249
|
+
}
|
|
250
|
+
|
|
199
251
|
generateTextureLod( texture, textureProperty, uvSnippet, levelSnippet = '0' ) {
|
|
200
252
|
|
|
201
253
|
this._include( 'repeatWrapping' );
|
|
202
254
|
|
|
203
|
-
const dimension = `textureDimensions( ${ textureProperty }, 0 )`;
|
|
255
|
+
const dimension = texture.isMultisampleRenderTargetTexture === true ? `textureDimensions( ${ textureProperty } )` : `textureDimensions( ${ textureProperty }, 0 )`;
|
|
204
256
|
|
|
205
|
-
return `textureLoad( ${ textureProperty },
|
|
257
|
+
return `textureLoad( ${ textureProperty }, tsl_repeatWrapping( ${ uvSnippet }, ${ dimension } ), i32( ${ levelSnippet } ) )`;
|
|
206
258
|
|
|
207
259
|
}
|
|
208
260
|
|
|
@@ -228,7 +280,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
228
280
|
|
|
229
281
|
isUnfilterable( texture ) {
|
|
230
282
|
|
|
231
|
-
return texture.isDataTexture === true && texture.type === FloatType;
|
|
283
|
+
return this.getComponentTypeFromTexture( texture ) !== 'float' || ( ! this.isAvailable( 'float32Filterable' ) && texture.isDataTexture === true && texture.type === FloatType ) || texture.isMultisampleRenderTargetTexture === true;
|
|
232
284
|
|
|
233
285
|
}
|
|
234
286
|
|
|
@@ -254,6 +306,21 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
254
306
|
|
|
255
307
|
}
|
|
256
308
|
|
|
309
|
+
generateTextureGrad( texture, textureProperty, uvSnippet, gradSnippet, depthSnippet, shaderStage = this.shaderStage ) {
|
|
310
|
+
|
|
311
|
+
if ( shaderStage === 'fragment' ) {
|
|
312
|
+
|
|
313
|
+
// TODO handle i32 or u32 --> uvSnippet, array_index: A, ddx, ddy
|
|
314
|
+
return `textureSampleGrad( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ gradSnippet[ 0 ] }, ${ gradSnippet[ 1 ] } )`;
|
|
315
|
+
|
|
316
|
+
} else {
|
|
317
|
+
|
|
318
|
+
console.error( `WebGPURenderer: THREE.TextureNode.gradient() does not support ${ shaderStage } shader.` );
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
}
|
|
323
|
+
|
|
257
324
|
generateTextureCompare( texture, textureProperty, uvSnippet, compareSnippet, depthSnippet, shaderStage = this.shaderStage ) {
|
|
258
325
|
|
|
259
326
|
if ( shaderStage === 'fragment' ) {
|
|
@@ -286,6 +353,20 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
286
353
|
|
|
287
354
|
}
|
|
288
355
|
|
|
356
|
+
generateTextureBias( texture, textureProperty, uvSnippet, biasSnippet, depthSnippet, shaderStage = this.shaderStage ) {
|
|
357
|
+
|
|
358
|
+
if ( shaderStage === 'fragment' ) {
|
|
359
|
+
|
|
360
|
+
return `textureSampleBias( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ biasSnippet } )`;
|
|
361
|
+
|
|
362
|
+
} else {
|
|
363
|
+
|
|
364
|
+
console.error( `WebGPURenderer: THREE.TextureNode.biasNode does not support ${ shaderStage } shader.` );
|
|
365
|
+
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
|
|
289
370
|
getPropertyName( node, shaderStage = this.shaderStage ) {
|
|
290
371
|
|
|
291
372
|
if ( node.isNodeVarying === true && node.needsInterpolation === true ) {
|
|
@@ -301,7 +382,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
301
382
|
const name = node.name;
|
|
302
383
|
const type = node.type;
|
|
303
384
|
|
|
304
|
-
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' ) {
|
|
385
|
+
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {
|
|
305
386
|
|
|
306
387
|
return name;
|
|
307
388
|
|
|
@@ -321,6 +402,12 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
321
402
|
|
|
322
403
|
}
|
|
323
404
|
|
|
405
|
+
getOutputStructName() {
|
|
406
|
+
|
|
407
|
+
return 'output';
|
|
408
|
+
|
|
409
|
+
}
|
|
410
|
+
|
|
324
411
|
_getUniformGroupCount( shaderStage ) {
|
|
325
412
|
|
|
326
413
|
return Object.keys( this.uniforms[ shaderStage ] ).length;
|
|
@@ -343,6 +430,49 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
343
430
|
|
|
344
431
|
}
|
|
345
432
|
|
|
433
|
+
getStorageAccess( node ) {
|
|
434
|
+
|
|
435
|
+
if ( node.isStorageTextureNode ) {
|
|
436
|
+
|
|
437
|
+
switch ( node.access ) {
|
|
438
|
+
|
|
439
|
+
case GPUStorageTextureAccess.ReadOnly:
|
|
440
|
+
|
|
441
|
+
return 'read';
|
|
442
|
+
|
|
443
|
+
case GPUStorageTextureAccess.WriteOnly:
|
|
444
|
+
|
|
445
|
+
return 'write';
|
|
446
|
+
|
|
447
|
+
default:
|
|
448
|
+
|
|
449
|
+
return 'read_write';
|
|
450
|
+
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
} else {
|
|
454
|
+
|
|
455
|
+
switch ( node.access ) {
|
|
456
|
+
|
|
457
|
+
case GPUBufferBindingType.Storage:
|
|
458
|
+
|
|
459
|
+
return 'read_write';
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
case GPUBufferBindingType.ReadOnlyStorage:
|
|
463
|
+
|
|
464
|
+
return 'read';
|
|
465
|
+
|
|
466
|
+
default:
|
|
467
|
+
|
|
468
|
+
return 'write';
|
|
469
|
+
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
}
|
|
475
|
+
|
|
346
476
|
getUniformFromNode( node, type, shaderStage, name = null ) {
|
|
347
477
|
|
|
348
478
|
const uniformNode = super.getUniformFromNode( node, type, shaderStage, name );
|
|
@@ -352,28 +482,35 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
352
482
|
|
|
353
483
|
let uniformGPU;
|
|
354
484
|
|
|
355
|
-
const
|
|
485
|
+
const group = node.groupNode;
|
|
486
|
+
const groupName = group.name;
|
|
356
487
|
|
|
357
|
-
|
|
488
|
+
const bindings = this.getBindGroupArray( groupName, shaderStage );
|
|
489
|
+
|
|
490
|
+
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {
|
|
358
491
|
|
|
359
492
|
let texture = null;
|
|
360
493
|
|
|
361
494
|
if ( type === 'texture' || type === 'storageTexture' ) {
|
|
362
495
|
|
|
363
|
-
texture = new NodeSampledTexture( uniformNode.name, uniformNode.node );
|
|
496
|
+
texture = new NodeSampledTexture( uniformNode.name, uniformNode.node, group, node.access ? node.access : null );
|
|
364
497
|
|
|
365
498
|
} else if ( type === 'cubeTexture' ) {
|
|
366
499
|
|
|
367
|
-
texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node );
|
|
500
|
+
texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node, group, node.access ? node.access : null );
|
|
501
|
+
|
|
502
|
+
} else if ( type === 'texture3D' ) {
|
|
503
|
+
|
|
504
|
+
texture = new NodeSampledTexture3D( uniformNode.name, uniformNode.node, group, node.access ? node.access : null );
|
|
368
505
|
|
|
369
506
|
}
|
|
370
507
|
|
|
371
|
-
texture.store = node.
|
|
508
|
+
texture.store = node.isStorageTextureNode === true;
|
|
372
509
|
texture.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
373
510
|
|
|
374
511
|
if ( shaderStage === 'fragment' && this.isUnfilterable( node.value ) === false && texture.store === false ) {
|
|
375
512
|
|
|
376
|
-
const sampler = new NodeSampler( `${uniformNode.name}_sampler`, uniformNode.node );
|
|
513
|
+
const sampler = new NodeSampler( `${uniformNode.name}_sampler`, uniformNode.node, group );
|
|
377
514
|
sampler.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
378
515
|
|
|
379
516
|
bindings.push( sampler, texture );
|
|
@@ -391,7 +528,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
391
528
|
} else if ( type === 'buffer' || type === 'storageBuffer' ) {
|
|
392
529
|
|
|
393
530
|
const bufferClass = type === 'storageBuffer' ? NodeStorageBuffer : NodeUniformBuffer;
|
|
394
|
-
const buffer = new bufferClass( node );
|
|
531
|
+
const buffer = new bufferClass( node, group );
|
|
395
532
|
buffer.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
396
533
|
|
|
397
534
|
bindings.push( buffer );
|
|
@@ -400,9 +537,6 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
400
537
|
|
|
401
538
|
} else {
|
|
402
539
|
|
|
403
|
-
const group = node.groupNode;
|
|
404
|
-
const groupName = group.name;
|
|
405
|
-
|
|
406
540
|
const uniformsStage = this.uniformGroups[ shaderStage ] || ( this.uniformGroups[ shaderStage ] = {} );
|
|
407
541
|
|
|
408
542
|
let uniformsGroup = uniformsStage[ groupName ];
|
|
@@ -426,24 +560,12 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
426
560
|
|
|
427
561
|
nodeData.uniformGPU = uniformGPU;
|
|
428
562
|
|
|
429
|
-
if ( shaderStage === 'vertex' ) {
|
|
430
|
-
|
|
431
|
-
this.bindingsOffset[ 'fragment' ] = bindings.length;
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
|
|
435
563
|
}
|
|
436
564
|
|
|
437
565
|
return uniformNode;
|
|
438
566
|
|
|
439
567
|
}
|
|
440
568
|
|
|
441
|
-
isReference( type ) {
|
|
442
|
-
|
|
443
|
-
return super.isReference( type ) || type === 'texture_2d' || type === 'texture_cube' || type === 'texture_depth_2d' || type === 'texture_storage_2d';
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
|
|
447
569
|
getBuiltin( name, property, type, shaderStage = this.shaderStage ) {
|
|
448
570
|
|
|
449
571
|
const map = this.builtins[ shaderStage ] || ( this.builtins[ shaderStage ] = new Map() );
|
|
@@ -462,6 +584,12 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
462
584
|
|
|
463
585
|
}
|
|
464
586
|
|
|
587
|
+
hasBuiltin( name, shaderStage = this.shaderStage ) {
|
|
588
|
+
|
|
589
|
+
return ( this.builtins[ shaderStage ] !== undefined && this.builtins[ shaderStage ].has( name ) );
|
|
590
|
+
|
|
591
|
+
}
|
|
592
|
+
|
|
465
593
|
getVertexIndex() {
|
|
466
594
|
|
|
467
595
|
if ( this.shaderStage === 'vertex' ) {
|
|
@@ -489,12 +617,18 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
489
617
|
|
|
490
618
|
//
|
|
491
619
|
|
|
492
|
-
|
|
620
|
+
let code = `fn ${ layout.name }( ${ parameters.join( ', ' ) } ) -> ${ this.getType( layout.type ) } {
|
|
493
621
|
${ flowData.vars }
|
|
494
622
|
${ flowData.code }
|
|
495
|
-
|
|
623
|
+
`;
|
|
496
624
|
|
|
497
|
-
|
|
625
|
+
if ( flowData.result ) {
|
|
626
|
+
|
|
627
|
+
code += `\treturn ${ flowData.result };\n`;
|
|
628
|
+
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
code += '\n}\n';
|
|
498
632
|
|
|
499
633
|
//
|
|
500
634
|
|
|
@@ -514,6 +648,42 @@ ${ flowData.code }
|
|
|
514
648
|
|
|
515
649
|
}
|
|
516
650
|
|
|
651
|
+
getInvocationLocalIndex() {
|
|
652
|
+
|
|
653
|
+
return this.getBuiltin( 'local_invocation_index', 'invocationLocalIndex', 'u32', 'attribute' );
|
|
654
|
+
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
getSubgroupSize() {
|
|
658
|
+
|
|
659
|
+
this.enableSubGroups();
|
|
660
|
+
|
|
661
|
+
return this.getBuiltin( 'subgroup_size', 'subgroupSize', 'u32', 'attribute' );
|
|
662
|
+
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
getInvocationSubgroupIndex() {
|
|
666
|
+
|
|
667
|
+
this.enableSubGroups();
|
|
668
|
+
|
|
669
|
+
return this.getBuiltin( 'subgroup_invocation_id', 'invocationSubgroupIndex', 'u32', 'attribute' );
|
|
670
|
+
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
getSubgroupIndex() {
|
|
674
|
+
|
|
675
|
+
this.enableSubGroups();
|
|
676
|
+
|
|
677
|
+
return this.getBuiltin( 'subgroup_id', 'subgroupIndex', 'u32', 'attribute' );
|
|
678
|
+
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
getDrawIndex() {
|
|
682
|
+
|
|
683
|
+
return null;
|
|
684
|
+
|
|
685
|
+
}
|
|
686
|
+
|
|
517
687
|
getFrontFacing() {
|
|
518
688
|
|
|
519
689
|
return this.getBuiltin( 'front_facing', 'isFront', 'bool' );
|
|
@@ -538,6 +708,62 @@ ${ flowData.code }
|
|
|
538
708
|
|
|
539
709
|
}
|
|
540
710
|
|
|
711
|
+
enableDirective( name, shaderStage = this.shaderStage ) {
|
|
712
|
+
|
|
713
|
+
const stage = this.directives[ shaderStage ] || ( this.directives[ shaderStage ] = new Set() );
|
|
714
|
+
stage.add( name );
|
|
715
|
+
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
getDirectives( shaderStage ) {
|
|
719
|
+
|
|
720
|
+
const snippets = [];
|
|
721
|
+
const directives = this.directives[ shaderStage ];
|
|
722
|
+
|
|
723
|
+
if ( directives !== undefined ) {
|
|
724
|
+
|
|
725
|
+
for ( const directive of directives ) {
|
|
726
|
+
|
|
727
|
+
snippets.push( `enable ${directive};` );
|
|
728
|
+
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
return snippets.join( '\n' );
|
|
734
|
+
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
enableSubGroups() {
|
|
738
|
+
|
|
739
|
+
this.enableDirective( 'subgroups' );
|
|
740
|
+
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
enableSubgroupsF16() {
|
|
744
|
+
|
|
745
|
+
this.enableDirective( 'subgroups-f16' );
|
|
746
|
+
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
enableClipDistances() {
|
|
750
|
+
|
|
751
|
+
this.enableDirective( 'clip_distances' );
|
|
752
|
+
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
enableShaderF16() {
|
|
756
|
+
|
|
757
|
+
this.enableDirective( 'f16' );
|
|
758
|
+
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
enableDualSourceBlending() {
|
|
762
|
+
|
|
763
|
+
this.enableDirective( 'dual_source_blending' );
|
|
764
|
+
|
|
765
|
+
}
|
|
766
|
+
|
|
541
767
|
getBuiltins( shaderStage ) {
|
|
542
768
|
|
|
543
769
|
const snippets = [];
|
|
@@ -557,6 +783,45 @@ ${ flowData.code }
|
|
|
557
783
|
|
|
558
784
|
}
|
|
559
785
|
|
|
786
|
+
getScopedArray( name, scope, bufferType, bufferCount ) {
|
|
787
|
+
|
|
788
|
+
if ( this.scopedArrays.has( name ) === false ) {
|
|
789
|
+
|
|
790
|
+
this.scopedArrays.set( name, {
|
|
791
|
+
name,
|
|
792
|
+
scope,
|
|
793
|
+
bufferType,
|
|
794
|
+
bufferCount
|
|
795
|
+
} );
|
|
796
|
+
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
return name;
|
|
800
|
+
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
getScopedArrays( shaderStage ) {
|
|
804
|
+
|
|
805
|
+
if ( shaderStage !== 'compute' ) {
|
|
806
|
+
|
|
807
|
+
return;
|
|
808
|
+
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
const snippets = [];
|
|
812
|
+
|
|
813
|
+
for ( const { name, scope, bufferType, bufferCount } of this.scopedArrays.values() ) {
|
|
814
|
+
|
|
815
|
+
const type = this.getType( bufferType );
|
|
816
|
+
|
|
817
|
+
snippets.push( `var<${scope}> ${name}: array< ${type}, ${bufferCount} >;` );
|
|
818
|
+
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
return snippets.join( '\n' );
|
|
822
|
+
|
|
823
|
+
}
|
|
824
|
+
|
|
560
825
|
getAttributes( shaderStage ) {
|
|
561
826
|
|
|
562
827
|
const snippets = [];
|
|
@@ -564,6 +829,16 @@ ${ flowData.code }
|
|
|
564
829
|
if ( shaderStage === 'compute' ) {
|
|
565
830
|
|
|
566
831
|
this.getBuiltin( 'global_invocation_id', 'id', 'vec3<u32>', 'attribute' );
|
|
832
|
+
this.getBuiltin( 'workgroup_id', 'workgroupId', 'vec3<u32>', 'attribute' );
|
|
833
|
+
this.getBuiltin( 'local_invocation_id', 'localId', 'vec3<u32>', 'attribute' );
|
|
834
|
+
this.getBuiltin( 'num_workgroups', 'numWorkgroups', 'vec3<u32>', 'attribute' );
|
|
835
|
+
|
|
836
|
+
if ( this.renderer.hasFeature( 'subgroups' ) ) {
|
|
837
|
+
|
|
838
|
+
this.enableDirective( 'subgroups', shaderStage );
|
|
839
|
+
this.getBuiltin( 'subgroup_size', 'subgroupSize', 'u32', 'attribute' );
|
|
840
|
+
|
|
841
|
+
}
|
|
567
842
|
|
|
568
843
|
}
|
|
569
844
|
|
|
@@ -603,6 +878,10 @@ ${ flowData.code }
|
|
|
603
878
|
|
|
604
879
|
}
|
|
605
880
|
|
|
881
|
+
const builtins = this.getBuiltins( 'output' );
|
|
882
|
+
|
|
883
|
+
if ( builtins ) snippets.push( '\t' + builtins );
|
|
884
|
+
|
|
606
885
|
return snippets.join( ',\n' );
|
|
607
886
|
|
|
608
887
|
}
|
|
@@ -621,8 +900,11 @@ ${ flowData.code }
|
|
|
621
900
|
snippet += this.getStructMembers( struct );
|
|
622
901
|
snippet += '\n}';
|
|
623
902
|
|
|
903
|
+
|
|
624
904
|
snippets.push( snippet );
|
|
625
905
|
|
|
906
|
+
snippets.push( `\nvar<private> output : ${ name };\n\n` );
|
|
907
|
+
|
|
626
908
|
}
|
|
627
909
|
|
|
628
910
|
return snippets.join( '\n\n' );
|
|
@@ -715,23 +997,24 @@ ${ flowData.code }
|
|
|
715
997
|
const structSnippets = [];
|
|
716
998
|
const uniformGroups = {};
|
|
717
999
|
|
|
718
|
-
let index = this.bindingsOffset[ shaderStage ];
|
|
719
|
-
|
|
720
1000
|
for ( const uniform of uniforms ) {
|
|
721
1001
|
|
|
722
|
-
|
|
1002
|
+
const groupName = uniform.groupNode.name;
|
|
1003
|
+
const uniformIndexes = this.bindingsIndexes[ groupName ];
|
|
1004
|
+
|
|
1005
|
+
if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'storageTexture' || uniform.type === 'texture3D' ) {
|
|
723
1006
|
|
|
724
1007
|
const texture = uniform.node.value;
|
|
725
1008
|
|
|
726
|
-
if ( shaderStage === 'fragment' && this.isUnfilterable( texture ) === false && uniform.node.
|
|
1009
|
+
if ( shaderStage === 'fragment' && this.isUnfilterable( texture ) === false && uniform.node.isStorageTextureNode !== true ) {
|
|
727
1010
|
|
|
728
1011
|
if ( texture.isDepthTexture === true && texture.compareFunction !== null ) {
|
|
729
1012
|
|
|
730
|
-
bindingSnippets.push( `@binding( ${
|
|
1013
|
+
bindingSnippets.push( `@binding( ${ uniformIndexes.binding ++ } ) @group( ${ uniformIndexes.group } ) var ${ uniform.name }_sampler : sampler_comparison;` );
|
|
731
1014
|
|
|
732
1015
|
} else {
|
|
733
1016
|
|
|
734
|
-
bindingSnippets.push( `@binding( ${
|
|
1017
|
+
bindingSnippets.push( `@binding( ${ uniformIndexes.binding ++ } ) @group( ${ uniformIndexes.group } ) var ${ uniform.name }_sampler : sampler;` );
|
|
735
1018
|
|
|
736
1019
|
}
|
|
737
1020
|
|
|
@@ -739,35 +1022,50 @@ ${ flowData.code }
|
|
|
739
1022
|
|
|
740
1023
|
let textureType;
|
|
741
1024
|
|
|
1025
|
+
let multisampled = '';
|
|
1026
|
+
|
|
1027
|
+
if ( texture.isMultisampleRenderTargetTexture === true ) {
|
|
1028
|
+
|
|
1029
|
+
multisampled = '_multisampled';
|
|
1030
|
+
|
|
1031
|
+
}
|
|
1032
|
+
|
|
742
1033
|
if ( texture.isCubeTexture === true ) {
|
|
743
1034
|
|
|
744
1035
|
textureType = 'texture_cube<f32>';
|
|
745
1036
|
|
|
746
|
-
} else if ( texture.isDataArrayTexture === true ) {
|
|
1037
|
+
} else if ( texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
747
1038
|
|
|
748
1039
|
textureType = 'texture_2d_array<f32>';
|
|
749
1040
|
|
|
750
1041
|
} else if ( texture.isDepthTexture === true ) {
|
|
751
1042
|
|
|
752
|
-
textureType =
|
|
1043
|
+
textureType = `texture_depth${multisampled}_2d`;
|
|
753
1044
|
|
|
754
1045
|
} else if ( texture.isVideoTexture === true ) {
|
|
755
1046
|
|
|
756
1047
|
textureType = 'texture_external';
|
|
757
1048
|
|
|
758
|
-
} else if (
|
|
1049
|
+
} else if ( texture.isData3DTexture === true ) {
|
|
1050
|
+
|
|
1051
|
+
textureType = 'texture_3d<f32>';
|
|
1052
|
+
|
|
1053
|
+
} else if ( uniform.node.isStorageTextureNode === true ) {
|
|
759
1054
|
|
|
760
1055
|
const format = getFormat( texture );
|
|
1056
|
+
const access = this.getStorageAccess( uniform.node );
|
|
761
1057
|
|
|
762
|
-
textureType =
|
|
1058
|
+
textureType = `texture_storage_2d<${ format }, ${ access }>`;
|
|
763
1059
|
|
|
764
1060
|
} else {
|
|
765
1061
|
|
|
766
|
-
|
|
1062
|
+
const componentPrefix = this.getComponentTypeFromTexture( texture ).charAt( 0 );
|
|
1063
|
+
|
|
1064
|
+
textureType = `texture${multisampled}_2d<${ componentPrefix }32>`;
|
|
767
1065
|
|
|
768
1066
|
}
|
|
769
1067
|
|
|
770
|
-
bindingSnippets.push( `@binding( ${
|
|
1068
|
+
bindingSnippets.push( `@binding( ${ uniformIndexes.binding ++ } ) @group( ${ uniformIndexes.group } ) var ${ uniform.name } : ${ textureType };` );
|
|
771
1069
|
|
|
772
1070
|
} else if ( uniform.type === 'buffer' || uniform.type === 'storageBuffer' ) {
|
|
773
1071
|
|
|
@@ -776,10 +1074,11 @@ ${ flowData.code }
|
|
|
776
1074
|
const bufferCount = bufferNode.bufferCount;
|
|
777
1075
|
|
|
778
1076
|
const bufferCountSnippet = bufferCount > 0 ? ', ' + bufferCount : '';
|
|
779
|
-
const
|
|
780
|
-
const
|
|
1077
|
+
const bufferTypeSnippet = bufferNode.isAtomic ? `atomic<${bufferType}>` : `${bufferType}`;
|
|
1078
|
+
const bufferSnippet = `\t${ uniform.name } : array< ${ bufferTypeSnippet }${ bufferCountSnippet } >\n`;
|
|
1079
|
+
const bufferAccessMode = bufferNode.isStorageBufferNode ? `storage, ${ this.getStorageAccess( bufferNode ) }` : 'uniform';
|
|
781
1080
|
|
|
782
|
-
bufferSnippets.push( this._getWGSLStructBinding( 'NodeBuffer_' + bufferNode.id, bufferSnippet, bufferAccessMode,
|
|
1081
|
+
bufferSnippets.push( this._getWGSLStructBinding( 'NodeBuffer_' + bufferNode.id, bufferSnippet, bufferAccessMode, uniformIndexes.binding ++, uniformIndexes.group ) );
|
|
783
1082
|
|
|
784
1083
|
} else {
|
|
785
1084
|
|
|
@@ -787,7 +1086,8 @@ ${ flowData.code }
|
|
|
787
1086
|
const groupName = uniform.groupNode.name;
|
|
788
1087
|
|
|
789
1088
|
const group = uniformGroups[ groupName ] || ( uniformGroups[ groupName ] = {
|
|
790
|
-
index:
|
|
1089
|
+
index: uniformIndexes.binding ++,
|
|
1090
|
+
id: uniformIndexes.group,
|
|
791
1091
|
snippets: []
|
|
792
1092
|
} );
|
|
793
1093
|
|
|
@@ -801,7 +1101,7 @@ ${ flowData.code }
|
|
|
801
1101
|
|
|
802
1102
|
const group = uniformGroups[ name ];
|
|
803
1103
|
|
|
804
|
-
structSnippets.push( this._getWGSLStructBinding( name, group.snippets.join( ',\n' ), 'uniform', group.index ) );
|
|
1104
|
+
structSnippets.push( this._getWGSLStructBinding( name, group.snippets.join( ',\n' ), 'uniform', group.index, group.id ) );
|
|
805
1105
|
|
|
806
1106
|
}
|
|
807
1107
|
|
|
@@ -817,6 +1117,8 @@ ${ flowData.code }
|
|
|
817
1117
|
|
|
818
1118
|
const shadersData = this.material !== null ? { fragment: {}, vertex: {} } : { compute: {} };
|
|
819
1119
|
|
|
1120
|
+
this.sortBindingGroups();
|
|
1121
|
+
|
|
820
1122
|
for ( const shaderStage in shadersData ) {
|
|
821
1123
|
|
|
822
1124
|
const stageData = shadersData[ shaderStage ];
|
|
@@ -826,6 +1128,8 @@ ${ flowData.code }
|
|
|
826
1128
|
stageData.structs = this.getStructs( shaderStage );
|
|
827
1129
|
stageData.vars = this.getVars( shaderStage );
|
|
828
1130
|
stageData.codes = this.getCodes( shaderStage );
|
|
1131
|
+
stageData.directives = this.getDirectives( shaderStage );
|
|
1132
|
+
stageData.scopedArrays = this.getScopedArrays( shaderStage );
|
|
829
1133
|
|
|
830
1134
|
//
|
|
831
1135
|
|
|
@@ -893,6 +1197,7 @@ ${ flowData.code }
|
|
|
893
1197
|
|
|
894
1198
|
stageData.flow = flow;
|
|
895
1199
|
|
|
1200
|
+
|
|
896
1201
|
}
|
|
897
1202
|
|
|
898
1203
|
if ( this.material !== null ) {
|
|
@@ -936,7 +1241,21 @@ ${ flowData.code }
|
|
|
936
1241
|
|
|
937
1242
|
isAvailable( name ) {
|
|
938
1243
|
|
|
939
|
-
|
|
1244
|
+
let result = supports[ name ];
|
|
1245
|
+
|
|
1246
|
+
if ( result === undefined ) {
|
|
1247
|
+
|
|
1248
|
+
if ( name === 'float32Filterable' ) {
|
|
1249
|
+
|
|
1250
|
+
result = this.renderer.hasFeature( 'float32-filterable' );
|
|
1251
|
+
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
supports[ name ] = result;
|
|
1255
|
+
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
return result;
|
|
940
1259
|
|
|
941
1260
|
}
|
|
942
1261
|
|
|
@@ -970,6 +1289,8 @@ ${ flowData.code }
|
|
|
970
1289
|
_getWGSLVertexCode( shaderData ) {
|
|
971
1290
|
|
|
972
1291
|
return `${ this.getSignature() }
|
|
1292
|
+
// directives
|
|
1293
|
+
${shaderData.directives}
|
|
973
1294
|
|
|
974
1295
|
// uniforms
|
|
975
1296
|
${shaderData.uniforms}
|
|
@@ -1000,6 +1321,8 @@ fn main( ${shaderData.attributes} ) -> VaryingsStruct {
|
|
|
1000
1321
|
_getWGSLFragmentCode( shaderData ) {
|
|
1001
1322
|
|
|
1002
1323
|
return `${ this.getSignature() }
|
|
1324
|
+
// global
|
|
1325
|
+
${ diagnostics }
|
|
1003
1326
|
|
|
1004
1327
|
// uniforms
|
|
1005
1328
|
${shaderData.uniforms}
|
|
@@ -1027,9 +1350,15 @@ fn main( ${shaderData.varyings} ) -> ${shaderData.returnType} {
|
|
|
1027
1350
|
_getWGSLComputeCode( shaderData, workgroupSize ) {
|
|
1028
1351
|
|
|
1029
1352
|
return `${ this.getSignature() }
|
|
1353
|
+
// directives
|
|
1354
|
+
${shaderData.directives}
|
|
1355
|
+
|
|
1030
1356
|
// system
|
|
1031
1357
|
var<private> instanceIndex : u32;
|
|
1032
1358
|
|
|
1359
|
+
// locals
|
|
1360
|
+
${shaderData.scopedArrays}
|
|
1361
|
+
|
|
1033
1362
|
// uniforms
|
|
1034
1363
|
${shaderData.uniforms}
|
|
1035
1364
|
|
|
@@ -1040,7 +1369,7 @@ ${shaderData.codes}
|
|
|
1040
1369
|
fn main( ${shaderData.attributes} ) {
|
|
1041
1370
|
|
|
1042
1371
|
// system
|
|
1043
|
-
instanceIndex = id.x;
|
|
1372
|
+
instanceIndex = id.x + id.y * numWorkgroups.x * u32(${workgroupSize}) + id.z * numWorkgroups.x * numWorkgroups.y * u32(${workgroupSize});
|
|
1044
1373
|
|
|
1045
1374
|
// vars
|
|
1046
1375
|
${shaderData.vars}
|