super-three 0.169.1 → 0.170.1
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 +24628 -24228
- package/build/three.core.js +37002 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +10519 -47108
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +533 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +17071 -53583
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +17134 -53623
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
- package/examples/jsm/animation/MMDPhysics.js +2 -0
- package/examples/jsm/capabilities/WebGPU.js +1 -10
- package/examples/jsm/controls/ArcballControls.js +25 -21
- package/examples/jsm/controls/OrbitControls.js +41 -9
- package/examples/jsm/controls/PointerLockControls.js +2 -5
- package/examples/jsm/controls/TransformControls.js +22 -6
- package/examples/jsm/csm/CSM.js +2 -2
- package/examples/jsm/csm/CSMFrustum.js +7 -4
- package/examples/jsm/csm/CSMHelper.js +2 -0
- package/examples/jsm/csm/CSMShadowNode.js +437 -0
- package/examples/jsm/curves/NURBSCurve.js +34 -3
- package/examples/jsm/exporters/GLTFExporter.js +138 -71
- package/examples/jsm/exporters/KTX2Exporter.js +35 -12
- package/examples/jsm/exporters/MMDExporter.js +6 -0
- package/examples/jsm/exporters/USDZExporter.js +21 -3
- package/examples/jsm/geometries/DecalGeometry.js +70 -21
- package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
- package/examples/jsm/interactive/HTMLMesh.js +1 -0
- package/examples/jsm/lighting/TiledLighting.js +18 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/LineGeometry.js +25 -0
- package/examples/jsm/lines/LineMaterial.js +0 -1
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/Line2.js +2 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +2 -16
- package/examples/jsm/lines/webgpu/Wireframe.js +57 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +91 -0
- package/examples/jsm/loaders/FBXLoader.js +12 -2
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +143 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +3 -0
- package/examples/jsm/loaders/MaterialXLoader.js +2 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- package/examples/jsm/math/ColorSpaces.js +76 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- package/examples/jsm/objects/InstancedPoints.js +2 -4
- package/examples/jsm/objects/LensflareMesh.js +4 -2
- package/examples/jsm/objects/SkyMesh.js +5 -3
- package/examples/jsm/objects/Water2Mesh.js +7 -3
- package/examples/jsm/objects/WaterMesh.js +12 -10
- package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
- package/examples/jsm/postprocessing/SSRPass.js +6 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
- package/examples/jsm/shaders/FXAAShader.js +225 -224
- package/examples/jsm/transpiler/AST.js +2 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +11 -6
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +18 -21
- package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
- package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +12 -41
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +60 -47
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +4 -9
- package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
- package/examples/jsm/tsl/display/FXAANode.js +316 -0
- package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +4 -7
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +73 -78
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +78 -42
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +3 -5
- package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
- package/examples/jsm/tsl/display/OutlineNode.js +434 -0
- package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +2 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +5 -17
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +2 -6
- package/examples/jsm/tsl/display/SMAANode.js +620 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
- package/examples/jsm/tsl/display/SSRNode.js +366 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +4 -12
- package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
- package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
- package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +3 -7
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +389 -0
- package/examples/jsm/utils/SceneOptimizer.js +410 -0
- package/examples/jsm/utils/UVsDebug.js +1 -1
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
- package/examples/jsm/webxr/Text2D.js +6 -6
- package/package.json +4 -4
- package/src/Three.Core.js +178 -0
- package/src/Three.TSL.js +526 -0
- package/src/Three.WebGPU.Nodes.js +9 -186
- package/src/Three.WebGPU.js +8 -186
- package/src/Three.js +1 -177
- package/src/animation/AnimationClip.js +2 -2
- package/src/animation/AnimationObjectGroup.js +2 -2
- package/src/audio/Audio.js +38 -0
- package/src/cameras/PerspectiveCamera.js +6 -6
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -6
- package/src/core/BufferGeometry.js +48 -8
- package/src/core/InterleavedBuffer.js +4 -4
- package/src/core/Object3D.js +2 -2
- package/src/extras/core/Curve.js +3 -3
- package/src/extras/core/Shape.js +2 -2
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/geometries/EdgesGeometry.js +2 -2
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/materials/LineDashedMaterial.js +0 -1
- package/src/materials/Material.js +2 -2
- package/src/materials/MeshPhongMaterial.js +1 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -2
- package/src/materials/MeshStandardMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +32 -13
- package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
- package/src/materials/nodes/NodeMaterial.js +93 -23
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +119 -7
- package/src/math/ColorManagement.js +143 -102
- package/src/math/Line3.js +2 -2
- package/src/math/Quaternion.js +2 -2
- package/src/math/Spherical.js +3 -3
- package/src/math/Vector2.js +7 -7
- package/src/math/Vector3.js +9 -9
- package/src/math/Vector4.js +22 -9
- package/src/nodes/Nodes.js +2 -21
- package/src/nodes/TSL.js +9 -25
- package/src/nodes/accessors/Arrays.js +27 -0
- package/src/nodes/accessors/BuiltinNode.js +26 -0
- package/src/nodes/accessors/Camera.js +0 -1
- package/src/nodes/accessors/ClippingNode.js +76 -42
- package/src/nodes/accessors/InstanceNode.js +17 -20
- package/src/nodes/accessors/InstancedMeshNode.js +26 -0
- package/src/nodes/accessors/Lights.js +32 -0
- package/src/nodes/accessors/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +61 -19
- package/src/nodes/accessors/StorageTextureNode.js +10 -4
- package/src/nodes/accessors/TextureNode.js +1 -1
- package/src/nodes/accessors/VelocityNode.js +13 -3
- package/src/nodes/code/FunctionCallNode.js +16 -5
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/core/Node.js +1 -0
- package/src/nodes/core/NodeBuilder.js +31 -14
- package/src/nodes/core/NodeUtils.js +28 -0
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/core/constants.js +6 -0
- package/src/nodes/display/BlendModes.js +99 -0
- package/src/nodes/display/ColorAdjustment.js +53 -4
- package/src/nodes/display/ColorSpaceFunctions.js +5 -5
- package/src/nodes/display/ColorSpaceNode.js +27 -39
- package/src/nodes/display/PassNode.js +6 -4
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +48 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +70 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
- package/src/nodes/gpgpu/ComputeNode.js +9 -1
- package/src/nodes/lighting/AnalyticLightNode.js +23 -419
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +41 -22
- package/src/nodes/lighting/PointShadowNode.js +254 -0
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +593 -0
- package/src/nodes/lighting/SpotLightNode.js +14 -2
- package/src/nodes/utils/LoopNode.js +2 -2
- package/src/nodes/utils/Oscillators.js +6 -0
- package/src/nodes/utils/PostProcessingUtils.js +89 -0
- package/src/nodes/utils/RTTNode.js +9 -1
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/StorageArrayElementNode.js +2 -2
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +472 -296
- package/src/objects/ClippingGroup.js +19 -0
- package/src/objects/Skeleton.js +2 -2
- package/src/renderers/WebGLRenderer.js +183 -109
- package/src/renderers/common/Animation.js +23 -11
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +15 -5
- package/src/renderers/common/Bindings.js +23 -6
- package/src/renderers/common/ClippingContext.js +77 -85
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/Geometries.js +20 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
- package/src/renderers/common/Lighting.js +45 -0
- package/src/renderers/common/PostProcessingUtils.js +86 -0
- package/src/renderers/common/RenderList.js +48 -17
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +45 -28
- package/src/renderers/common/RenderObjects.js +12 -6
- package/src/renderers/common/Renderer.js +222 -77
- package/src/renderers/common/Textures.js +41 -17
- package/src/renderers/common/UniformsGroup.js +16 -4
- package/src/renderers/common/extras/PMREMGenerator.js +89 -13
- package/src/renderers/common/nodes/NodeLibrary.js +2 -15
- package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
- package/src/renderers/common/nodes/NodeUniform.js +42 -0
- package/src/renderers/common/nodes/Nodes.js +2 -2
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +20 -1
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLGeometries.js +0 -28
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -28
- package/src/renderers/webgl/WebGLPrograms.js +5 -2
- package/src/renderers/webgl/WebGLState.js +37 -1
- package/src/renderers/webgl/WebGLTextures.js +29 -12
- package/src/renderers/webgl-fallback/WebGLBackend.js +111 -37
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
- package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +37 -9
- package/src/renderers/webgpu/WebGPUBackend.js +152 -56
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -34
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +192 -92
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +29 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/TimerNode.js +0 -97
- /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
import NodeLibrary from '../../common/nodes/NodeLibrary.js';
|
|
2
2
|
|
|
3
3
|
// Materials
|
|
4
|
-
import { MeshPhongMaterial } from '../../../materials/MeshPhongMaterial.js';
|
|
5
4
|
import MeshPhongNodeMaterial from '../../../materials/nodes/MeshPhongNodeMaterial.js';
|
|
6
|
-
import { MeshStandardMaterial } from '../../../materials/MeshStandardMaterial.js';
|
|
7
5
|
import MeshStandardNodeMaterial from '../../../materials/nodes/MeshStandardNodeMaterial.js';
|
|
8
|
-
import { MeshPhysicalMaterial } from '../../../materials/MeshPhysicalMaterial.js';
|
|
9
6
|
import MeshPhysicalNodeMaterial from '../../../materials/nodes/MeshPhysicalNodeMaterial.js';
|
|
10
|
-
import { MeshToonMaterial } from '../../../materials/MeshToonMaterial.js';
|
|
11
7
|
import MeshToonNodeMaterial from '../../../materials/nodes/MeshToonNodeMaterial.js';
|
|
12
|
-
import { MeshBasicMaterial } from '../../../materials/MeshBasicMaterial.js';
|
|
13
8
|
import MeshBasicNodeMaterial from '../../../materials/nodes/MeshBasicNodeMaterial.js';
|
|
14
|
-
import { MeshLambertMaterial } from '../../../materials/MeshLambertMaterial.js';
|
|
15
9
|
import MeshLambertNodeMaterial from '../../../materials/nodes/MeshLambertNodeMaterial.js';
|
|
16
|
-
import { MeshNormalMaterial } from '../../../materials/MeshNormalMaterial.js';
|
|
17
10
|
import MeshNormalNodeMaterial from '../../../materials/nodes/MeshNormalNodeMaterial.js';
|
|
18
|
-
import { MeshMatcapMaterial } from '../../../materials/MeshMatcapMaterial.js';
|
|
19
11
|
import MeshMatcapNodeMaterial from '../../../materials/nodes/MeshMatcapNodeMaterial.js';
|
|
20
|
-
import { LineBasicMaterial } from '../../../materials/LineBasicMaterial.js';
|
|
21
12
|
import LineBasicNodeMaterial from '../../../materials/nodes/LineBasicNodeMaterial.js';
|
|
22
|
-
import { LineDashedMaterial } from '../../../materials/LineDashedMaterial.js';
|
|
23
13
|
import LineDashedNodeMaterial from '../../../materials/nodes/LineDashedNodeMaterial.js';
|
|
24
|
-
import { PointsMaterial } from '../../../materials/PointsMaterial.js';
|
|
25
14
|
import PointsNodeMaterial from '../../../materials/nodes/PointsNodeMaterial.js';
|
|
26
|
-
import { SpriteMaterial } from '../../../materials/SpriteMaterial.js';
|
|
27
15
|
import SpriteNodeMaterial from '../../../materials/nodes/SpriteNodeMaterial.js';
|
|
28
|
-
import { ShadowMaterial } from '../../../materials/ShadowMaterial.js';
|
|
29
16
|
import ShadowNodeMaterial from '../../../materials/nodes/ShadowNodeMaterial.js';
|
|
30
17
|
//import { MeshDepthMaterial } from '../../../materials/MeshDepthMaterial.js';
|
|
31
18
|
//import MeshDepthNodeMaterial from '../../../materials/nodes/MeshDepthNodeMaterial.js';
|
|
@@ -54,30 +41,25 @@ import { IESSpotLightNode } from '../../../nodes/Nodes.js';
|
|
|
54
41
|
import { LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping, NeutralToneMapping } from '../../../constants.js';
|
|
55
42
|
import { linearToneMapping, reinhardToneMapping, cineonToneMapping, acesFilmicToneMapping, agxToneMapping, neutralToneMapping } from '../../../nodes/display/ToneMappingFunctions.js';
|
|
56
43
|
|
|
57
|
-
// Color Space
|
|
58
|
-
import { LinearSRGBColorSpace, SRGBColorSpace } from '../../../constants.js';
|
|
59
|
-
import { linearSRGBTosRGB, sRGBToLinearSRGB } from '../../../nodes/display/ColorSpaceFunctions.js';
|
|
60
|
-
import { getColorSpaceMethod } from '../../../nodes/display/ColorSpaceNode.js';
|
|
61
|
-
|
|
62
44
|
class StandardNodeLibrary extends NodeLibrary {
|
|
63
45
|
|
|
64
46
|
constructor() {
|
|
65
47
|
|
|
66
48
|
super();
|
|
67
49
|
|
|
68
|
-
this.addMaterial( MeshPhongNodeMaterial, MeshPhongMaterial );
|
|
69
|
-
this.addMaterial( MeshStandardNodeMaterial, MeshStandardMaterial );
|
|
70
|
-
this.addMaterial( MeshPhysicalNodeMaterial, MeshPhysicalMaterial );
|
|
71
|
-
this.addMaterial( MeshToonNodeMaterial, MeshToonMaterial );
|
|
72
|
-
this.addMaterial( MeshBasicNodeMaterial, MeshBasicMaterial );
|
|
73
|
-
this.addMaterial( MeshLambertNodeMaterial, MeshLambertMaterial );
|
|
74
|
-
this.addMaterial( MeshNormalNodeMaterial, MeshNormalMaterial );
|
|
75
|
-
this.addMaterial( MeshMatcapNodeMaterial, MeshMatcapMaterial );
|
|
76
|
-
this.addMaterial( LineBasicNodeMaterial, LineBasicMaterial );
|
|
77
|
-
this.addMaterial( LineDashedNodeMaterial, LineDashedMaterial );
|
|
78
|
-
this.addMaterial( PointsNodeMaterial, PointsMaterial );
|
|
79
|
-
this.addMaterial( SpriteNodeMaterial, SpriteMaterial );
|
|
80
|
-
this.addMaterial( ShadowNodeMaterial, ShadowMaterial );
|
|
50
|
+
this.addMaterial( MeshPhongNodeMaterial, 'MeshPhongMaterial' );
|
|
51
|
+
this.addMaterial( MeshStandardNodeMaterial, 'MeshStandardMaterial' );
|
|
52
|
+
this.addMaterial( MeshPhysicalNodeMaterial, 'MeshPhysicalMaterial' );
|
|
53
|
+
this.addMaterial( MeshToonNodeMaterial, 'MeshToonMaterial' );
|
|
54
|
+
this.addMaterial( MeshBasicNodeMaterial, 'MeshBasicMaterial' );
|
|
55
|
+
this.addMaterial( MeshLambertNodeMaterial, 'MeshLambertMaterial' );
|
|
56
|
+
this.addMaterial( MeshNormalNodeMaterial, 'MeshNormalMaterial' );
|
|
57
|
+
this.addMaterial( MeshMatcapNodeMaterial, 'MeshMatcapMaterial' );
|
|
58
|
+
this.addMaterial( LineBasicNodeMaterial, 'LineBasicMaterial' );
|
|
59
|
+
this.addMaterial( LineDashedNodeMaterial, 'LineDashedMaterial' );
|
|
60
|
+
this.addMaterial( PointsNodeMaterial, 'PointsMaterial' );
|
|
61
|
+
this.addMaterial( SpriteNodeMaterial, 'SpriteMaterial' );
|
|
62
|
+
this.addMaterial( ShadowNodeMaterial, 'ShadowMaterial' );
|
|
81
63
|
|
|
82
64
|
this.addLight( PointLightNode, PointLight );
|
|
83
65
|
this.addLight( DirectionalLightNode, DirectionalLight );
|
|
@@ -95,9 +77,6 @@ class StandardNodeLibrary extends NodeLibrary {
|
|
|
95
77
|
this.addToneMapping( agxToneMapping, AgXToneMapping );
|
|
96
78
|
this.addToneMapping( neutralToneMapping, NeutralToneMapping );
|
|
97
79
|
|
|
98
|
-
this.addColorSpace( linearSRGBTosRGB, getColorSpaceMethod( LinearSRGBColorSpace, SRGBColorSpace ) );
|
|
99
|
-
this.addColorSpace( sRGBToLinearSRGB, getColorSpaceMethod( SRGBColorSpace, LinearSRGBColorSpace ) );
|
|
100
|
-
|
|
101
80
|
}
|
|
102
81
|
|
|
103
82
|
}
|
|
@@ -11,12 +11,27 @@ import { NodeBuilder, CodeNode } from '../../../nodes/Nodes.js';
|
|
|
11
11
|
import { getFormat } from '../utils/WebGPUTextureUtils.js';
|
|
12
12
|
|
|
13
13
|
import WGSLNodeParser from './WGSLNodeParser.js';
|
|
14
|
-
import {
|
|
14
|
+
import { NodeAccess } from '../../../nodes/core/constants.js';
|
|
15
15
|
|
|
16
|
-
import
|
|
16
|
+
import VarNode from '../../../nodes/core/VarNode.js';
|
|
17
|
+
import ExpressionNode from '../../../nodes/code/ExpressionNode.js';
|
|
18
|
+
|
|
19
|
+
import { NoColorSpace, FloatType, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestFilter } from '../../../constants.js';
|
|
17
20
|
|
|
18
21
|
// GPUShaderStage is not defined in browsers not supporting WebGPU
|
|
19
|
-
const GPUShaderStage = self.GPUShaderStage;
|
|
22
|
+
const GPUShaderStage = ( typeof self !== 'undefined' ) ? self.GPUShaderStage : { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };
|
|
23
|
+
|
|
24
|
+
const accessNames = {
|
|
25
|
+
[ NodeAccess.READ_ONLY ]: 'read',
|
|
26
|
+
[ NodeAccess.WRITE_ONLY ]: 'write',
|
|
27
|
+
[ NodeAccess.READ_WRITE ]: 'read_write'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const wrapNames = {
|
|
31
|
+
[ RepeatWrapping ]: 'repeat',
|
|
32
|
+
[ ClampToEdgeWrapping ]: 'clamp',
|
|
33
|
+
[ MirroredRepeatWrapping ]: 'mirror'
|
|
34
|
+
};
|
|
20
35
|
|
|
21
36
|
const gpuShaderStageLib = {
|
|
22
37
|
'vertex': GPUShaderStage ? GPUShaderStage.VERTEX : 1,
|
|
@@ -57,21 +72,12 @@ const wgslTypeLib = {
|
|
|
57
72
|
bvec4: 'vec4<bool>',
|
|
58
73
|
|
|
59
74
|
mat2: 'mat2x2<f32>',
|
|
60
|
-
imat2: 'mat2x2<i32>',
|
|
61
|
-
umat2: 'mat2x2<u32>',
|
|
62
|
-
bmat2: 'mat2x2<bool>',
|
|
63
|
-
|
|
64
75
|
mat3: 'mat3x3<f32>',
|
|
65
|
-
|
|
66
|
-
umat3: 'mat3x3<u32>',
|
|
67
|
-
bmat3: 'mat3x3<bool>',
|
|
68
|
-
|
|
69
|
-
mat4: 'mat4x4<f32>',
|
|
70
|
-
imat4: 'mat4x4<i32>',
|
|
71
|
-
umat4: 'mat4x4<u32>',
|
|
72
|
-
bmat4: 'mat4x4<bool>'
|
|
76
|
+
mat4: 'mat4x4<f32>'
|
|
73
77
|
};
|
|
74
78
|
|
|
79
|
+
const wgslCodeCache = {};
|
|
80
|
+
|
|
75
81
|
const wgslPolyfill = {
|
|
76
82
|
tsl_xor: new CodeNode( 'fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }' ),
|
|
77
83
|
mod_float: new CodeNode( 'fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }' ),
|
|
@@ -82,19 +88,12 @@ const wgslPolyfill = {
|
|
|
82
88
|
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
89
|
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
90
|
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
|
-
|
|
86
|
-
fn
|
|
91
|
+
repeatWrapping_float: new CodeNode( 'fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }' ),
|
|
92
|
+
mirrorWrapping_float: new CodeNode( 'fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }' ),
|
|
93
|
+
clampWrapping_float: new CodeNode( 'fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }' ),
|
|
94
|
+
biquadraticTexture: new CodeNode( /* wgsl */`
|
|
95
|
+
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
|
|
87
96
|
|
|
88
|
-
let uvScaled = vec2<u32>( uv * vec2<f32>( dimension ) );
|
|
89
|
-
|
|
90
|
-
return ( ( uvScaled % dimension ) + dimension ) % dimension;
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
` ),
|
|
94
|
-
biquadraticTexture: new CodeNode( `
|
|
95
|
-
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, level : i32 ) -> vec4f {
|
|
96
|
-
|
|
97
|
-
let iRes = vec2i( textureDimensions( map, level ) );
|
|
98
97
|
let res = vec2f( iRes );
|
|
99
98
|
|
|
100
99
|
let uvScaled = coord * res;
|
|
@@ -106,10 +105,10 @@ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, level : i32 ) -
|
|
|
106
105
|
let iuv = floor( uv );
|
|
107
106
|
let f = fract( uv );
|
|
108
107
|
|
|
109
|
-
let rg1 = textureLoad( map,
|
|
110
|
-
let rg2 = textureLoad( map,
|
|
111
|
-
let rg3 = textureLoad( map,
|
|
112
|
-
let rg4 = textureLoad( map,
|
|
108
|
+
let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
|
|
109
|
+
let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
|
|
110
|
+
let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
|
|
111
|
+
let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
|
|
113
112
|
|
|
114
113
|
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
115
114
|
|
|
@@ -134,7 +133,7 @@ const wgslMethods = {
|
|
|
134
133
|
|
|
135
134
|
// WebGPU issue: does not support pow() with negative base on Windows
|
|
136
135
|
|
|
137
|
-
if ( /Windows/g.test( navigator.userAgent ) ) {
|
|
136
|
+
if ( typeof navigator !== 'undefined' && /Windows/g.test( navigator.userAgent ) ) {
|
|
138
137
|
|
|
139
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 ); }' );
|
|
140
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 ] );
|
|
@@ -152,7 +151,7 @@ if ( /Windows/g.test( navigator.userAgent ) ) {
|
|
|
152
151
|
|
|
153
152
|
let diagnostics = '';
|
|
154
153
|
|
|
155
|
-
if ( /Firefox/g.test( navigator.userAgent ) !== true ) {
|
|
154
|
+
if ( ( typeof navigator !== 'undefined' && /Firefox|Deno/g.test( navigator.userAgent ) ) !== true ) {
|
|
156
155
|
|
|
157
156
|
diagnostics += 'diagnostic( off, derivative_uniformity );\n';
|
|
158
157
|
|
|
@@ -202,7 +201,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
202
201
|
|
|
203
202
|
} else {
|
|
204
203
|
|
|
205
|
-
return this.generateTextureLod( texture, textureProperty, uvSnippet, '0' );
|
|
204
|
+
return this.generateTextureLod( texture, textureProperty, uvSnippet, depthSnippet, '0' );
|
|
206
205
|
|
|
207
206
|
}
|
|
208
207
|
|
|
@@ -234,39 +233,139 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
234
233
|
|
|
235
234
|
} else {
|
|
236
235
|
|
|
237
|
-
return this.generateTextureLod( texture, textureProperty, uvSnippet, levelSnippet );
|
|
236
|
+
return this.generateTextureLod( texture, textureProperty, uvSnippet, depthSnippet, levelSnippet );
|
|
237
|
+
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
generateWrapFunction( texture ) {
|
|
243
|
+
|
|
244
|
+
const functionName = `tsl_coord_${ wrapNames[ texture.wrapS ] }S_${ wrapNames[ texture.wrapT ] }T`;
|
|
245
|
+
|
|
246
|
+
let nodeCode = wgslCodeCache[ functionName ];
|
|
247
|
+
|
|
248
|
+
if ( nodeCode === undefined ) {
|
|
249
|
+
|
|
250
|
+
const includes = [];
|
|
251
|
+
|
|
252
|
+
let code = `fn ${ functionName }( coord : vec2f ) -> vec2f {\n\n\treturn vec2f(\n`;
|
|
253
|
+
|
|
254
|
+
const addWrapSnippet = ( wrap, axis ) => {
|
|
255
|
+
|
|
256
|
+
if ( wrap === RepeatWrapping ) {
|
|
257
|
+
|
|
258
|
+
includes.push( wgslPolyfill.repeatWrapping_float );
|
|
259
|
+
|
|
260
|
+
code += `\t\ttsl_repeatWrapping_float( coord.${ axis } )`;
|
|
261
|
+
|
|
262
|
+
} else if ( wrap === ClampToEdgeWrapping ) {
|
|
263
|
+
|
|
264
|
+
includes.push( wgslPolyfill.clampWrapping_float );
|
|
265
|
+
|
|
266
|
+
code += `\t\ttsl_clampWrapping_float( coord.${ axis } )`;
|
|
267
|
+
|
|
268
|
+
} else if ( wrap === MirroredRepeatWrapping ) {
|
|
269
|
+
|
|
270
|
+
includes.push( wgslPolyfill.mirrorWrapping_float );
|
|
271
|
+
|
|
272
|
+
code += `\t\ttsl_mirrorWrapping_float( coord.${ axis } )`;
|
|
273
|
+
|
|
274
|
+
} else {
|
|
275
|
+
|
|
276
|
+
code += `\t\tcoord.${ axis }`;
|
|
277
|
+
|
|
278
|
+
console.warn( `WebGPURenderer: Unsupported texture wrap type "${ wrap }" for vertex shader.` );
|
|
279
|
+
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
addWrapSnippet( texture.wrapS, 'x' );
|
|
285
|
+
|
|
286
|
+
code += ',\n';
|
|
287
|
+
|
|
288
|
+
addWrapSnippet( texture.wrapT, 'y' );
|
|
289
|
+
|
|
290
|
+
code += '\n\t);\n\n}\n';
|
|
291
|
+
|
|
292
|
+
wgslCodeCache[ functionName ] = nodeCode = new CodeNode( code, includes );
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
nodeCode.build( this );
|
|
297
|
+
|
|
298
|
+
return functionName;
|
|
299
|
+
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
generateTextureDimension( texture, textureProperty, levelSnippet ) {
|
|
303
|
+
|
|
304
|
+
const textureData = this.getDataFromNode( texture, this.shaderStage, this.globalCache );
|
|
305
|
+
|
|
306
|
+
if ( textureData.dimensionsSnippet === undefined ) textureData.dimensionsSnippet = {};
|
|
307
|
+
|
|
308
|
+
let textureDimensionNode = textureData.dimensionsSnippet[ levelSnippet ];
|
|
309
|
+
|
|
310
|
+
if ( textureData.dimensionsSnippet[ levelSnippet ] === undefined ) {
|
|
311
|
+
|
|
312
|
+
let textureDimensionsParams;
|
|
313
|
+
|
|
314
|
+
if ( texture.isMultisampleRenderTargetTexture === true ) {
|
|
315
|
+
|
|
316
|
+
textureDimensionsParams = textureProperty;
|
|
317
|
+
|
|
318
|
+
} else {
|
|
319
|
+
|
|
320
|
+
textureDimensionsParams = `${ textureProperty }, u32( ${ levelSnippet } )`;
|
|
321
|
+
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
textureDimensionNode = new VarNode( new ExpressionNode( `textureDimensions( ${ textureDimensionsParams } )`, 'uvec2' ) );
|
|
325
|
+
|
|
326
|
+
textureData.dimensionsSnippet[ levelSnippet ] = textureDimensionNode;
|
|
238
327
|
|
|
239
328
|
}
|
|
240
329
|
|
|
330
|
+
return textureDimensionNode.build( this );
|
|
331
|
+
|
|
241
332
|
}
|
|
242
333
|
|
|
243
|
-
generateFilteredTexture( texture, textureProperty, uvSnippet, levelSnippet = '
|
|
334
|
+
generateFilteredTexture( texture, textureProperty, uvSnippet, levelSnippet = '0u' ) {
|
|
244
335
|
|
|
245
336
|
this._include( 'biquadraticTexture' );
|
|
246
337
|
|
|
247
|
-
|
|
338
|
+
const wrapFunction = this.generateWrapFunction( texture );
|
|
339
|
+
const textureDimension = this.generateTextureDimension( texture, textureProperty, levelSnippet );
|
|
340
|
+
|
|
341
|
+
return `tsl_biquadraticTexture( ${ textureProperty }, ${ wrapFunction }( ${ uvSnippet } ), ${ textureDimension }, u32( ${ levelSnippet } ) )`;
|
|
248
342
|
|
|
249
343
|
}
|
|
250
344
|
|
|
251
|
-
generateTextureLod( texture, textureProperty, uvSnippet, levelSnippet = '
|
|
345
|
+
generateTextureLod( texture, textureProperty, uvSnippet, depthSnippet, levelSnippet = '0u' ) {
|
|
252
346
|
|
|
253
|
-
this.
|
|
347
|
+
const wrapFunction = this.generateWrapFunction( texture );
|
|
348
|
+
const textureDimension = this.generateTextureDimension( texture, textureProperty, levelSnippet );
|
|
254
349
|
|
|
255
|
-
const
|
|
350
|
+
const coordSnippet = `vec2u( ${ wrapFunction }( ${ uvSnippet } ) * vec2f( ${ textureDimension } ) )`;
|
|
256
351
|
|
|
257
|
-
return
|
|
352
|
+
return this.generateTextureLoad( texture, textureProperty, coordSnippet, depthSnippet, levelSnippet );
|
|
258
353
|
|
|
259
354
|
}
|
|
260
355
|
|
|
261
356
|
generateTextureLoad( texture, textureProperty, uvIndexSnippet, depthSnippet, levelSnippet = '0u' ) {
|
|
262
357
|
|
|
263
|
-
if (
|
|
358
|
+
if ( texture.isVideoTexture === true || texture.isStorageTexture === true ) {
|
|
359
|
+
|
|
360
|
+
return `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;
|
|
264
361
|
|
|
265
|
-
|
|
362
|
+
} else if ( depthSnippet ) {
|
|
363
|
+
|
|
364
|
+
return `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, u32( ${ levelSnippet } ) )`;
|
|
266
365
|
|
|
267
366
|
} else {
|
|
268
367
|
|
|
269
|
-
return `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ levelSnippet } )`;
|
|
368
|
+
return `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, u32( ${ levelSnippet } ) )`;
|
|
270
369
|
|
|
271
370
|
}
|
|
272
371
|
|
|
@@ -278,9 +377,18 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
278
377
|
|
|
279
378
|
}
|
|
280
379
|
|
|
380
|
+
isSampleCompare( texture ) {
|
|
381
|
+
|
|
382
|
+
return texture.isDepthTexture === true && texture.compareFunction !== null;
|
|
383
|
+
|
|
384
|
+
}
|
|
385
|
+
|
|
281
386
|
isUnfilterable( texture ) {
|
|
282
387
|
|
|
283
|
-
return this.getComponentTypeFromTexture( texture ) !== 'float' ||
|
|
388
|
+
return this.getComponentTypeFromTexture( texture ) !== 'float' ||
|
|
389
|
+
( ! this.isAvailable( 'float32Filterable' ) && texture.isDataTexture === true && texture.type === FloatType ) ||
|
|
390
|
+
( this.isSampleCompare( texture ) === false && texture.minFilter === NearestFilter && texture.magFilter === NearestFilter ) ||
|
|
391
|
+
texture.isMultisampleRenderTargetTexture === true;
|
|
284
392
|
|
|
285
393
|
}
|
|
286
394
|
|
|
@@ -294,7 +402,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
294
402
|
|
|
295
403
|
} else if ( this.isUnfilterable( texture ) ) {
|
|
296
404
|
|
|
297
|
-
snippet = this.generateTextureLod( texture, textureProperty, uvSnippet, '0',
|
|
405
|
+
snippet = this.generateTextureLod( texture, textureProperty, uvSnippet, depthSnippet, '0', shaderStage );
|
|
298
406
|
|
|
299
407
|
} else {
|
|
300
408
|
|
|
@@ -386,7 +494,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
386
494
|
|
|
387
495
|
return name;
|
|
388
496
|
|
|
389
|
-
} else if ( type === 'buffer' || type === 'storageBuffer' ) {
|
|
497
|
+
} else if ( type === 'buffer' || type === 'storageBuffer' || type === 'indirectStorageBuffer' ) {
|
|
390
498
|
|
|
391
499
|
return `NodeBuffer_${ node.id }.${name}`;
|
|
392
500
|
|
|
@@ -430,46 +538,18 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
430
538
|
|
|
431
539
|
}
|
|
432
540
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
if ( node.isStorageTextureNode ) {
|
|
436
|
-
|
|
437
|
-
switch ( node.access ) {
|
|
438
|
-
|
|
439
|
-
case GPUStorageTextureAccess.ReadOnly:
|
|
440
|
-
|
|
441
|
-
return 'read';
|
|
442
|
-
|
|
443
|
-
case GPUStorageTextureAccess.WriteOnly:
|
|
444
|
-
|
|
445
|
-
return 'write';
|
|
541
|
+
getNodeAccess( node, shaderStage ) {
|
|
446
542
|
|
|
447
|
-
|
|
543
|
+
if ( shaderStage !== 'compute' )
|
|
544
|
+
return NodeAccess.READ_ONLY;
|
|
448
545
|
|
|
449
|
-
|
|
546
|
+
return node.access;
|
|
450
547
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
} else {
|
|
454
|
-
|
|
455
|
-
switch ( node.access ) {
|
|
456
|
-
|
|
457
|
-
case GPUBufferBindingType.Storage:
|
|
458
|
-
|
|
459
|
-
return 'read_write';
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
case GPUBufferBindingType.ReadOnlyStorage:
|
|
463
|
-
|
|
464
|
-
return 'read';
|
|
465
|
-
|
|
466
|
-
default:
|
|
467
|
-
|
|
468
|
-
return 'write';
|
|
548
|
+
}
|
|
469
549
|
|
|
470
|
-
|
|
550
|
+
getStorageAccess( node, shaderStage ) {
|
|
471
551
|
|
|
472
|
-
|
|
552
|
+
return accessNames[ this.getNodeAccess( node, shaderStage ) ];
|
|
473
553
|
|
|
474
554
|
}
|
|
475
555
|
|
|
@@ -491,17 +571,19 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
491
571
|
|
|
492
572
|
let texture = null;
|
|
493
573
|
|
|
574
|
+
const access = this.getNodeAccess( node, shaderStage );
|
|
575
|
+
|
|
494
576
|
if ( type === 'texture' || type === 'storageTexture' ) {
|
|
495
577
|
|
|
496
|
-
texture = new NodeSampledTexture( uniformNode.name, uniformNode.node, group,
|
|
578
|
+
texture = new NodeSampledTexture( uniformNode.name, uniformNode.node, group, access );
|
|
497
579
|
|
|
498
580
|
} else if ( type === 'cubeTexture' ) {
|
|
499
581
|
|
|
500
|
-
texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node, group,
|
|
582
|
+
texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node, group, access );
|
|
501
583
|
|
|
502
584
|
} else if ( type === 'texture3D' ) {
|
|
503
585
|
|
|
504
|
-
texture = new NodeSampledTexture3D( uniformNode.name, uniformNode.node, group,
|
|
586
|
+
texture = new NodeSampledTexture3D( uniformNode.name, uniformNode.node, group, access );
|
|
505
587
|
|
|
506
588
|
}
|
|
507
589
|
|
|
@@ -525,9 +607,10 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
525
607
|
|
|
526
608
|
}
|
|
527
609
|
|
|
528
|
-
} else if ( type === 'buffer' || type === 'storageBuffer' ) {
|
|
610
|
+
} else if ( type === 'buffer' || type === 'storageBuffer' || type === 'indirectStorageBuffer' ) {
|
|
611
|
+
|
|
612
|
+
const bufferClass = type === 'buffer' ? NodeUniformBuffer : NodeStorageBuffer;
|
|
529
613
|
|
|
530
|
-
const bufferClass = type === 'storageBuffer' ? NodeStorageBuffer : NodeUniformBuffer;
|
|
531
614
|
const buffer = new bufferClass( node, group );
|
|
532
615
|
buffer.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
533
616
|
|
|
@@ -702,6 +785,12 @@ ${ flowData.code }
|
|
|
702
785
|
|
|
703
786
|
}
|
|
704
787
|
|
|
788
|
+
getClipDistance() {
|
|
789
|
+
|
|
790
|
+
return 'varyings.hw_clip_distances';
|
|
791
|
+
|
|
792
|
+
}
|
|
793
|
+
|
|
705
794
|
isFlipY() {
|
|
706
795
|
|
|
707
796
|
return false;
|
|
@@ -764,6 +853,13 @@ ${ flowData.code }
|
|
|
764
853
|
|
|
765
854
|
}
|
|
766
855
|
|
|
856
|
+
enableHardwareClipping( planeCount ) {
|
|
857
|
+
|
|
858
|
+
this.enableClipDistances();
|
|
859
|
+
this.getBuiltin( 'clip_distances', 'hw_clip_distances', `array<f32, ${ planeCount } >`, 'vertex' );
|
|
860
|
+
|
|
861
|
+
}
|
|
862
|
+
|
|
767
863
|
getBuiltins( shaderStage ) {
|
|
768
864
|
|
|
769
865
|
const snippets = [];
|
|
@@ -1008,7 +1104,7 @@ ${ flowData.code }
|
|
|
1008
1104
|
|
|
1009
1105
|
if ( shaderStage === 'fragment' && this.isUnfilterable( texture ) === false && uniform.node.isStorageTextureNode !== true ) {
|
|
1010
1106
|
|
|
1011
|
-
if (
|
|
1107
|
+
if ( this.isSampleCompare( texture ) ) {
|
|
1012
1108
|
|
|
1013
1109
|
bindingSnippets.push( `@binding( ${ uniformIndexes.binding ++ } ) @group( ${ uniformIndexes.group } ) var ${ uniform.name }_sampler : sampler_comparison;` );
|
|
1014
1110
|
|
|
@@ -1053,7 +1149,7 @@ ${ flowData.code }
|
|
|
1053
1149
|
} else if ( uniform.node.isStorageTextureNode === true ) {
|
|
1054
1150
|
|
|
1055
1151
|
const format = getFormat( texture );
|
|
1056
|
-
const access = this.getStorageAccess( uniform.node );
|
|
1152
|
+
const access = this.getStorageAccess( uniform.node, shaderStage );
|
|
1057
1153
|
|
|
1058
1154
|
textureType = `texture_storage_2d<${ format }, ${ access }>`;
|
|
1059
1155
|
|
|
@@ -1067,16 +1163,16 @@ ${ flowData.code }
|
|
|
1067
1163
|
|
|
1068
1164
|
bindingSnippets.push( `@binding( ${ uniformIndexes.binding ++ } ) @group( ${ uniformIndexes.group } ) var ${ uniform.name } : ${ textureType };` );
|
|
1069
1165
|
|
|
1070
|
-
} else if ( uniform.type === 'buffer' || uniform.type === 'storageBuffer' ) {
|
|
1166
|
+
} else if ( uniform.type === 'buffer' || uniform.type === 'storageBuffer' || uniform.type === 'indirectStorageBuffer' ) {
|
|
1071
1167
|
|
|
1072
1168
|
const bufferNode = uniform.node;
|
|
1073
1169
|
const bufferType = this.getType( bufferNode.bufferType );
|
|
1074
1170
|
const bufferCount = bufferNode.bufferCount;
|
|
1075
1171
|
|
|
1076
|
-
const bufferCountSnippet = bufferCount > 0 ? ', ' + bufferCount : '';
|
|
1172
|
+
const bufferCountSnippet = bufferCount > 0 && uniform.type === 'buffer' ? ', ' + bufferCount : '';
|
|
1077
1173
|
const bufferTypeSnippet = bufferNode.isAtomic ? `atomic<${bufferType}>` : `${bufferType}`;
|
|
1078
1174
|
const bufferSnippet = `\t${ uniform.name } : array< ${ bufferTypeSnippet }${ bufferCountSnippet } >\n`;
|
|
1079
|
-
const bufferAccessMode = bufferNode.isStorageBufferNode ? `storage, ${ this.getStorageAccess( bufferNode ) }` : 'uniform';
|
|
1175
|
+
const bufferAccessMode = bufferNode.isStorageBufferNode ? `storage, ${ this.getStorageAccess( bufferNode, shaderStage ) }` : 'uniform';
|
|
1080
1176
|
|
|
1081
1177
|
bufferSnippets.push( this._getWGSLStructBinding( 'NodeBuffer_' + bufferNode.id, bufferSnippet, bufferAccessMode, uniformIndexes.binding ++, uniformIndexes.group ) );
|
|
1082
1178
|
|
|
@@ -1249,6 +1345,10 @@ ${ flowData.code }
|
|
|
1249
1345
|
|
|
1250
1346
|
result = this.renderer.hasFeature( 'float32-filterable' );
|
|
1251
1347
|
|
|
1348
|
+
} else if ( name === 'clipDistance' ) {
|
|
1349
|
+
|
|
1350
|
+
result = this.renderer.hasFeature( 'clip-distances' );
|
|
1351
|
+
|
|
1252
1352
|
}
|
|
1253
1353
|
|
|
1254
1354
|
supports[ name ] = result;
|
|
@@ -97,13 +97,21 @@ const parse = ( source ) => {
|
|
|
97
97
|
|
|
98
98
|
let resolvedType = type;
|
|
99
99
|
|
|
100
|
-
if ( resolvedType.startsWith( '
|
|
100
|
+
if ( resolvedType.startsWith( 'ptr' ) ) {
|
|
101
101
|
|
|
102
|
-
resolvedType =
|
|
102
|
+
resolvedType = 'pointer';
|
|
103
103
|
|
|
104
|
-
}
|
|
104
|
+
} else {
|
|
105
|
+
|
|
106
|
+
if ( resolvedType.startsWith( 'texture' ) ) {
|
|
107
|
+
|
|
108
|
+
resolvedType = type.split( '<' )[ 0 ];
|
|
105
109
|
|
|
106
|
-
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
resolvedType = wgslTypeLib[ resolvedType ];
|
|
113
|
+
|
|
114
|
+
}
|
|
107
115
|
|
|
108
116
|
inputs.push( new NodeFunctionInput( resolvedType, name ) );
|
|
109
117
|
|
|
@@ -108,6 +108,7 @@ class WebGPUAttributeUtils {
|
|
|
108
108
|
const buffer = backend.get( bufferAttribute ).buffer;
|
|
109
109
|
|
|
110
110
|
const array = bufferAttribute.array;
|
|
111
|
+
const isTypedArray = this._isTypedArray( array );
|
|
111
112
|
const updateRanges = bufferAttribute.updateRanges;
|
|
112
113
|
|
|
113
114
|
if ( updateRanges.length === 0 ) {
|
|
@@ -123,15 +124,21 @@ class WebGPUAttributeUtils {
|
|
|
123
124
|
|
|
124
125
|
} else {
|
|
125
126
|
|
|
127
|
+
const byteOffsetFactor = isTypedArray ? 1 : array.BYTES_PER_ELEMENT;
|
|
128
|
+
|
|
126
129
|
for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
|
|
127
130
|
|
|
128
131
|
const range = updateRanges[ i ];
|
|
132
|
+
|
|
133
|
+
const dataOffset = range.start * byteOffsetFactor;
|
|
134
|
+
const size = range.count * byteOffsetFactor;
|
|
135
|
+
|
|
129
136
|
device.queue.writeBuffer(
|
|
130
137
|
buffer,
|
|
131
138
|
0,
|
|
132
139
|
array,
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
dataOffset,
|
|
141
|
+
size
|
|
135
142
|
);
|
|
136
143
|
|
|
137
144
|
}
|
|
@@ -299,6 +306,12 @@ class WebGPUAttributeUtils {
|
|
|
299
306
|
|
|
300
307
|
}
|
|
301
308
|
|
|
309
|
+
_isTypedArray( array ) {
|
|
310
|
+
|
|
311
|
+
return ArrayBuffer.isView( array ) && ! ( array instanceof DataView );
|
|
312
|
+
|
|
313
|
+
}
|
|
314
|
+
|
|
302
315
|
_getBufferAttribute( attribute ) {
|
|
303
316
|
|
|
304
317
|
if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
|