super-three 0.167.0 → 0.169.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.
- package/build/three.cjs +532 -173
- package/build/three.module.js +532 -174
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +18173 -14266
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -4
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- 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 +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +97 -62
- 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 +1 -1
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- 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 +29 -8
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +27 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +40 -14
- 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/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- 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 +1 -1
- package/examples/jsm/physics/RapierPhysics.js +21 -1
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- 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/TextureUtils.js +2 -1
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +3 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +7 -0
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +32 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
- package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
- package/src/materials/Material.js +4 -7
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +53 -21
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +8 -5
- package/src/nodes/accessors/BufferNode.js +7 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/src/nodes/accessors/ClippingNode.js +19 -13
- package/src/nodes/accessors/CubeTextureNode.js +9 -8
- package/src/nodes/accessors/InstanceNode.js +19 -15
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +56 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
- package/src/nodes/accessors/ModelNode.js +47 -12
- package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
- package/src/nodes/accessors/MorphNode.js +17 -13
- package/src/nodes/accessors/Normal.js +88 -0
- package/src/nodes/accessors/Object3DNode.js +17 -33
- package/src/nodes/accessors/PointUVNode.js +9 -5
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/src/nodes/accessors/ReferenceNode.js +50 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +12 -6
- package/src/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +88 -21
- package/src/nodes/accessors/StorageBufferNode.js +22 -5
- package/src/nodes/accessors/StorageTextureNode.js +9 -6
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +16 -13
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +29 -23
- package/src/nodes/accessors/TextureSizeNode.js +10 -9
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
- package/src/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/src/nodes/accessors/VertexColorNode.js +7 -4
- package/src/nodes/code/CodeNode.js +9 -5
- package/src/nodes/code/ExpressionNode.js +10 -6
- package/src/nodes/code/FunctionCallNode.js +8 -5
- package/src/nodes/code/FunctionNode.js +8 -23
- package/src/nodes/code/ScriptableNode.js +13 -10
- package/src/nodes/code/ScriptableValueNode.js +9 -7
- package/src/nodes/core/AssignNode.js +12 -9
- package/src/nodes/core/AttributeNode.js +12 -21
- package/src/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +10 -6
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +21 -11
- package/src/nodes/core/IndexNode.js +35 -8
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +16 -7
- package/src/nodes/core/Node.js +19 -40
- package/src/nodes/core/NodeBuilder.js +117 -38
- package/src/nodes/core/NodeUtils.js +49 -6
- package/src/nodes/core/OutputStructNode.js +10 -6
- package/src/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +36 -32
- package/src/nodes/core/StackNode.js +31 -11
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +14 -11
- package/src/nodes/core/UniformNode.js +7 -4
- package/src/nodes/core/VarNode.js +12 -8
- package/src/nodes/core/VaryingNode.js +10 -6
- package/src/nodes/display/AfterImageNode.js +15 -9
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/src/nodes/display/AnamorphicNode.js +17 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +27 -19
- package/src/nodes/display/BumpMapNode.js +13 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +67 -61
- package/src/nodes/display/DenoiseNode.js +23 -17
- package/src/nodes/display/DepthOfFieldNode.js +12 -7
- package/src/nodes/display/DotScreenNode.js +13 -22
- package/src/nodes/display/FXAANode.js +21 -16
- package/src/nodes/display/FilmNode.js +11 -7
- package/src/nodes/display/FrontFacingNode.js +10 -6
- package/src/nodes/display/GTAONode.js +22 -15
- package/src/nodes/display/GaussianBlurNode.js +14 -8
- package/src/nodes/display/Lut3DNode.js +10 -6
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +13 -13
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +95 -8
- package/src/nodes/display/PixelationPassNode.js +20 -8
- package/src/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +11 -7
- package/src/nodes/display/RenderOutputNode.js +15 -11
- 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 +13 -8
- 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 +15 -175
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +12 -8
- package/src/nodes/display/ViewportDepthNode.js +34 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
- package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
- package/src/nodes/display/ViewportTextureNode.js +11 -11
- package/src/nodes/fog/FogExp2Node.js +8 -7
- package/src/nodes/fog/FogNode.js +10 -8
- package/src/nodes/fog/FogRangeNode.js +8 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +34 -33
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +9 -5
- 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/src/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +225 -36
- package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
- package/src/nodes/lighting/BasicLightMapNode.js +7 -4
- package/src/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +23 -19
- package/src/nodes/lighting/HemisphereLightNode.js +11 -11
- package/src/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +19 -18
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +112 -75
- package/src/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +11 -11
- package/src/nodes/lighting/SpotLightNode.js +14 -16
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +38 -10
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +127 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +97 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +61 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/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 +9 -6
- package/src/nodes/utils/FlipNode.js +68 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +16 -6
- package/src/nodes/utils/MatcapUVNode.js +10 -7
- package/src/nodes/utils/MaxMipLevelNode.js +8 -5
- package/src/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +11 -8
- package/src/nodes/utils/ReflectorNode.js +12 -4
- package/src/nodes/utils/RemapNode.js +12 -8
- package/src/nodes/utils/RotateNode.js +8 -13
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +11 -12
- package/src/nodes/utils/TimerNode.js +8 -5
- package/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 +78 -13
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +88 -41
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +15 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +23 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +117 -6
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +128 -94
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +19 -22
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +65 -19
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +3 -1
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +83 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
- package/src/renderers/webgpu/WebGPUBackend.js +112 -86
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +9 -6
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +7 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
- package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/src/utils.js +33 -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/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/accessors/CameraNode.js +0 -19
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/display/ViewportNode.js +0 -137
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -8,23 +8,24 @@ import BRDF_Sheen from './BSDF/BRDF_Sheen.js';
|
|
|
8
8
|
import { LTC_Evaluate, LTC_Uv } from './BSDF/LTC.js';
|
|
9
9
|
import LightingModel from '../core/LightingModel.js';
|
|
10
10
|
import { diffuseColor, specularColor, specularF90, roughness, clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, ior, thickness, transmission, attenuationDistance, attenuationColor, dispersion } from '../core/PropertyNode.js';
|
|
11
|
-
import { transformedNormalView, transformedClearcoatNormalView, transformedNormalWorld } from '../accessors/
|
|
12
|
-
import { positionViewDirection, positionView, positionWorld } from '../accessors/
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import { transformedNormalView, transformedClearcoatNormalView, transformedNormalWorld } from '../accessors/Normal.js';
|
|
12
|
+
import { positionViewDirection, positionView, positionWorld } from '../accessors/Position.js';
|
|
13
|
+
import { Fn, float, vec2, vec3, vec4, mat3, If } from '../tsl/TSLBase.js';
|
|
14
|
+
import { select } from '../math/ConditionalNode.js';
|
|
15
15
|
import { mix, normalize, refract, length, clamp, log2, log, exp, smoothstep } from '../math/MathNode.js';
|
|
16
16
|
import { div } from '../math/OperatorNode.js';
|
|
17
|
-
import { cameraPosition, cameraProjectionMatrix, cameraViewMatrix } from '../accessors/
|
|
17
|
+
import { cameraPosition, cameraProjectionMatrix, cameraViewMatrix } from '../accessors/Camera.js';
|
|
18
18
|
import { modelWorldMatrix } from '../accessors/ModelNode.js';
|
|
19
|
-
import {
|
|
19
|
+
import { screenSize } from '../display/ScreenNode.js';
|
|
20
20
|
import { viewportMipTexture } from '../display/ViewportTextureNode.js';
|
|
21
|
-
import {
|
|
21
|
+
import { textureBicubic } from '../accessors/TextureBicubic.js';
|
|
22
|
+
import { Loop } from '../utils/LoopNode.js';
|
|
22
23
|
|
|
23
24
|
//
|
|
24
25
|
// Transmission
|
|
25
26
|
//
|
|
26
27
|
|
|
27
|
-
const getVolumeTransmissionRay =
|
|
28
|
+
const getVolumeTransmissionRay = /*@__PURE__*/ Fn( ( [ n, v, thickness, ior, modelMatrix ] ) => {
|
|
28
29
|
|
|
29
30
|
// Direction of refracted light.
|
|
30
31
|
const refractionVector = vec3( refract( v.negate(), normalize( n ), div( 1.0, ior ) ) );
|
|
@@ -51,7 +52,7 @@ const getVolumeTransmissionRay = tslFn( ( [ n, v, thickness, ior, modelMatrix ]
|
|
|
51
52
|
]
|
|
52
53
|
} );
|
|
53
54
|
|
|
54
|
-
const applyIorToRoughness =
|
|
55
|
+
const applyIorToRoughness = /*@__PURE__*/ Fn( ( [ roughness, ior ] ) => {
|
|
55
56
|
|
|
56
57
|
// Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
|
|
57
58
|
// an IOR of 1.5 results in the default amount of microfacet refraction.
|
|
@@ -66,20 +67,20 @@ const applyIorToRoughness = tslFn( ( [ roughness, ior ] ) => {
|
|
|
66
67
|
]
|
|
67
68
|
} );
|
|
68
69
|
|
|
69
|
-
const singleViewportMipTexture = viewportMipTexture();
|
|
70
|
+
const singleViewportMipTexture = /*@__PURE__*/ viewportMipTexture();
|
|
70
71
|
|
|
71
|
-
const getTransmissionSample =
|
|
72
|
+
const getTransmissionSample = /*@__PURE__*/ Fn( ( [ fragCoord, roughness, ior ] ) => {
|
|
72
73
|
|
|
73
74
|
const transmissionSample = singleViewportMipTexture.uv( fragCoord );
|
|
74
75
|
//const transmissionSample = viewportMipTexture( fragCoord );
|
|
75
76
|
|
|
76
|
-
const lod = log2( float(
|
|
77
|
+
const lod = log2( float( screenSize.x ) ).mul( applyIorToRoughness( roughness, ior ) );
|
|
77
78
|
|
|
78
|
-
return
|
|
79
|
+
return textureBicubic( transmissionSample, lod );
|
|
79
80
|
|
|
80
81
|
} );
|
|
81
82
|
|
|
82
|
-
const volumeAttenuation =
|
|
83
|
+
const volumeAttenuation = /*@__PURE__*/ Fn( ( [ transmissionDistance, attenuationColor, attenuationDistance ] ) => {
|
|
83
84
|
|
|
84
85
|
If( attenuationDistance.notEqual( 0 ), () => {
|
|
85
86
|
|
|
@@ -104,7 +105,7 @@ const volumeAttenuation = tslFn( ( [ transmissionDistance, attenuationColor, att
|
|
|
104
105
|
]
|
|
105
106
|
} );
|
|
106
107
|
|
|
107
|
-
const getIBLVolumeRefraction =
|
|
108
|
+
const getIBLVolumeRefraction = /*@__PURE__*/ Fn( ( [ n, v, roughness, diffuseColor, specularColor, specularF90, position, modelMatrix, viewMatrix, projMatrix, ior, thickness, attenuationColor, attenuationDistance, dispersion ] ) => {
|
|
108
109
|
|
|
109
110
|
let transmittedLight, transmittance;
|
|
110
111
|
|
|
@@ -116,7 +117,7 @@ const getIBLVolumeRefraction = tslFn( ( [ n, v, roughness, diffuseColor, specula
|
|
|
116
117
|
const halfSpread = ior.sub( 1.0 ).mul( dispersion.mul( 0.025 ) );
|
|
117
118
|
const iors = vec3( ior.sub( halfSpread ), ior, ior.add( halfSpread ) );
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
Loop( { start: 0, end: 3 }, ( { i } ) => {
|
|
120
121
|
|
|
121
122
|
const ior = iors.element( i );
|
|
122
123
|
|
|
@@ -184,7 +185,7 @@ const getIBLVolumeRefraction = tslFn( ( [ n, v, roughness, diffuseColor, specula
|
|
|
184
185
|
//
|
|
185
186
|
|
|
186
187
|
// XYZ to linear-sRGB color space
|
|
187
|
-
const XYZ_TO_REC709 = mat3(
|
|
188
|
+
const XYZ_TO_REC709 = /*@__PURE__*/ mat3(
|
|
188
189
|
3.2404542, - 0.9692660, 0.0556434,
|
|
189
190
|
- 1.5371385, 1.8760108, - 0.2040259,
|
|
190
191
|
- 0.4985314, 0.0415560, 1.0572252
|
|
@@ -227,7 +228,7 @@ const evalSensitivity = ( OPD, shift ) => {
|
|
|
227
228
|
|
|
228
229
|
};
|
|
229
230
|
|
|
230
|
-
const evalIridescence =
|
|
231
|
+
const evalIridescence = /*@__PURE__*/ Fn( ( { outsideIOR, eta2, cosTheta1, thinFilmThickness, baseF0 } ) => {
|
|
231
232
|
|
|
232
233
|
// Force iridescenceIOR -> outsideIOR when thinFilmThickness -> 0.0
|
|
233
234
|
const iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
|
@@ -249,7 +250,7 @@ const evalIridescence = tslFn( ( { outsideIOR, eta2, cosTheta1, thinFilmThicknes
|
|
|
249
250
|
const R12 = F_Schlick( { f0: R0, f90: 1.0, dotVH: cosTheta1 } );
|
|
250
251
|
//const R21 = R12;
|
|
251
252
|
const T121 = R12.oneMinus();
|
|
252
|
-
const phi12 = iridescenceIOR.lessThan( outsideIOR ).
|
|
253
|
+
const phi12 = iridescenceIOR.lessThan( outsideIOR ).select( Math.PI, 0.0 );
|
|
253
254
|
const phi21 = float( Math.PI ).sub( phi12 );
|
|
254
255
|
|
|
255
256
|
// Second interface
|
|
@@ -257,9 +258,9 @@ const evalIridescence = tslFn( ( { outsideIOR, eta2, cosTheta1, thinFilmThicknes
|
|
|
257
258
|
const R1 = IorToFresnel0( baseIOR, iridescenceIOR.toVec3() );
|
|
258
259
|
const R23 = F_Schlick( { f0: R1, f90: 1.0, dotVH: cosTheta2 } );
|
|
259
260
|
const phi23 = vec3(
|
|
260
|
-
baseIOR.x.lessThan( iridescenceIOR ).
|
|
261
|
-
baseIOR.y.lessThan( iridescenceIOR ).
|
|
262
|
-
baseIOR.z.lessThan( iridescenceIOR ).
|
|
261
|
+
baseIOR.x.lessThan( iridescenceIOR ).select( Math.PI, 0.0 ),
|
|
262
|
+
baseIOR.y.lessThan( iridescenceIOR ).select( Math.PI, 0.0 ),
|
|
263
|
+
baseIOR.z.lessThan( iridescenceIOR ).select( Math.PI, 0.0 )
|
|
263
264
|
);
|
|
264
265
|
|
|
265
266
|
// Phase shift
|
|
@@ -307,25 +308,25 @@ const evalIridescence = tslFn( ( { outsideIOR, eta2, cosTheta1, thinFilmThicknes
|
|
|
307
308
|
// This is a curve-fit approxmation to the "Charlie sheen" BRDF integrated over the hemisphere from
|
|
308
309
|
// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF". The analysis can be found
|
|
309
310
|
// in the Sheen section of https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
|
|
310
|
-
const IBLSheenBRDF =
|
|
311
|
+
const IBLSheenBRDF = /*@__PURE__*/ Fn( ( { normal, viewDir, roughness } ) => {
|
|
311
312
|
|
|
312
313
|
const dotNV = normal.dot( viewDir ).saturate();
|
|
313
314
|
|
|
314
315
|
const r2 = roughness.pow2();
|
|
315
316
|
|
|
316
|
-
const a =
|
|
317
|
+
const a = select(
|
|
317
318
|
roughness.lessThan( 0.25 ),
|
|
318
319
|
float( - 339.2 ).mul( r2 ).add( float( 161.4 ).mul( roughness ) ).sub( 25.9 ),
|
|
319
320
|
float( - 8.48 ).mul( r2 ).add( float( 14.3 ).mul( roughness ) ).sub( 9.95 )
|
|
320
321
|
);
|
|
321
322
|
|
|
322
|
-
const b =
|
|
323
|
+
const b = select(
|
|
323
324
|
roughness.lessThan( 0.25 ),
|
|
324
325
|
float( 44.0 ).mul( r2 ).sub( float( 23.7 ).mul( roughness ) ).add( 3.26 ),
|
|
325
326
|
float( 1.97 ).mul( r2 ).sub( float( 3.27 ).mul( roughness ) ).add( 0.72 )
|
|
326
327
|
);
|
|
327
328
|
|
|
328
|
-
const DG =
|
|
329
|
+
const DG = select( roughness.lessThan( 0.25 ), 0.0, float( 0.1 ).mul( roughness ).sub( 0.025 ) ).add( a.mul( dotNV ).add( b ).exp() );
|
|
329
330
|
|
|
330
331
|
return DG.mul( 1.0 / Math.PI ).saturate();
|
|
331
332
|
|
|
@@ -363,16 +364,16 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
363
364
|
|
|
364
365
|
if ( this.clearcoat === true ) {
|
|
365
366
|
|
|
366
|
-
this.clearcoatRadiance = vec3().
|
|
367
|
-
this.clearcoatSpecularDirect = vec3().
|
|
368
|
-
this.clearcoatSpecularIndirect = vec3().
|
|
367
|
+
this.clearcoatRadiance = vec3().toVar( 'clearcoatRadiance' );
|
|
368
|
+
this.clearcoatSpecularDirect = vec3().toVar( 'clearcoatSpecularDirect' );
|
|
369
|
+
this.clearcoatSpecularIndirect = vec3().toVar( 'clearcoatSpecularIndirect' );
|
|
369
370
|
|
|
370
371
|
}
|
|
371
372
|
|
|
372
373
|
if ( this.sheen === true ) {
|
|
373
374
|
|
|
374
|
-
this.sheenSpecularDirect = vec3().
|
|
375
|
-
this.sheenSpecularIndirect = vec3().
|
|
375
|
+
this.sheenSpecularDirect = vec3().toVar( 'sheenSpecularDirect' );
|
|
376
|
+
this.sheenSpecularIndirect = vec3().toVar( 'sheenSpecularIndirect' );
|
|
376
377
|
|
|
377
378
|
}
|
|
378
379
|
|
|
@@ -553,8 +554,8 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
553
554
|
|
|
554
555
|
// Both indirect specular and indirect diffuse light accumulate here
|
|
555
556
|
|
|
556
|
-
const singleScattering = vec3().
|
|
557
|
-
const multiScattering = vec3().
|
|
557
|
+
const singleScattering = vec3().toVar( 'singleScattering' );
|
|
558
|
+
const multiScattering = vec3().toVar( 'multiScattering' );
|
|
558
559
|
const cosineWeightedIrradiance = iblIrradiance.mul( 1 / Math.PI );
|
|
559
560
|
|
|
560
561
|
this.computeMultiscattering( singleScattering, multiScattering, specularF90 );
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import LightingModel from '../core/LightingModel.js';
|
|
2
2
|
import BRDF_Lambert from './BSDF/BRDF_Lambert.js';
|
|
3
3
|
import { diffuseColor } from '../core/PropertyNode.js';
|
|
4
|
-
import { normalGeometry } from '../accessors/
|
|
5
|
-
import {
|
|
4
|
+
import { normalGeometry } from '../accessors/Normal.js';
|
|
5
|
+
import { Fn, float, vec2, vec3 } from '../tsl/TSLBase.js';
|
|
6
6
|
import { mix, smoothstep } from '../math/MathNode.js';
|
|
7
7
|
import { materialReference } from '../accessors/MaterialReferenceNode.js';
|
|
8
8
|
|
|
9
|
-
const getGradientIrradiance =
|
|
9
|
+
const getGradientIrradiance = /*@__PURE__*/ Fn( ( { normal, lightDirection, builder } ) => {
|
|
10
10
|
|
|
11
11
|
// dotNL will be from -1.0 to 1.0
|
|
12
12
|
const dotNL = normal.dot( lightDirection );
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { normalView } from '../../accessors/Normal.js';
|
|
2
|
+
import { Fn } from '../../tsl/TSLBase.js';
|
|
3
3
|
|
|
4
|
-
const getGeometryRoughness =
|
|
4
|
+
const getGeometryRoughness = /*@__PURE__*/ Fn( () => {
|
|
5
5
|
|
|
6
|
-
const dxy =
|
|
6
|
+
const dxy = normalView.dFdx().abs().max( normalView.dFdy().abs() );
|
|
7
7
|
const geometryRoughness = dxy.x.max( dxy.y ).max( dxy.z );
|
|
8
8
|
|
|
9
9
|
return geometryRoughness;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import getGeometryRoughness from './getGeometryRoughness.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Fn } from '../../tsl/TSLBase.js';
|
|
3
3
|
|
|
4
|
-
const getRoughness =
|
|
4
|
+
const getRoughness = /*@__PURE__*/ Fn( ( inputs ) => {
|
|
5
5
|
|
|
6
6
|
const { roughness } = inputs;
|
|
7
7
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Fn, mul } from '../../tsl/TSLBase.js';
|
|
2
|
+
|
|
3
|
+
const getShIrradianceAt = /*@__PURE__*/ Fn( ( [ normal, shCoefficients ] ) => {
|
|
4
|
+
|
|
5
|
+
// normal is assumed to have unit length
|
|
6
|
+
|
|
7
|
+
const x = normal.x, y = normal.y, z = normal.z;
|
|
8
|
+
|
|
9
|
+
// band 0
|
|
10
|
+
let result = shCoefficients.element( 0 ).mul( 0.886227 );
|
|
11
|
+
|
|
12
|
+
// band 1
|
|
13
|
+
result = result.add( shCoefficients.element( 1 ).mul( 2.0 * 0.511664 ).mul( y ) );
|
|
14
|
+
result = result.add( shCoefficients.element( 2 ).mul( 2.0 * 0.511664 ).mul( z ) );
|
|
15
|
+
result = result.add( shCoefficients.element( 3 ).mul( 2.0 * 0.511664 ).mul( x ) );
|
|
16
|
+
|
|
17
|
+
// band 2
|
|
18
|
+
result = result.add( shCoefficients.element( 4 ).mul( 2.0 * 0.429043 ).mul( x ).mul( y ) );
|
|
19
|
+
result = result.add( shCoefficients.element( 5 ).mul( 2.0 * 0.429043 ).mul( y ).mul( z ) );
|
|
20
|
+
result = result.add( shCoefficients.element( 6 ).mul( z.mul( z ).mul( 0.743125 ).sub( 0.247708 ) ) );
|
|
21
|
+
result = result.add( shCoefficients.element( 7 ).mul( 2.0 * 0.429043 ).mul( x ).mul( z ) );
|
|
22
|
+
result = result.add( shCoefficients.element( 8 ).mul( 0.429043 ).mul( mul( x, x ).sub( mul( y, y ) ) ) );
|
|
23
|
+
|
|
24
|
+
return result;
|
|
25
|
+
|
|
26
|
+
} );
|
|
27
|
+
|
|
28
|
+
export default getShIrradianceAt;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
import { getValueType } from '../core/NodeUtils.js';
|
|
3
3
|
import { buffer } from '../accessors/BufferNode.js';
|
|
4
4
|
import { instancedBufferAttribute } from '../accessors/BufferAttributeNode.js';
|
|
5
5
|
import { instanceIndex } from '../core/IndexNode.js';
|
|
6
|
-
import { nodeProxy, float } from '../
|
|
6
|
+
import { nodeProxy, float } from '../tsl/TSLBase.js';
|
|
7
7
|
|
|
8
8
|
import { Vector4 } from '../../math/Vector4.js';
|
|
9
9
|
import { MathUtils } from '../../math/MathUtils.js';
|
|
@@ -14,6 +14,12 @@ let max = null;
|
|
|
14
14
|
|
|
15
15
|
class RangeNode extends Node {
|
|
16
16
|
|
|
17
|
+
static get type() {
|
|
18
|
+
|
|
19
|
+
return 'RangeNode';
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
constructor( minNode = float(), maxNode = float() ) {
|
|
18
24
|
|
|
19
25
|
super();
|
|
@@ -112,6 +118,4 @@ class RangeNode extends Node {
|
|
|
112
118
|
|
|
113
119
|
export default RangeNode;
|
|
114
120
|
|
|
115
|
-
export const range = nodeProxy( RangeNode );
|
|
116
|
-
|
|
117
|
-
addNodeClass( 'RangeNode', RangeNode );
|
|
121
|
+
export const range = /*@__PURE__*/ nodeProxy( RangeNode );
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { nodeProxy } from '../tsl/TSLCore.js';
|
|
3
|
+
|
|
4
|
+
class AtomicFunctionNode extends TempNode {
|
|
5
|
+
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'AtomicFunctionNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
constructor( method, pointerNode, valueNode, storeNode = null ) {
|
|
13
|
+
|
|
14
|
+
super( 'uint' );
|
|
15
|
+
|
|
16
|
+
this.method = method;
|
|
17
|
+
|
|
18
|
+
this.pointerNode = pointerNode;
|
|
19
|
+
this.valueNode = valueNode;
|
|
20
|
+
this.storeNode = storeNode;
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getInputType( builder ) {
|
|
25
|
+
|
|
26
|
+
return this.pointerNode.getNodeType( builder );
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getNodeType( builder ) {
|
|
31
|
+
|
|
32
|
+
return this.getInputType( builder );
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
generate( builder ) {
|
|
37
|
+
|
|
38
|
+
const method = this.method;
|
|
39
|
+
|
|
40
|
+
const type = this.getNodeType( builder );
|
|
41
|
+
const inputType = this.getInputType( builder );
|
|
42
|
+
|
|
43
|
+
const a = this.pointerNode;
|
|
44
|
+
const b = this.valueNode;
|
|
45
|
+
|
|
46
|
+
const params = [];
|
|
47
|
+
|
|
48
|
+
params.push( `&${ a.build( builder, inputType ) }` );
|
|
49
|
+
params.push( b.build( builder, inputType ) );
|
|
50
|
+
|
|
51
|
+
const methodSnippet = `${ builder.getMethod( method, type ) }( ${params.join( ', ' )} )`;
|
|
52
|
+
|
|
53
|
+
if ( this.storeNode !== null ) {
|
|
54
|
+
|
|
55
|
+
const varSnippet = this.storeNode.build( builder, inputType );
|
|
56
|
+
|
|
57
|
+
builder.addLineFlowCode( `${varSnippet} = ${methodSnippet}`, this );
|
|
58
|
+
|
|
59
|
+
} else {
|
|
60
|
+
|
|
61
|
+
builder.addLineFlowCode( methodSnippet, this );
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
AtomicFunctionNode.ATOMIC_LOAD = 'atomicLoad';
|
|
70
|
+
AtomicFunctionNode.ATOMIC_STORE = 'atomicStore';
|
|
71
|
+
AtomicFunctionNode.ATOMIC_ADD = 'atomicAdd';
|
|
72
|
+
AtomicFunctionNode.ATOMIC_SUB = 'atomicSub';
|
|
73
|
+
AtomicFunctionNode.ATOMIC_MAX = 'atomicMax';
|
|
74
|
+
AtomicFunctionNode.ATOMIC_MIN = 'atomicMin';
|
|
75
|
+
AtomicFunctionNode.ATOMIC_AND = 'atomicAnd';
|
|
76
|
+
AtomicFunctionNode.ATOMIC_OR = 'atomicOr';
|
|
77
|
+
AtomicFunctionNode.ATOMIC_XOR = 'atomicXor';
|
|
78
|
+
|
|
79
|
+
export default AtomicFunctionNode;
|
|
80
|
+
|
|
81
|
+
const atomicNode = nodeProxy( AtomicFunctionNode );
|
|
82
|
+
|
|
83
|
+
export const atomicFunc = ( method, pointerNode, valueNode, storeNode ) => {
|
|
84
|
+
|
|
85
|
+
const node = atomicNode( method, pointerNode, valueNode, storeNode );
|
|
86
|
+
node.append();
|
|
87
|
+
|
|
88
|
+
return node;
|
|
89
|
+
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const atomicStore = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_STORE, pointerNode, valueNode, storeNode );
|
|
93
|
+
export const atomicAdd = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_ADD, pointerNode, valueNode, storeNode );
|
|
94
|
+
export const atomicSub = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_SUB, pointerNode, valueNode, storeNode );
|
|
95
|
+
export const atomicMax = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_MAX, pointerNode, valueNode, storeNode );
|
|
96
|
+
export const atomicMin = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_MIN, pointerNode, valueNode, storeNode );
|
|
97
|
+
export const atomicAnd = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_AND, pointerNode, valueNode, storeNode );
|
|
98
|
+
export const atomicOr = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_OR, pointerNode, valueNode, storeNode );
|
|
99
|
+
export const atomicXor = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_XOR, pointerNode, valueNode, storeNode );
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
|
+
import { nodeProxy } from '../tsl/TSLCore.js';
|
|
3
|
+
|
|
4
|
+
class BarrierNode extends Node {
|
|
5
|
+
|
|
6
|
+
constructor( scope ) {
|
|
7
|
+
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
this.scope = scope;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
generate( builder ) {
|
|
15
|
+
|
|
16
|
+
const { scope } = this;
|
|
17
|
+
const { renderer } = builder;
|
|
18
|
+
|
|
19
|
+
if ( renderer.backend.isWebGLBackend === true ) {
|
|
20
|
+
|
|
21
|
+
builder.addFlowCode( `\t// ${scope}Barrier \n` );
|
|
22
|
+
|
|
23
|
+
} else {
|
|
24
|
+
|
|
25
|
+
builder.addLineFlowCode( `${scope}Barrier()`, this );
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default BarrierNode;
|
|
34
|
+
|
|
35
|
+
const barrier = nodeProxy( BarrierNode );
|
|
36
|
+
|
|
37
|
+
export const workgroupBarrier = () => barrier( 'workgroup' ).append();
|
|
38
|
+
export const storageBarrier = () => barrier( 'storage' ).append();
|
|
39
|
+
export const textureBarrier = () => barrier( 'texture' ).append();
|
|
40
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
|
+
import { nodeObject } from '../tsl/TSLBase.js';
|
|
3
|
+
|
|
4
|
+
class ComputeBuiltinNode extends Node {
|
|
5
|
+
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'ComputeBuiltinNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
constructor( builtinName, nodeType ) {
|
|
13
|
+
|
|
14
|
+
super( nodeType );
|
|
15
|
+
|
|
16
|
+
this._builtinName = builtinName;
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getHash( builder ) {
|
|
21
|
+
|
|
22
|
+
return this.getBuiltinName( builder );
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getNodeType( /*builder*/ ) {
|
|
27
|
+
|
|
28
|
+
return this.nodeType;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
setBuiltinName( builtinName ) {
|
|
33
|
+
|
|
34
|
+
this._builtinName = builtinName;
|
|
35
|
+
|
|
36
|
+
return this;
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getBuiltinName( /*builder*/ ) {
|
|
41
|
+
|
|
42
|
+
return this._builtinName;
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
hasBuiltin( builder ) {
|
|
47
|
+
|
|
48
|
+
builder.hasBuiltin( this._builtinName );
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
generate( builder, output ) {
|
|
53
|
+
|
|
54
|
+
const builtinName = this.getBuiltinName( builder );
|
|
55
|
+
const nodeType = this.getNodeType( builder );
|
|
56
|
+
|
|
57
|
+
if ( builder.shaderStage === 'compute' ) {
|
|
58
|
+
|
|
59
|
+
return builder.format( builtinName, nodeType, output );
|
|
60
|
+
|
|
61
|
+
} else {
|
|
62
|
+
|
|
63
|
+
console.warn( `ComputeBuiltinNode: Compute built-in value ${builtinName} can not be accessed in the ${builder.shaderStage} stage` );
|
|
64
|
+
return builder.generateConst( nodeType );
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
serialize( data ) {
|
|
71
|
+
|
|
72
|
+
super.serialize( data );
|
|
73
|
+
|
|
74
|
+
data.global = this.global;
|
|
75
|
+
data._builtinName = this._builtinName;
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
deserialize( data ) {
|
|
80
|
+
|
|
81
|
+
super.deserialize( data );
|
|
82
|
+
|
|
83
|
+
this.global = data.global;
|
|
84
|
+
this._builtinName = data._builtinName;
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default ComputeBuiltinNode;
|
|
91
|
+
|
|
92
|
+
const computeBuiltin = ( name, nodeType ) => nodeObject( new ComputeBuiltinNode( name, nodeType ) );
|
|
93
|
+
|
|
94
|
+
export const numWorkgroups = /*@__PURE__*/ computeBuiltin( 'numWorkgroups', 'uvec3' );
|
|
95
|
+
export const workgroupId = /*@__PURE__*/ computeBuiltin( 'workgroupId', 'uvec3' );
|
|
96
|
+
export const localId = /*@__PURE__*/ computeBuiltin( 'localId', 'uvec3' );
|
|
97
|
+
export const subgroupSize = /*@__PURE__*/ computeBuiltin( 'subgroupSize', 'uint' );
|
|
98
|
+
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
|
-
import {
|
|
3
|
+
import { addMethodChaining, nodeObject } from '../tsl/TSLCore.js';
|
|
4
4
|
|
|
5
5
|
class ComputeNode extends Node {
|
|
6
6
|
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'ComputeNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
constructor( computeNode, count, workgroupSize = [ 64 ] ) {
|
|
8
14
|
|
|
9
15
|
super( 'void' );
|
|
@@ -66,7 +72,7 @@ class ComputeNode extends Node {
|
|
|
66
72
|
|
|
67
73
|
if ( snippet !== '' ) {
|
|
68
74
|
|
|
69
|
-
builder.addLineFlowCode( snippet );
|
|
75
|
+
builder.addLineFlowCode( snippet, this );
|
|
70
76
|
|
|
71
77
|
}
|
|
72
78
|
|
|
@@ -80,6 +86,4 @@ export default ComputeNode;
|
|
|
80
86
|
|
|
81
87
|
export const compute = ( node, count, workgroupSize ) => nodeObject( new ComputeNode( nodeObject( node ), count, workgroupSize ) );
|
|
82
88
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
addNodeClass( 'ComputeNode', ComputeNode );
|
|
89
|
+
addMethodChaining( 'compute', compute );
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import ArrayElementNode from '../utils/ArrayElementNode.js';
|
|
2
|
+
import { nodeObject } from '../tsl/TSLCore.js';
|
|
3
|
+
import Node from '../core/Node.js';
|
|
4
|
+
|
|
5
|
+
class WorkgroupInfoElementNode extends ArrayElementNode {
|
|
6
|
+
|
|
7
|
+
constructor( workgroupInfoNode, indexNode ) {
|
|
8
|
+
|
|
9
|
+
super( workgroupInfoNode, indexNode );
|
|
10
|
+
|
|
11
|
+
this.isWorkgroupInfoElementNode = true;
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
generate( builder, output ) {
|
|
16
|
+
|
|
17
|
+
let snippet;
|
|
18
|
+
|
|
19
|
+
const isAssignContext = builder.context.assign;
|
|
20
|
+
snippet = super.generate( builder );
|
|
21
|
+
|
|
22
|
+
if ( isAssignContext !== true ) {
|
|
23
|
+
|
|
24
|
+
const type = this.getNodeType( builder );
|
|
25
|
+
|
|
26
|
+
snippet = builder.format( snippet, type, output );
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// TODO: Possibly activate clip distance index on index access rather than from clipping context
|
|
31
|
+
|
|
32
|
+
return snippet;
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class WorkgroupInfoNode extends Node {
|
|
40
|
+
|
|
41
|
+
constructor( scope, bufferType, bufferCount = 0 ) {
|
|
42
|
+
|
|
43
|
+
super( bufferType );
|
|
44
|
+
|
|
45
|
+
this.bufferType = bufferType;
|
|
46
|
+
this.bufferCount = bufferCount;
|
|
47
|
+
|
|
48
|
+
this.isWorkgroupInfoNode = true;
|
|
49
|
+
|
|
50
|
+
this.scope = scope;
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
label( name ) {
|
|
55
|
+
|
|
56
|
+
this.name = name;
|
|
57
|
+
|
|
58
|
+
return this;
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getHash() {
|
|
63
|
+
|
|
64
|
+
return this.uuid;
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setScope( scope ) {
|
|
69
|
+
|
|
70
|
+
this.scope = scope;
|
|
71
|
+
|
|
72
|
+
return this;
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getInputType( /*builder*/ ) {
|
|
77
|
+
|
|
78
|
+
return `${this.scope}Array`;
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
element( indexNode ) {
|
|
83
|
+
|
|
84
|
+
return nodeObject( new WorkgroupInfoElementNode( this, indexNode ) );
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
generate( builder ) {
|
|
89
|
+
|
|
90
|
+
return builder.getScopedArray( this.name || `${this.scope}Array_${this.id}`, this.scope.toLowerCase(), this.bufferType, this.bufferCount );
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default WorkgroupInfoNode;
|
|
97
|
+
|
|
98
|
+
export const workgroupArray = ( type, count ) => nodeObject( new WorkgroupInfoNode( 'Workgroup', type, count ) );
|
|
99
|
+
|
|
100
|
+
|