super-three 0.165.0 → 0.168.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 +854 -410
- package/build/three.module.js +849 -411
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +77755 -0
- package/build/three.webgpu.min.js +6 -0
- package/examples/jsm/Addons.js +5 -2
- 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 +453 -452
- 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 +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +13 -4
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/helpers/ViewHelper.js +51 -2
- package/examples/jsm/libs/tween.module.js +64 -75
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/webgpu/Line2.js +20 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
- package/examples/jsm/loaders/FBXLoader.js +23 -45
- package/examples/jsm/loaders/GLTFLoader.js +10 -4
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +10 -10
- package/examples/jsm/loaders/PCDLoader.js +9 -9
- package/examples/jsm/loaders/USDZLoader.js +124 -76
- package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
- package/examples/jsm/loaders/VTKLoader.js +76 -3
- package/examples/jsm/misc/GPUComputationRenderer.js +9 -19
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -1
- package/examples/jsm/objects/InstancedPoints.js +2 -2
- package/examples/jsm/objects/SkyMesh.js +188 -0
- package/examples/jsm/objects/Water2Mesh.js +159 -0
- package/examples/jsm/objects/WaterMesh.js +102 -0
- package/examples/jsm/physics/RapierPhysics.js +20 -0
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/RenderTransitionPass.js +13 -38
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/postprocessing/SSAOPass.js +6 -9
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
- 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 +46 -4
- package/examples/jsm/transpiler/TSLEncoder.js +24 -22
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +8 -6
- package/src/Three.WebGPU.js +200 -0
- package/src/Three.js +3 -0
- package/src/constants.js +4 -1
- package/src/core/Object3D.js +22 -22
- package/src/extras/Controls.js +32 -0
- package/src/extras/TextureUtils.js +210 -0
- 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/ObjectLoader.js +33 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeLoader.js +6 -4
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeMaterialLoader.js +2 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeObjectLoader.js +2 -1
- package/src/materials/Material.js +7 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/InstancedPointsNodeMaterial.js +36 -27
- package/{examples/jsm/nodes/materials → src/materials/nodes}/Line2NodeMaterial.js +37 -40
- package/src/materials/nodes/LineBasicNodeMaterial.js +27 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/LineDashedNodeMaterial.js +10 -11
- package/src/materials/nodes/MeshBasicNodeMaterial.js +73 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +43 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +53 -0
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +74 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshPhysicalNodeMaterial.js +22 -20
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshStandardNodeMaterial.js +28 -11
- package/src/materials/nodes/MeshToonNodeMaterial.js +34 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/NodeMaterial.js +142 -96
- package/{examples/jsm/nodes/materials/Materials.js → src/materials/nodes/NodeMaterials.js} +1 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/PointsNodeMaterial.js +5 -6
- package/src/materials/nodes/ShadowNodeMaterial.js +34 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/SpriteNodeMaterial.js +13 -13
- package/{examples/jsm/nodes/materials → src/materials/nodes}/VolumeNodeMaterial.js +14 -16
- 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/Vector4.js +13 -0
- package/src/nodes/Nodes.js +164 -0
- package/src/nodes/TSL.js +176 -0
- package/{examples/jsm → src}/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +124 -0
- package/{examples/jsm/nodes/accessors/BitangentNode.js → src/nodes/accessors/Bitangent.js} +9 -9
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +41 -6
- package/{examples/jsm → src}/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/Camera.js +19 -0
- package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +76 -0
- package/src/nodes/accessors/InstanceNode.js +144 -0
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialNode.js +66 -49
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +37 -0
- package/{examples/jsm → src}/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +35 -31
- package/src/nodes/accessors/Normal.js +62 -0
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +11 -11
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +14 -8
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/{examples/jsm → src}/nodes/accessors/RendererReferenceNode.js +6 -6
- package/{examples/jsm → src}/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +187 -0
- package/{examples/jsm → src}/nodes/accessors/StorageBufferNode.js +54 -6
- package/{examples/jsm → src}/nodes/accessors/StorageTextureNode.js +16 -7
- package/src/nodes/accessors/Tangent.js +22 -0
- package/{examples/jsm → src}/nodes/accessors/Texture3DNode.js +11 -11
- package/{examples/jsm/nodes/accessors/TextureBicubicNode.js → src/nodes/accessors/TextureBicubic.js} +3 -32
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +69 -37
- package/{examples/jsm → src}/nodes/accessors/TextureSizeNode.js +4 -6
- package/{examples/jsm/nodes/accessors/UniformsNode.js → src/nodes/accessors/UniformArrayNode.js} +24 -9
- package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +6 -5
- package/{examples/jsm → src}/nodes/code/CodeNode.js +5 -5
- package/{examples/jsm → src}/nodes/code/ExpressionNode.js +4 -4
- package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +5 -5
- package/{examples/jsm → src}/nodes/code/FunctionNode.js +5 -23
- package/{examples/jsm → src}/nodes/code/ScriptableNode.js +18 -6
- package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +6 -7
- package/{examples/jsm → src}/nodes/core/AssignNode.js +5 -5
- package/{examples/jsm → src}/nodes/core/AttributeNode.js +22 -21
- package/{examples/jsm → src}/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +46 -0
- package/{examples/jsm → src}/nodes/core/ConstNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/ContextNode.js +17 -11
- package/{examples/jsm → src}/nodes/core/IndexNode.js +17 -6
- package/{examples/jsm → src}/nodes/core/InputNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
- package/src/nodes/core/MRTNode.js +82 -0
- package/{examples/jsm → src}/nodes/core/Node.js +57 -31
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +216 -65
- package/src/nodes/core/NodeCache.js +36 -0
- package/{examples/jsm → src}/nodes/core/NodeFrame.js +42 -0
- 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 +7 -1
- package/{examples/jsm → src}/nodes/core/OutputStructNode.js +4 -4
- package/{examples/jsm → src}/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +84 -0
- package/{examples/jsm → src}/nodes/core/StackNode.js +26 -10
- package/{examples/jsm → src}/nodes/core/StructTypeNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/TempNode.js +4 -4
- package/src/nodes/core/UniformGroupNode.js +55 -0
- package/{examples/jsm → src}/nodes/core/UniformNode.js +14 -5
- package/{examples/jsm → src}/nodes/core/VarNode.js +8 -12
- package/{examples/jsm → src}/nodes/core/VaryingNode.js +13 -5
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +27 -35
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +27 -30
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +335 -0
- package/{examples/jsm → src}/nodes/display/BumpMapNode.js +7 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +85 -0
- package/src/nodes/display/DenoiseNode.js +201 -0
- package/src/nodes/display/DepthOfFieldNode.js +121 -0
- package/src/nodes/display/DotScreenNode.js +63 -0
- package/src/nodes/display/FXAANode.js +329 -0
- package/src/nodes/display/FilmNode.js +53 -0
- package/src/nodes/display/FrontFacingNode.js +41 -0
- package/src/nodes/display/GTAONode.js +328 -0
- package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +44 -24
- package/src/nodes/display/Lut3DNode.js +54 -0
- package/src/nodes/display/MotionBlur.js +25 -0
- package/{examples/jsm → src}/nodes/display/NormalMapNode.js +9 -11
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +367 -0
- package/src/nodes/display/PixelationPassNode.js +206 -0
- package/{examples/jsm → src}/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +50 -0
- package/src/nodes/display/RenderOutputNode.js +56 -0
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +123 -0
- package/src/nodes/display/StereoCompositePassNode.js +107 -0
- package/src/nodes/display/StereoPassNode.js +80 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +66 -0
- package/src/nodes/display/TransitionNode.js +77 -0
- package/src/nodes/display/ViewportDepthNode.js +121 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +30 -0
- package/{examples/jsm → src}/nodes/display/ViewportNode.js +28 -26
- package/src/nodes/display/ViewportSharedTextureNode.js +36 -0
- package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +12 -12
- package/{examples/jsm → src}/nodes/fog/FogExp2Node.js +4 -6
- package/{examples/jsm → src}/nodes/fog/FogNode.js +5 -7
- package/{examples/jsm → src}/nodes/fog/FogRangeNode.js +4 -6
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- 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/{examples/jsm → src}/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- 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 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +78 -0
- package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +10 -8
- package/{examples/jsm → src}/nodes/functions/PhysicalLightingModel.js +73 -31
- package/{examples/jsm → src}/nodes/functions/ShadowMaskModel.js +1 -1
- package/{examples/jsm → src}/nodes/functions/ToonLightingModel.js +6 -4
- package/src/nodes/functions/material/getGeometryRoughness.js +13 -0
- package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +2 -2
- package/{examples/jsm → src}/nodes/geometry/RangeNode.js +23 -10
- package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +24 -0
- package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +354 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +27 -0
- package/src/nodes/lighting/BasicLightMapNode.js +29 -0
- package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +3 -9
- package/{examples/jsm → src}/nodes/lighting/EnvironmentNode.js +23 -21
- package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +4 -7
- package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +3 -8
- package/{examples/jsm → src}/nodes/lighting/IrradianceNode.js +2 -2
- package/{examples/jsm → src}/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/{examples/jsm → src}/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +64 -0
- package/{examples/jsm → src}/nodes/lighting/LightingNode.js +4 -2
- package/src/nodes/lighting/LightsNode.js +231 -0
- package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +4 -10
- package/src/nodes/lighting/RectAreaLightNode.js +93 -0
- package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +4 -10
- package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +2 -2
- package/{examples/jsm → src}/nodes/materialx/lib/mx_hsv.js +43 -46
- 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} +31 -13
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +404 -0
- package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -7
- package/{examples/jsm → src}/nodes/math/OperatorNode.js +100 -58
- package/{examples/jsm → src}/nodes/math/TriNoise3D.js +19 -29
- package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
- package/{examples/jsm → src}/nodes/pmrem/PMREMNode.js +60 -16
- package/{examples/jsm → src}/nodes/pmrem/PMREMUtils.js +46 -46
- 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} +106 -96
- package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/{examples/jsm → src}/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +7 -5
- package/{examples/jsm → src}/nodes/utils/JoinNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/LoopNode.js +19 -12
- package/{examples/jsm → src}/nodes/utils/MatcapUVNode.js +6 -6
- package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +12 -6
- package/{examples/jsm → src}/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +130 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +17 -4
- package/{examples/jsm → src}/nodes/utils/RemapNode.js +7 -7
- package/{examples/jsm → src}/nodes/utils/RotateNode.js +4 -12
- package/{examples/jsm → src}/nodes/utils/SetNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/SplitNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +4 -6
- package/{examples/jsm → src}/nodes/utils/TimerNode.js +5 -5
- package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +7 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +169 -190
- package/src/objects/InstancedMesh.js +1 -1
- package/src/renderers/WebGLRenderer.js +60 -23
- package/{examples/jsm → src}/renderers/common/Attributes.js +2 -1
- package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
- package/{examples/jsm → src}/renderers/common/Background.js +12 -4
- package/src/renderers/common/BindGroup.js +18 -0
- package/{examples/jsm → src}/renderers/common/Bindings.js +45 -32
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +18 -7
- 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 +34 -6
- package/src/renderers/common/PostProcessing.js +90 -0
- package/{examples/jsm/objects → src/renderers/common}/QuadMesh.js +8 -3
- package/{examples/jsm → src}/renderers/common/RenderContext.js +25 -1
- package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderList.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderObject.js +45 -12
- package/{examples/jsm → src}/renderers/common/Renderer.js +151 -73
- package/{examples/jsm → src}/renderers/common/SampledTexture.js +14 -5
- package/src/renderers/common/StandardRenderer.js +18 -0
- 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 +14 -14
- package/{examples/jsm → src}/renderers/common/Uniform.js +9 -4
- package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
- package/{examples/jsm → src}/renderers/common/extras/PMREMGenerator.js +25 -25
- package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampledTexture.js +8 -7
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +2 -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 +69 -21
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +16 -1
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +1 -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/packing.glsl.js +45 -13
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -4
- 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 +2 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +8 -0
- package/src/renderers/shaders/UniformsLib.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -2
- package/src/renderers/webgl/WebGLBufferRenderer.js +6 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +6 -18
- package/src/renderers/webgl/WebGLLights.js +6 -0
- package/src/renderers/webgl/WebGLProgram.js +27 -1
- package/src/renderers/webgl/WebGLPrograms.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +75 -57
- package/src/renderers/webgl/WebGLUniforms.js +12 -2
- package/src/renderers/webgl/WebGLUniformsGroups.js +7 -7
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +242 -120
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +227 -44
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +2 -2
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +1 -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 +22 -1
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +62 -23
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +1 -1
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +242 -136
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +9 -9
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +281 -107
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +64 -33
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +4 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +34 -36
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +76 -44
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +42 -4
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -0
- package/src/renderers/webxr/WebXRManager.js +37 -24
- package/src/textures/CompressedArrayTexture.js +1 -1
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/nodes/Nodes.js +0 -202
- package/examples/jsm/nodes/accessors/BatchNode.js +0 -78
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -12
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -61
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -94
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +0 -21
- package/examples/jsm/nodes/accessors/ModelNode.js +0 -36
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -14
- package/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -10
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -6
- package/examples/jsm/nodes/accessors/SkinningNode.js +0 -124
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -23
- package/examples/jsm/nodes/core/CacheNode.js +0 -49
- 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 -83
- package/examples/jsm/nodes/core/UniformGroupNode.js +0 -36
- 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 -40
- package/examples/jsm/nodes/display/PassNode.js +0 -201
- package/examples/jsm/nodes/display/ToneMappingNode.js +0 -188
- package/examples/jsm/nodes/display/ViewportDepthNode.js +0 -97
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -31
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -37
- 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 -256
- package/examples/jsm/nodes/lighting/LightingContextNode.js +0 -66
- package/examples/jsm/nodes/lighting/LightsNode.js +0 -215
- 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/MeshMatcapNodeMaterial.js +0 -52
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -38
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
- package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +0 -34
- package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +0 -34
- package/examples/jsm/nodes/math/HashNode.js +0 -34
- package/examples/jsm/nodes/math/MathNode.js +0 -391
- package/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
- package/examples/jsm/nodes/utils/DiscardNode.js +0 -27
- package/examples/jsm/nodes/utils/PackingNode.js +0 -55
- package/examples/jsm/nodes/utils/RotateUVNode.js +0 -35
- package/examples/jsm/renderers/common/PostProcessing.js +0 -33
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- /package/{examples/jsm/nodes/accessors/UVNode.js → src/nodes/accessors/UV.js} +0 -0
- /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/Animation.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/ChainMap.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/Pipelines.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderBundle.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderBundles.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderLists.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderObjects.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}/WebGLBufferRenderer.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,5 +1,3 @@
|
|
|
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';
|
|
@@ -13,8 +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';
|
|
16
|
-
import { GPUStorageTextureAccess } from '../utils/WebGPUConstants.js';
|
|
14
|
+
import { GPUBufferBindingType, GPUStorageTextureAccess } from '../utils/WebGPUConstants.js';
|
|
17
15
|
|
|
16
|
+
import { NoColorSpace, FloatType } from '../../../constants.js';
|
|
18
17
|
|
|
19
18
|
// GPUShaderStage is not defined in browsers not supporting WebGPU
|
|
20
19
|
const GPUShaderStage = self.GPUShaderStage;
|
|
@@ -27,11 +26,12 @@ const gpuShaderStageLib = {
|
|
|
27
26
|
|
|
28
27
|
const supports = {
|
|
29
28
|
instance: true,
|
|
29
|
+
swizzleAssign: false,
|
|
30
30
|
storageBuffer: true
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
const wgslFnOpLib = {
|
|
34
|
-
'^^': '
|
|
34
|
+
'^^': 'tsl_xor'
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
const wgslTypeLib = {
|
|
@@ -72,77 +72,98 @@ const wgslTypeLib = {
|
|
|
72
72
|
bmat4: 'mat4x4<bool>'
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
const wgslMethods = {
|
|
76
|
-
dFdx: 'dpdx',
|
|
77
|
-
dFdy: '- dpdy',
|
|
78
|
-
mod_float: 'threejs_mod_float',
|
|
79
|
-
mod_vec2: 'threejs_mod_vec2',
|
|
80
|
-
mod_vec3: 'threejs_mod_vec3',
|
|
81
|
-
mod_vec4: 'threejs_mod_vec4',
|
|
82
|
-
equals_bool: 'threejs_equals_bool',
|
|
83
|
-
equals_bvec2: 'threejs_equals_bvec2',
|
|
84
|
-
equals_bvec3: 'threejs_equals_bvec3',
|
|
85
|
-
equals_bvec4: 'threejs_equals_bvec4',
|
|
86
|
-
lessThanEqual: 'threejs_lessThanEqual',
|
|
87
|
-
greaterThan: 'threejs_greaterThan',
|
|
88
|
-
inversesqrt: 'inverseSqrt',
|
|
89
|
-
bitcast: 'bitcast<f32>'
|
|
90
|
-
};
|
|
91
|
-
|
|
92
75
|
const wgslPolyfill = {
|
|
93
|
-
|
|
94
|
-
fn
|
|
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> {
|
|
95
87
|
|
|
96
|
-
|
|
88
|
+
let uvScaled = vec2<u32>( uv * vec2<f32>( dimension ) );
|
|
89
|
+
|
|
90
|
+
return ( ( uvScaled % dimension ) + dimension ) % dimension;
|
|
97
91
|
|
|
98
92
|
}
|
|
99
93
|
` ),
|
|
100
|
-
|
|
101
|
-
fn
|
|
94
|
+
biquadraticTexture: new CodeNode( `
|
|
95
|
+
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, level : i32 ) -> vec4f {
|
|
102
96
|
|
|
103
|
-
|
|
97
|
+
let res = vec2f( textureDimensions( map, level ) );
|
|
104
98
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
greaterThan: new CodeNode( `
|
|
108
|
-
fn threejs_greaterThan( a : vec3<f32>, b : vec3<f32> ) -> vec3<bool> {
|
|
99
|
+
let uvScaled = coord * res;
|
|
100
|
+
let uvWrapping = ( ( uvScaled % res ) + res ) % res;
|
|
109
101
|
|
|
110
|
-
|
|
102
|
+
// https://www.shadertoy.com/view/WtyXRy
|
|
111
103
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
mod_vec2: new CodeNode( 'fn threejs_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }' ),
|
|
116
|
-
mod_vec3: new CodeNode( 'fn threejs_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }' ),
|
|
117
|
-
mod_vec4: new CodeNode( 'fn threejs_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }' ),
|
|
118
|
-
equals_bool: new CodeNode( 'fn threejs_equals_bool( a : bool, b : bool ) -> bool { return a == b; }' ),
|
|
119
|
-
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 ); }' ),
|
|
120
|
-
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 ); }' ),
|
|
121
|
-
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 ); }' ),
|
|
122
|
-
repeatWrapping: new CodeNode( `
|
|
123
|
-
fn threejs_repeatWrapping( uv : vec2<f32>, dimension : vec2<u32> ) -> vec2<u32> {
|
|
104
|
+
let uv = uvWrapping - 0.5;
|
|
105
|
+
let iuv = floor( uv );
|
|
106
|
+
let f = fract( uv );
|
|
124
107
|
|
|
125
|
-
let
|
|
108
|
+
let rg1 = textureLoad( map, vec2i( iuv + vec2( 0.5, 0.5 ) ), level );
|
|
109
|
+
let rg2 = textureLoad( map, vec2i( iuv + vec2( 1.5, 0.5 ) ), level );
|
|
110
|
+
let rg3 = textureLoad( map, vec2i( iuv + vec2( 0.5, 1.5 ) ), level );
|
|
111
|
+
let rg4 = textureLoad( map, vec2i( iuv + vec2( 1.5, 1.5 ) ), level );
|
|
126
112
|
|
|
127
|
-
return ( (
|
|
113
|
+
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
128
114
|
|
|
129
115
|
}
|
|
130
116
|
` )
|
|
131
117
|
};
|
|
132
118
|
|
|
119
|
+
const wgslMethods = {
|
|
120
|
+
dFdx: 'dpdx',
|
|
121
|
+
dFdy: '- dpdy',
|
|
122
|
+
mod_float: 'tsl_mod_float',
|
|
123
|
+
mod_vec2: 'tsl_mod_vec2',
|
|
124
|
+
mod_vec3: 'tsl_mod_vec3',
|
|
125
|
+
mod_vec4: 'tsl_mod_vec4',
|
|
126
|
+
equals_bool: 'tsl_equals_bool',
|
|
127
|
+
equals_bvec2: 'tsl_equals_bvec2',
|
|
128
|
+
equals_bvec3: 'tsl_equals_bvec3',
|
|
129
|
+
equals_bvec4: 'tsl_equals_bvec4',
|
|
130
|
+
inversesqrt: 'inverseSqrt',
|
|
131
|
+
bitcast: 'bitcast<f32>'
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// WebGPU issue: does not support pow() with negative base on Windows
|
|
135
|
+
|
|
136
|
+
if ( /Windows/g.test( navigator.userAgent ) ) {
|
|
137
|
+
|
|
138
|
+
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 ); }' );
|
|
139
|
+
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 ] );
|
|
140
|
+
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 ] );
|
|
141
|
+
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 ] );
|
|
142
|
+
|
|
143
|
+
wgslMethods.pow_float = 'tsl_pow_float';
|
|
144
|
+
wgslMethods.pow_vec2 = 'tsl_pow_vec2';
|
|
145
|
+
wgslMethods.pow_vec3 = 'tsl_pow_vec3';
|
|
146
|
+
wgslMethods.pow_vec4 = 'tsl_pow_vec4';
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
//
|
|
151
|
+
|
|
133
152
|
class WGSLNodeBuilder extends NodeBuilder {
|
|
134
153
|
|
|
135
|
-
constructor( object, renderer
|
|
154
|
+
constructor( object, renderer ) {
|
|
136
155
|
|
|
137
|
-
super( object, renderer, new WGSLNodeParser()
|
|
156
|
+
super( object, renderer, new WGSLNodeParser() );
|
|
138
157
|
|
|
139
158
|
this.uniformGroups = {};
|
|
140
159
|
|
|
141
160
|
this.builtins = {};
|
|
142
161
|
|
|
162
|
+
this.directives = {};
|
|
163
|
+
|
|
143
164
|
}
|
|
144
165
|
|
|
145
|
-
|
|
166
|
+
needsToWorkingColorSpace( texture ) {
|
|
146
167
|
|
|
147
168
|
return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace;
|
|
148
169
|
|
|
@@ -162,9 +183,13 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
162
183
|
|
|
163
184
|
}
|
|
164
185
|
|
|
186
|
+
} else if ( this.isFilteredTexture( texture ) ) {
|
|
187
|
+
|
|
188
|
+
return this.generateFilteredTexture( texture, textureProperty, uvSnippet );
|
|
189
|
+
|
|
165
190
|
} else {
|
|
166
191
|
|
|
167
|
-
return this.generateTextureLod( texture, textureProperty, uvSnippet );
|
|
192
|
+
return this.generateTextureLod( texture, textureProperty, uvSnippet, '0' );
|
|
168
193
|
|
|
169
194
|
}
|
|
170
195
|
|
|
@@ -190,6 +215,10 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
190
215
|
|
|
191
216
|
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ levelSnippet } )`;
|
|
192
217
|
|
|
218
|
+
} else if ( this.isFilteredTexture( texture ) ) {
|
|
219
|
+
|
|
220
|
+
return this.generateFilteredTexture( texture, textureProperty, uvSnippet, levelSnippet );
|
|
221
|
+
|
|
193
222
|
} else {
|
|
194
223
|
|
|
195
224
|
return this.generateTextureLod( texture, textureProperty, uvSnippet, levelSnippet );
|
|
@@ -198,13 +227,21 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
198
227
|
|
|
199
228
|
}
|
|
200
229
|
|
|
230
|
+
generateFilteredTexture( texture, textureProperty, uvSnippet, levelSnippet = '0' ) {
|
|
231
|
+
|
|
232
|
+
this._include( 'biquadraticTexture' );
|
|
233
|
+
|
|
234
|
+
return `tsl_biquadraticTexture( ${ textureProperty }, ${ uvSnippet }, i32( ${ levelSnippet } ) )`;
|
|
235
|
+
|
|
236
|
+
}
|
|
237
|
+
|
|
201
238
|
generateTextureLod( texture, textureProperty, uvSnippet, levelSnippet = '0' ) {
|
|
202
239
|
|
|
203
240
|
this._include( 'repeatWrapping' );
|
|
204
241
|
|
|
205
|
-
const dimension = `textureDimensions( ${ textureProperty }, 0 )`;
|
|
242
|
+
const dimension = texture.isMultisampleRenderTargetTexture === true ? `textureDimensions( ${ textureProperty } )` : `textureDimensions( ${ textureProperty }, 0 )`;
|
|
206
243
|
|
|
207
|
-
return `textureLoad( ${ textureProperty },
|
|
244
|
+
return `textureLoad( ${ textureProperty }, tsl_repeatWrapping( ${ uvSnippet }, ${ dimension } ), i32( ${ levelSnippet } ) )`;
|
|
208
245
|
|
|
209
246
|
}
|
|
210
247
|
|
|
@@ -230,7 +267,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
230
267
|
|
|
231
268
|
isUnfilterable( texture ) {
|
|
232
269
|
|
|
233
|
-
return this.getComponentTypeFromTexture( texture ) !== 'float' || ( texture.isDataTexture === true && texture.type === FloatType );
|
|
270
|
+
return this.getComponentTypeFromTexture( texture ) !== 'float' || ( ! this.isAvailable( 'float32Filterable' ) && texture.isDataTexture === true && texture.type === FloatType ) || texture.isMultisampleRenderTargetTexture === true;
|
|
234
271
|
|
|
235
272
|
}
|
|
236
273
|
|
|
@@ -303,6 +340,20 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
303
340
|
|
|
304
341
|
}
|
|
305
342
|
|
|
343
|
+
generateTextureBias( texture, textureProperty, uvSnippet, biasSnippet, depthSnippet, shaderStage = this.shaderStage ) {
|
|
344
|
+
|
|
345
|
+
if ( shaderStage === 'fragment' ) {
|
|
346
|
+
|
|
347
|
+
return `textureSampleBias( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ biasSnippet } )`;
|
|
348
|
+
|
|
349
|
+
} else {
|
|
350
|
+
|
|
351
|
+
console.error( `WebGPURenderer: THREE.TextureNode.biasNode does not support ${ shaderStage } shader.` );
|
|
352
|
+
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
}
|
|
356
|
+
|
|
306
357
|
getPropertyName( node, shaderStage = this.shaderStage ) {
|
|
307
358
|
|
|
308
359
|
if ( node.isNodeVarying === true && node.needsInterpolation === true ) {
|
|
@@ -372,30 +423,38 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
372
423
|
|
|
373
424
|
switch ( node.access ) {
|
|
374
425
|
|
|
375
|
-
case GPUStorageTextureAccess.ReadOnly:
|
|
426
|
+
case GPUStorageTextureAccess.ReadOnly:
|
|
376
427
|
|
|
377
428
|
return 'read';
|
|
378
429
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
case GPUStorageTextureAccess.WriteOnly: {
|
|
430
|
+
case GPUStorageTextureAccess.WriteOnly:
|
|
382
431
|
|
|
383
432
|
return 'write';
|
|
384
433
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
default: {
|
|
434
|
+
default:
|
|
388
435
|
|
|
389
436
|
return 'read_write';
|
|
390
437
|
|
|
391
|
-
}
|
|
392
|
-
|
|
393
438
|
}
|
|
394
439
|
|
|
395
440
|
} else {
|
|
396
441
|
|
|
397
|
-
|
|
398
|
-
|
|
442
|
+
switch ( node.access ) {
|
|
443
|
+
|
|
444
|
+
case GPUBufferBindingType.Storage:
|
|
445
|
+
|
|
446
|
+
return 'read_write';
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
case GPUBufferBindingType.ReadOnlyStorage:
|
|
450
|
+
|
|
451
|
+
return 'read';
|
|
452
|
+
|
|
453
|
+
default:
|
|
454
|
+
|
|
455
|
+
return 'write';
|
|
456
|
+
|
|
457
|
+
}
|
|
399
458
|
|
|
400
459
|
}
|
|
401
460
|
|
|
@@ -410,7 +469,10 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
410
469
|
|
|
411
470
|
let uniformGPU;
|
|
412
471
|
|
|
413
|
-
const
|
|
472
|
+
const group = node.groupNode;
|
|
473
|
+
const groupName = group.name;
|
|
474
|
+
|
|
475
|
+
const bindings = this.getBindGroupArray( groupName, shaderStage );
|
|
414
476
|
|
|
415
477
|
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {
|
|
416
478
|
|
|
@@ -418,15 +480,15 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
418
480
|
|
|
419
481
|
if ( type === 'texture' || type === 'storageTexture' ) {
|
|
420
482
|
|
|
421
|
-
texture = new NodeSampledTexture( uniformNode.name, uniformNode.node, node.access ? node.access : null );
|
|
483
|
+
texture = new NodeSampledTexture( uniformNode.name, uniformNode.node, group, node.access ? node.access : null );
|
|
422
484
|
|
|
423
485
|
} else if ( type === 'cubeTexture' ) {
|
|
424
486
|
|
|
425
|
-
texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node, node.access ? node.access : null );
|
|
487
|
+
texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node, group, node.access ? node.access : null );
|
|
426
488
|
|
|
427
489
|
} else if ( type === 'texture3D' ) {
|
|
428
490
|
|
|
429
|
-
texture = new NodeSampledTexture3D( uniformNode.name, uniformNode.node, node.access ? node.access : null );
|
|
491
|
+
texture = new NodeSampledTexture3D( uniformNode.name, uniformNode.node, group, node.access ? node.access : null );
|
|
430
492
|
|
|
431
493
|
}
|
|
432
494
|
|
|
@@ -435,7 +497,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
435
497
|
|
|
436
498
|
if ( shaderStage === 'fragment' && this.isUnfilterable( node.value ) === false && texture.store === false ) {
|
|
437
499
|
|
|
438
|
-
const sampler = new NodeSampler( `${uniformNode.name}_sampler`, uniformNode.node );
|
|
500
|
+
const sampler = new NodeSampler( `${uniformNode.name}_sampler`, uniformNode.node, group );
|
|
439
501
|
sampler.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
440
502
|
|
|
441
503
|
bindings.push( sampler, texture );
|
|
@@ -453,7 +515,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
453
515
|
} else if ( type === 'buffer' || type === 'storageBuffer' ) {
|
|
454
516
|
|
|
455
517
|
const bufferClass = type === 'storageBuffer' ? NodeStorageBuffer : NodeUniformBuffer;
|
|
456
|
-
const buffer = new bufferClass( node );
|
|
518
|
+
const buffer = new bufferClass( node, group );
|
|
457
519
|
buffer.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
458
520
|
|
|
459
521
|
bindings.push( buffer );
|
|
@@ -462,9 +524,6 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
462
524
|
|
|
463
525
|
} else {
|
|
464
526
|
|
|
465
|
-
const group = node.groupNode;
|
|
466
|
-
const groupName = group.name;
|
|
467
|
-
|
|
468
527
|
const uniformsStage = this.uniformGroups[ shaderStage ] || ( this.uniformGroups[ shaderStage ] = {} );
|
|
469
528
|
|
|
470
529
|
let uniformsGroup = uniformsStage[ groupName ];
|
|
@@ -488,24 +547,12 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
488
547
|
|
|
489
548
|
nodeData.uniformGPU = uniformGPU;
|
|
490
549
|
|
|
491
|
-
if ( shaderStage === 'vertex' ) {
|
|
492
|
-
|
|
493
|
-
this.bindingsOffset[ 'fragment' ] = bindings.length;
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
|
|
497
550
|
}
|
|
498
551
|
|
|
499
552
|
return uniformNode;
|
|
500
553
|
|
|
501
554
|
}
|
|
502
555
|
|
|
503
|
-
isReference( type ) {
|
|
504
|
-
|
|
505
|
-
return super.isReference( type ) || type === 'texture_2d' || type === 'texture_cube' || type === 'texture_depth_2d' || type === 'texture_storage_2d' || type === 'texture_3d';
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
|
|
509
556
|
getBuiltin( name, property, type, shaderStage = this.shaderStage ) {
|
|
510
557
|
|
|
511
558
|
const map = this.builtins[ shaderStage ] || ( this.builtins[ shaderStage ] = new Map() );
|
|
@@ -551,12 +598,18 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
551
598
|
|
|
552
599
|
//
|
|
553
600
|
|
|
554
|
-
|
|
601
|
+
let code = `fn ${ layout.name }( ${ parameters.join( ', ' ) } ) -> ${ this.getType( layout.type ) } {
|
|
555
602
|
${ flowData.vars }
|
|
556
603
|
${ flowData.code }
|
|
557
|
-
|
|
604
|
+
`;
|
|
605
|
+
|
|
606
|
+
if ( flowData.result ) {
|
|
607
|
+
|
|
608
|
+
code += `\treturn ${ flowData.result };\n`;
|
|
609
|
+
|
|
610
|
+
}
|
|
558
611
|
|
|
559
|
-
}
|
|
612
|
+
code += '\n}\n';
|
|
560
613
|
|
|
561
614
|
//
|
|
562
615
|
|
|
@@ -576,6 +629,34 @@ ${ flowData.code }
|
|
|
576
629
|
|
|
577
630
|
}
|
|
578
631
|
|
|
632
|
+
getInvocationLocalIndex() {
|
|
633
|
+
|
|
634
|
+
return this.getBuiltin( 'local_invocation_index', 'invocationLocalIndex', 'u32', 'attribute' );
|
|
635
|
+
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
getSubgroupSize() {
|
|
639
|
+
|
|
640
|
+
this.enableSubGroups();
|
|
641
|
+
|
|
642
|
+
return this.getBuiltin( 'subgroup_size', 'subgroupSize', 'u32', 'attribute' );
|
|
643
|
+
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
getSubgroupIndex() {
|
|
647
|
+
|
|
648
|
+
this.enableSubGroups();
|
|
649
|
+
|
|
650
|
+
return this.getBuiltin( 'subgroup_invocation_id', 'subgroupIndex', 'u32', 'attribute' );
|
|
651
|
+
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
getDrawIndex() {
|
|
655
|
+
|
|
656
|
+
return null;
|
|
657
|
+
|
|
658
|
+
}
|
|
659
|
+
|
|
579
660
|
getFrontFacing() {
|
|
580
661
|
|
|
581
662
|
return this.getBuiltin( 'front_facing', 'isFront', 'bool' );
|
|
@@ -584,7 +665,7 @@ ${ flowData.code }
|
|
|
584
665
|
|
|
585
666
|
getFragCoord() {
|
|
586
667
|
|
|
587
|
-
return this.getBuiltin( 'position', 'fragCoord', 'vec4<f32>' ) + '.
|
|
668
|
+
return this.getBuiltin( 'position', 'fragCoord', 'vec4<f32>' ) + '.xy';
|
|
588
669
|
|
|
589
670
|
}
|
|
590
671
|
|
|
@@ -600,6 +681,62 @@ ${ flowData.code }
|
|
|
600
681
|
|
|
601
682
|
}
|
|
602
683
|
|
|
684
|
+
enableDirective( name, shaderStage = this.shaderStage ) {
|
|
685
|
+
|
|
686
|
+
const stage = this.directives[ shaderStage ] || ( this.directives[ shaderStage ] = new Set() );
|
|
687
|
+
stage.add( name );
|
|
688
|
+
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
getDirectives( shaderStage ) {
|
|
692
|
+
|
|
693
|
+
const snippets = [];
|
|
694
|
+
const directives = this.directives[ shaderStage ];
|
|
695
|
+
|
|
696
|
+
if ( directives !== undefined ) {
|
|
697
|
+
|
|
698
|
+
for ( const directive of directives ) {
|
|
699
|
+
|
|
700
|
+
snippets.push( `enable ${directive};` );
|
|
701
|
+
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
return snippets.join( '\n' );
|
|
707
|
+
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
enableSubGroups() {
|
|
711
|
+
|
|
712
|
+
this.enableDirective( 'subgroups' );
|
|
713
|
+
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
enableSubgroupsF16() {
|
|
717
|
+
|
|
718
|
+
this.enableDirective( 'subgroups-f16' );
|
|
719
|
+
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
enableClipDistances() {
|
|
723
|
+
|
|
724
|
+
this.enableDirective( 'clip_distances' );
|
|
725
|
+
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
enableShaderF16() {
|
|
729
|
+
|
|
730
|
+
this.enableDirective( 'f16' );
|
|
731
|
+
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
enableDualSourceBlending() {
|
|
735
|
+
|
|
736
|
+
this.enableDirective( 'dual_source_blending' );
|
|
737
|
+
|
|
738
|
+
}
|
|
739
|
+
|
|
603
740
|
getBuiltins( shaderStage ) {
|
|
604
741
|
|
|
605
742
|
const snippets = [];
|
|
@@ -626,6 +763,9 @@ ${ flowData.code }
|
|
|
626
763
|
if ( shaderStage === 'compute' ) {
|
|
627
764
|
|
|
628
765
|
this.getBuiltin( 'global_invocation_id', 'id', 'vec3<u32>', 'attribute' );
|
|
766
|
+
this.getBuiltin( 'workgroup_id', 'workgroupId', 'vec3<u32>', 'attribute' );
|
|
767
|
+
this.getBuiltin( 'local_invocation_id', 'localId', 'vec3<u32>', 'attribute' );
|
|
768
|
+
this.getBuiltin( 'num_workgroups', 'numWorkgroups', 'vec3<u32>', 'attribute' );
|
|
629
769
|
|
|
630
770
|
}
|
|
631
771
|
|
|
@@ -667,7 +807,7 @@ ${ flowData.code }
|
|
|
667
807
|
|
|
668
808
|
const builtins = this.getBuiltins( 'output' );
|
|
669
809
|
|
|
670
|
-
if ( builtins ) snippets.push( builtins );
|
|
810
|
+
if ( builtins ) snippets.push( '\t' + builtins );
|
|
671
811
|
|
|
672
812
|
return snippets.join( ',\n' );
|
|
673
813
|
|
|
@@ -687,9 +827,10 @@ ${ flowData.code }
|
|
|
687
827
|
snippet += this.getStructMembers( struct );
|
|
688
828
|
snippet += '\n}';
|
|
689
829
|
|
|
830
|
+
|
|
690
831
|
snippets.push( snippet );
|
|
691
832
|
|
|
692
|
-
snippets.push( `\nvar<private> output : ${ name };\n\n`);
|
|
833
|
+
snippets.push( `\nvar<private> output : ${ name };\n\n` );
|
|
693
834
|
|
|
694
835
|
}
|
|
695
836
|
|
|
@@ -783,10 +924,11 @@ ${ flowData.code }
|
|
|
783
924
|
const structSnippets = [];
|
|
784
925
|
const uniformGroups = {};
|
|
785
926
|
|
|
786
|
-
let index = this.bindingsOffset[ shaderStage ];
|
|
787
|
-
|
|
788
927
|
for ( const uniform of uniforms ) {
|
|
789
928
|
|
|
929
|
+
const groundName = uniform.groupNode.name;
|
|
930
|
+
const uniformIndexes = this.bindingsIndexes[ groundName ];
|
|
931
|
+
|
|
790
932
|
if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'storageTexture' || uniform.type === 'texture3D' ) {
|
|
791
933
|
|
|
792
934
|
const texture = uniform.node.value;
|
|
@@ -795,11 +937,11 @@ ${ flowData.code }
|
|
|
795
937
|
|
|
796
938
|
if ( texture.isDepthTexture === true && texture.compareFunction !== null ) {
|
|
797
939
|
|
|
798
|
-
bindingSnippets.push( `@binding( ${
|
|
940
|
+
bindingSnippets.push( `@binding( ${ uniformIndexes.binding ++ } ) @group( ${ uniformIndexes.group } ) var ${ uniform.name }_sampler : sampler_comparison;` );
|
|
799
941
|
|
|
800
942
|
} else {
|
|
801
943
|
|
|
802
|
-
bindingSnippets.push( `@binding( ${
|
|
944
|
+
bindingSnippets.push( `@binding( ${ uniformIndexes.binding ++ } ) @group( ${ uniformIndexes.group } ) var ${ uniform.name }_sampler : sampler;` );
|
|
803
945
|
|
|
804
946
|
}
|
|
805
947
|
|
|
@@ -807,17 +949,25 @@ ${ flowData.code }
|
|
|
807
949
|
|
|
808
950
|
let textureType;
|
|
809
951
|
|
|
952
|
+
let multisampled = '';
|
|
953
|
+
|
|
954
|
+
if ( texture.isMultisampleRenderTargetTexture === true ) {
|
|
955
|
+
|
|
956
|
+
multisampled = '_multisampled';
|
|
957
|
+
|
|
958
|
+
}
|
|
959
|
+
|
|
810
960
|
if ( texture.isCubeTexture === true ) {
|
|
811
961
|
|
|
812
962
|
textureType = 'texture_cube<f32>';
|
|
813
963
|
|
|
814
|
-
} else if ( texture.isDataArrayTexture === true ) {
|
|
964
|
+
} else if ( texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
815
965
|
|
|
816
966
|
textureType = 'texture_2d_array<f32>';
|
|
817
967
|
|
|
818
968
|
} else if ( texture.isDepthTexture === true ) {
|
|
819
969
|
|
|
820
|
-
textureType =
|
|
970
|
+
textureType = `texture_depth${multisampled}_2d`;
|
|
821
971
|
|
|
822
972
|
} else if ( texture.isVideoTexture === true ) {
|
|
823
973
|
|
|
@@ -832,17 +982,17 @@ ${ flowData.code }
|
|
|
832
982
|
const format = getFormat( texture );
|
|
833
983
|
const access = this.getStorageAccess( uniform.node );
|
|
834
984
|
|
|
835
|
-
textureType = `texture_storage_2d<${ format }, ${access}>`;
|
|
985
|
+
textureType = `texture_storage_2d<${ format }, ${ access }>`;
|
|
836
986
|
|
|
837
987
|
} else {
|
|
838
988
|
|
|
839
989
|
const componentPrefix = this.getComponentTypeFromTexture( texture ).charAt( 0 );
|
|
840
990
|
|
|
841
|
-
textureType = `
|
|
991
|
+
textureType = `texture${multisampled}_2d<${ componentPrefix }32>`;
|
|
842
992
|
|
|
843
993
|
}
|
|
844
994
|
|
|
845
|
-
bindingSnippets.push( `@binding( ${
|
|
995
|
+
bindingSnippets.push( `@binding( ${ uniformIndexes.binding ++ } ) @group( ${ uniformIndexes.group } ) var ${ uniform.name } : ${ textureType };` );
|
|
846
996
|
|
|
847
997
|
} else if ( uniform.type === 'buffer' || uniform.type === 'storageBuffer' ) {
|
|
848
998
|
|
|
@@ -851,10 +1001,10 @@ ${ flowData.code }
|
|
|
851
1001
|
const bufferCount = bufferNode.bufferCount;
|
|
852
1002
|
|
|
853
1003
|
const bufferCountSnippet = bufferCount > 0 ? ', ' + bufferCount : '';
|
|
854
|
-
const bufferSnippet = `\t${uniform.name} : array< ${bufferType}${bufferCountSnippet} >\n`;
|
|
855
|
-
const bufferAccessMode = bufferNode.isStorageBufferNode ?
|
|
1004
|
+
const bufferSnippet = `\t${ uniform.name } : array< ${ bufferType }${ bufferCountSnippet } >\n`;
|
|
1005
|
+
const bufferAccessMode = bufferNode.isStorageBufferNode ? `storage, ${ this.getStorageAccess( bufferNode ) }` : 'uniform';
|
|
856
1006
|
|
|
857
|
-
bufferSnippets.push( this._getWGSLStructBinding( 'NodeBuffer_' + bufferNode.id, bufferSnippet, bufferAccessMode,
|
|
1007
|
+
bufferSnippets.push( this._getWGSLStructBinding( 'NodeBuffer_' + bufferNode.id, bufferSnippet, bufferAccessMode, uniformIndexes.binding ++, uniformIndexes.group ) );
|
|
858
1008
|
|
|
859
1009
|
} else {
|
|
860
1010
|
|
|
@@ -862,7 +1012,8 @@ ${ flowData.code }
|
|
|
862
1012
|
const groupName = uniform.groupNode.name;
|
|
863
1013
|
|
|
864
1014
|
const group = uniformGroups[ groupName ] || ( uniformGroups[ groupName ] = {
|
|
865
|
-
index:
|
|
1015
|
+
index: uniformIndexes.binding ++,
|
|
1016
|
+
id: uniformIndexes.group,
|
|
866
1017
|
snippets: []
|
|
867
1018
|
} );
|
|
868
1019
|
|
|
@@ -876,7 +1027,7 @@ ${ flowData.code }
|
|
|
876
1027
|
|
|
877
1028
|
const group = uniformGroups[ name ];
|
|
878
1029
|
|
|
879
|
-
structSnippets.push( this._getWGSLStructBinding( name, group.snippets.join( ',\n' ), 'uniform', group.index ) );
|
|
1030
|
+
structSnippets.push( this._getWGSLStructBinding( name, group.snippets.join( ',\n' ), 'uniform', group.index, group.id ) );
|
|
880
1031
|
|
|
881
1032
|
}
|
|
882
1033
|
|
|
@@ -901,6 +1052,7 @@ ${ flowData.code }
|
|
|
901
1052
|
stageData.structs = this.getStructs( shaderStage );
|
|
902
1053
|
stageData.vars = this.getVars( shaderStage );
|
|
903
1054
|
stageData.codes = this.getCodes( shaderStage );
|
|
1055
|
+
stageData.directives = this.getDirectives( shaderStage );
|
|
904
1056
|
|
|
905
1057
|
//
|
|
906
1058
|
|
|
@@ -968,6 +1120,7 @@ ${ flowData.code }
|
|
|
968
1120
|
|
|
969
1121
|
stageData.flow = flow;
|
|
970
1122
|
|
|
1123
|
+
|
|
971
1124
|
}
|
|
972
1125
|
|
|
973
1126
|
if ( this.material !== null ) {
|
|
@@ -1011,7 +1164,21 @@ ${ flowData.code }
|
|
|
1011
1164
|
|
|
1012
1165
|
isAvailable( name ) {
|
|
1013
1166
|
|
|
1014
|
-
|
|
1167
|
+
let result = supports[ name ];
|
|
1168
|
+
|
|
1169
|
+
if ( result === undefined ) {
|
|
1170
|
+
|
|
1171
|
+
if ( name === 'float32Filterable' ) {
|
|
1172
|
+
|
|
1173
|
+
result = this.renderer.hasFeature( 'float32-filterable' );
|
|
1174
|
+
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
supports[ name ] = result;
|
|
1178
|
+
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
return result;
|
|
1015
1182
|
|
|
1016
1183
|
}
|
|
1017
1184
|
|
|
@@ -1045,6 +1212,8 @@ ${ flowData.code }
|
|
|
1045
1212
|
_getWGSLVertexCode( shaderData ) {
|
|
1046
1213
|
|
|
1047
1214
|
return `${ this.getSignature() }
|
|
1215
|
+
// directives
|
|
1216
|
+
${shaderData.directives}
|
|
1048
1217
|
|
|
1049
1218
|
// uniforms
|
|
1050
1219
|
${shaderData.uniforms}
|
|
@@ -1076,6 +1245,8 @@ fn main( ${shaderData.attributes} ) -> VaryingsStruct {
|
|
|
1076
1245
|
|
|
1077
1246
|
return `${ this.getSignature() }
|
|
1078
1247
|
|
|
1248
|
+
diagnostic( off, derivative_uniformity );
|
|
1249
|
+
|
|
1079
1250
|
// uniforms
|
|
1080
1251
|
${shaderData.uniforms}
|
|
1081
1252
|
|
|
@@ -1102,6 +1273,9 @@ fn main( ${shaderData.varyings} ) -> ${shaderData.returnType} {
|
|
|
1102
1273
|
_getWGSLComputeCode( shaderData, workgroupSize ) {
|
|
1103
1274
|
|
|
1104
1275
|
return `${ this.getSignature() }
|
|
1276
|
+
// directives
|
|
1277
|
+
${shaderData.directives}
|
|
1278
|
+
|
|
1105
1279
|
// system
|
|
1106
1280
|
var<private> instanceIndex : u32;
|
|
1107
1281
|
|
|
@@ -1115,7 +1289,7 @@ ${shaderData.codes}
|
|
|
1115
1289
|
fn main( ${shaderData.attributes} ) {
|
|
1116
1290
|
|
|
1117
1291
|
// system
|
|
1118
|
-
instanceIndex = id.x;
|
|
1292
|
+
instanceIndex = id.x + id.y * numWorkgroups.x * u32(${workgroupSize}) + id.z * numWorkgroups.x * numWorkgroups.y * u32(${workgroupSize});
|
|
1119
1293
|
|
|
1120
1294
|
// vars
|
|
1121
1295
|
${shaderData.vars}
|