super-three 0.157.1 → 0.160.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/README.md +6 -4
- package/build/three.cjs +3100 -1537
- package/build/three.js +3100 -1537
- package/build/three.min.js +1 -1
- package/build/three.module.js +3093 -1538
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +291 -0
- package/examples/jsm/controls/FlyControls.js +26 -0
- package/examples/jsm/controls/OrbitControls.js +62 -41
- package/examples/jsm/controls/TransformControls.js +27 -11
- package/examples/jsm/csm/CSMShader.js +53 -48
- package/examples/jsm/exporters/GLTFExporter.js +151 -3
- package/examples/jsm/exporters/USDZExporter.js +27 -19
- package/examples/jsm/geometries/InstancedPointsGeometry.js +174 -0
- package/examples/jsm/geometries/SDFGeometryGenerator.js +144 -0
- package/examples/jsm/helpers/TextureHelper.js +237 -0
- package/examples/jsm/interactive/HTMLMesh.js +9 -2
- package/examples/jsm/libs/lottie_canvas.module.js +6 -1
- package/examples/jsm/libs/opentype.module.js +13 -75
- package/examples/jsm/libs/surfaceNet.js +201 -0
- package/examples/jsm/lines/LineMaterial.js +16 -33
- package/examples/jsm/loaders/ColladaLoader.js +0 -6
- package/examples/jsm/loaders/DRACOLoader.js +4 -3
- package/examples/jsm/loaders/FBXLoader.js +294 -124
- package/examples/jsm/loaders/GLTFLoader.js +83 -6
- package/examples/jsm/loaders/LUTImageLoader.js +162 -0
- package/examples/jsm/loaders/MaterialXLoader.js +73 -54
- package/examples/jsm/loaders/NRRDLoader.js +0 -13
- package/examples/jsm/loaders/SVGLoader.js +4 -4
- package/examples/jsm/loaders/USDZLoader.js +3 -17
- package/examples/jsm/loaders/lwo/IFFParser.js +89 -93
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/math/Capsule.js +0 -55
- package/examples/jsm/math/Octree.js +85 -7
- package/examples/jsm/misc/Timer.js +119 -0
- package/examples/jsm/misc/TubePainter.js +3 -6
- package/examples/jsm/modifiers/CurveModifier.js +20 -2
- package/examples/jsm/modifiers/SimplifyModifier.js +103 -11
- package/examples/jsm/modifiers/TessellateModifier.js +3 -3
- package/examples/jsm/nodes/Nodes.js +16 -12
- package/examples/jsm/nodes/accessors/CameraNode.js +18 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +5 -73
- package/examples/jsm/nodes/accessors/InstanceNode.js +3 -3
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +68 -31
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +11 -2
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -2
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +12 -3
- package/examples/jsm/nodes/accessors/MorphNode.js +191 -16
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/ReferenceNode.js +25 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +13 -3
- package/examples/jsm/nodes/accessors/TextureNode.js +123 -37
- package/examples/jsm/nodes/code/CodeNode.js +3 -3
- package/examples/jsm/nodes/code/FunctionNode.js +1 -1
- package/examples/jsm/nodes/core/AssignNode.js +72 -0
- package/examples/jsm/nodes/core/AttributeNode.js +7 -1
- package/examples/jsm/nodes/core/CacheNode.js +4 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/LightingModel.js +3 -1
- package/examples/jsm/nodes/core/Node.js +13 -15
- package/examples/jsm/nodes/core/NodeBuilder.js +209 -42
- package/examples/jsm/nodes/core/NodeFrame.js +10 -8
- package/examples/jsm/nodes/core/NodeUniform.js +12 -0
- package/examples/jsm/nodes/core/NodeUtils.js +7 -9
- package/examples/jsm/nodes/core/OutputStructNode.js +4 -4
- package/examples/jsm/nodes/core/ParameterNode.js +33 -0
- package/examples/jsm/nodes/core/PropertyNode.js +15 -6
- package/examples/jsm/nodes/core/StackNode.js +7 -17
- package/examples/jsm/nodes/core/StructTypeNode.js +4 -4
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformGroup.js +13 -0
- package/examples/jsm/nodes/core/UniformGroupNode.js +36 -0
- package/examples/jsm/nodes/core/UniformNode.js +17 -0
- package/examples/jsm/nodes/core/VarNode.js +7 -34
- package/examples/jsm/nodes/core/VaryingNode.js +3 -7
- package/examples/jsm/nodes/display/BumpMapNode.js +35 -13
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +6 -10
- package/examples/jsm/nodes/display/GaussianBlurNode.js +170 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -1
- package/examples/jsm/nodes/display/PassNode.js +182 -0
- package/examples/jsm/nodes/display/ViewportDepthNode.js +31 -3
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportNode.js +17 -10
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +20 -6
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -7
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +8 -3
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +8 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +8 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +93 -43
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +55 -6
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -18
- package/examples/jsm/nodes/lighting/LightingContextNode.js +21 -57
- package/examples/jsm/nodes/lighting/LightsNode.js +80 -20
- package/examples/jsm/nodes/lighting/PointLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/SpotLightNode.js +1 -1
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +162 -0
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +76 -77
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +5 -5
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +47 -20
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/NodeMaterial.js +82 -60
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +10 -10
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +128 -54
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +1430 -618
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +24 -14
- package/examples/jsm/nodes/math/MathNode.js +2 -0
- package/examples/jsm/nodes/math/OperatorNode.js +24 -27
- package/examples/jsm/nodes/shadernode/ShaderNode.js +158 -10
- package/examples/jsm/nodes/utils/ArrayElementNode.js +2 -0
- package/examples/jsm/nodes/utils/DiscardNode.js +3 -2
- package/examples/jsm/nodes/utils/FunctionOverloadingNode.js +95 -0
- package/examples/jsm/nodes/utils/JoinNode.js +11 -1
- package/examples/jsm/nodes/utils/LoopNode.js +36 -24
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +10 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +3 -3
- package/examples/jsm/objects/InstancedPoints.js +21 -0
- package/examples/jsm/objects/Lensflare.js +20 -0
- package/examples/jsm/objects/QuadMesh.js +60 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -0
- package/examples/jsm/objects/Refractor.js +3 -0
- package/examples/jsm/objects/Sky.js +5 -3
- package/examples/jsm/objects/Water.js +5 -2
- package/examples/jsm/objects/Water2.js +3 -0
- package/examples/jsm/physics/AmmoPhysics.js +21 -0
- package/examples/jsm/physics/RapierPhysics.js +21 -0
- package/examples/jsm/postprocessing/BokehPass.js +3 -2
- package/examples/jsm/postprocessing/GTAOPass.js +572 -0
- package/examples/jsm/postprocessing/LUTPass.js +2 -1
- package/examples/jsm/postprocessing/OutputPass.js +3 -0
- package/examples/jsm/postprocessing/Pass.js +14 -3
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SMAAPass.js +0 -2
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +3 -9
- package/examples/jsm/renderers/SVGRenderer.js +9 -6
- package/examples/jsm/renderers/common/Animation.js +10 -21
- package/examples/jsm/renderers/common/Backend.js +19 -3
- package/examples/jsm/renderers/common/Background.js +20 -22
- package/examples/jsm/renderers/common/Bindings.js +31 -22
- package/examples/jsm/renderers/common/ChainMap.js +3 -3
- package/examples/jsm/renderers/common/Color4.js +37 -0
- package/examples/jsm/renderers/common/Geometries.js +4 -4
- package/examples/jsm/renderers/common/Info.js +12 -2
- package/examples/jsm/renderers/common/Pipelines.js +3 -51
- package/examples/jsm/renderers/common/PostProcessing.js +25 -0
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderContexts.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +21 -2
- package/examples/jsm/renderers/common/RenderObjects.js +5 -3
- package/examples/jsm/renderers/common/Renderer.js +137 -37
- package/examples/jsm/renderers/common/StorageTexture.js +1 -0
- package/examples/jsm/renderers/common/Textures.js +8 -37
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +10 -2
- package/examples/jsm/renderers/common/nodes/NodeUniformsGroup.js +44 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +121 -19
- package/examples/jsm/renderers/webgl/WebGLBackend.js +366 -67
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +183 -38
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +92 -5
- package/examples/jsm/renderers/webgl/utils/WebGLCapabilities.js +36 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +11 -1
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +14 -2
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +71 -2
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +42 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +33 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +4 -14
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +188 -137
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +1 -1
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +241 -90
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -10
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +11 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +2 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +88 -6
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +2 -0
- package/examples/jsm/shaders/AfterimageShader.js +2 -0
- package/examples/jsm/shaders/BasicShader.js +2 -0
- package/examples/jsm/shaders/BlendShader.js +2 -0
- package/examples/jsm/shaders/BokehShader.js +2 -0
- package/examples/jsm/shaders/BokehShader2.js +4 -0
- package/examples/jsm/shaders/BrightnessContrastShader.js +2 -0
- package/examples/jsm/shaders/ColorCorrectionShader.js +2 -0
- package/examples/jsm/shaders/DOFMipMapShader.js +2 -0
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +5 -0
- package/examples/jsm/shaders/FXAAShader.js +135 -133
- package/examples/jsm/shaders/FilmShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +2 -0
- package/examples/jsm/shaders/FreiChenShader.js +2 -0
- package/examples/jsm/shaders/GTAOShader.js +424 -0
- package/examples/jsm/shaders/GodRaysShader.js +8 -0
- package/examples/jsm/shaders/HalftoneShader.js +2 -0
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/HueSaturationShader.js +2 -0
- package/examples/jsm/shaders/KaleidoShader.js +2 -0
- package/examples/jsm/shaders/LuminosityHighPassShader.js +2 -0
- package/examples/jsm/shaders/LuminosityShader.js +2 -0
- package/examples/jsm/shaders/MMDToonShader.js +2 -0
- package/examples/jsm/shaders/MirrorShader.js +2 -0
- package/examples/jsm/shaders/NormalMapShader.js +2 -0
- package/examples/jsm/shaders/OutputShader.js +8 -5
- package/examples/jsm/shaders/PoissonDenoiseShader.js +226 -0
- package/examples/jsm/shaders/SAOShader.js +7 -3
- package/examples/jsm/shaders/SMAAShader.js +6 -0
- package/examples/jsm/shaders/SSAOShader.js +8 -3
- package/examples/jsm/shaders/SSRShader.js +6 -0
- package/examples/jsm/shaders/SobelOperatorShader.js +2 -0
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +2 -0
- package/examples/jsm/shaders/TechnicolorShader.js +2 -0
- package/examples/jsm/shaders/TriangleBlurShader.js +2 -0
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -0
- package/examples/jsm/shaders/VelocityShader.js +2 -0
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +2 -0
- package/examples/jsm/transpiler/AST.js +270 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +941 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +49 -0
- package/examples/jsm/transpiler/TSLEncoder.js +715 -0
- package/examples/jsm/transpiler/Transpiler.js +18 -0
- package/examples/jsm/utils/SortUtils.js +158 -0
- package/examples/jsm/utils/TextureUtils.js +33 -21
- package/examples/jsm/webxr/ARButton.js +14 -0
- package/examples/jsm/webxr/VRButton.js +24 -9
- package/examples/jsm/webxr/XRButton.js +27 -11
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +8 -6
- package/src/Three.js +1 -0
- package/src/constants.js +8 -1
- package/src/core/BufferAttribute.js +21 -2
- package/src/core/InterleavedBuffer.js +21 -1
- package/src/core/Object3D.js +60 -12
- package/src/core/UniformsGroup.js +7 -1
- package/src/extras/PMREMGenerator.js +7 -1
- package/src/extras/curves/LineCurve3.js +4 -0
- package/src/loaders/AudioLoader.js +1 -1
- package/src/loaders/BufferGeometryLoader.js +0 -7
- package/src/loaders/ImageBitmapLoader.js +25 -1
- package/src/loaders/MaterialLoader.js +10 -2
- package/src/loaders/ObjectLoader.js +49 -0
- package/src/materials/Material.js +27 -13
- package/src/materials/ShaderMaterial.js +2 -1
- package/src/math/Box3.js +35 -18
- package/src/math/ColorManagement.js +0 -16
- package/src/math/Quaternion.js +5 -4
- package/src/math/Sphere.js +2 -0
- package/src/math/Triangle.js +17 -5
- package/src/math/Vector3.js +11 -12
- package/src/objects/BatchedMesh.js +1020 -0
- package/src/objects/Skeleton.js +1 -3
- package/src/objects/SkinnedMesh.js +6 -7
- package/src/renderers/WebGL3DRenderTarget.js +2 -2
- package/src/renderers/WebGLArrayRenderTarget.js +2 -2
- package/src/renderers/WebGLRenderer.js +165 -43
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -2
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +0 -5
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +31 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +9 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +8 -6
- package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +9 -17
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +84 -0
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk.js +4 -0
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +39 -5
- package/src/renderers/webgl/WebGLBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
- package/src/renderers/webgl/WebGLExtensions.js +1 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLLights.js +11 -2
- package/src/renderers/webgl/WebGLProgram.js +100 -51
- package/src/renderers/webgl/WebGLPrograms.js +8 -0
- package/src/renderers/webgl/WebGLShadowMap.js +35 -0
- package/src/renderers/webgl/WebGLState.js +25 -4
- package/src/renderers/webgl/WebGLTextures.js +7 -11
- package/src/renderers/webgl/WebGLUniforms.js +11 -1
- package/src/renderers/webgl/WebGLUniformsGroups.js +72 -93
- package/src/renderers/webxr/WebXRManager.js +16 -0
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +0 -76
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +0 -29
|
@@ -7,7 +7,7 @@ import { GPUFeatureName, GPUTextureFormat, GPULoadOp, GPUStoreOp, GPUIndexFormat
|
|
|
7
7
|
import WGSLNodeBuilder from './nodes/WGSLNodeBuilder.js';
|
|
8
8
|
import Backend from '../common/Backend.js';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { DepthFormat, WebGPUCoordinateSystem } from 'three';
|
|
11
11
|
|
|
12
12
|
import WebGPUUtils from './utils/WebGPUUtils.js';
|
|
13
13
|
import WebGPUAttributeUtils from './utils/WebGPUAttributeUtils.js';
|
|
@@ -33,6 +33,8 @@ class WebGPUBackend extends Backend {
|
|
|
33
33
|
|
|
34
34
|
super( parameters );
|
|
35
35
|
|
|
36
|
+
this.isWebGPUBackend = true;
|
|
37
|
+
|
|
36
38
|
// some parameters require default values other than "undefined"
|
|
37
39
|
|
|
38
40
|
this.parameters.antialias = ( parameters.antialias === true );
|
|
@@ -54,9 +56,6 @@ class WebGPUBackend extends Backend {
|
|
|
54
56
|
this.context = null;
|
|
55
57
|
this.colorBuffer = null;
|
|
56
58
|
|
|
57
|
-
this.defaultDepthTexture = new DepthTexture();
|
|
58
|
-
this.defaultDepthTexture.name = 'depthBuffer';
|
|
59
|
-
|
|
60
59
|
this.utils = new WebGPUUtils( this );
|
|
61
60
|
this.attributeUtils = new WebGPUAttributeUtils( this );
|
|
62
61
|
this.bindingUtils = new WebGPUBindingUtils( this );
|
|
@@ -115,6 +114,13 @@ class WebGPUBackend extends Backend {
|
|
|
115
114
|
this.device = device;
|
|
116
115
|
this.context = context;
|
|
117
116
|
|
|
117
|
+
this.context.configure( {
|
|
118
|
+
device: this.device,
|
|
119
|
+
format: GPUTextureFormat.BGRA8Unorm,
|
|
120
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
|
|
121
|
+
alphaMode: 'premultiplied'
|
|
122
|
+
} );
|
|
123
|
+
|
|
118
124
|
this.updateSize();
|
|
119
125
|
|
|
120
126
|
}
|
|
@@ -216,7 +222,6 @@ class WebGPUBackend extends Backend {
|
|
|
216
222
|
resolveTarget,
|
|
217
223
|
loadOp: GPULoadOp.Load,
|
|
218
224
|
storeOp: GPUStoreOp.Store
|
|
219
|
-
|
|
220
225
|
} );
|
|
221
226
|
|
|
222
227
|
}
|
|
@@ -245,7 +250,7 @@ class WebGPUBackend extends Backend {
|
|
|
245
250
|
|
|
246
251
|
}
|
|
247
252
|
|
|
248
|
-
depthStencilAttachment.view = this.
|
|
253
|
+
depthStencilAttachment.view = this.textureUtils.getDepthBuffer( renderContext.depth, renderContext.stencil ).createView();
|
|
249
254
|
|
|
250
255
|
}
|
|
251
256
|
|
|
@@ -490,75 +495,166 @@ class WebGPUBackend extends Backend {
|
|
|
490
495
|
|
|
491
496
|
}
|
|
492
497
|
|
|
493
|
-
clear(
|
|
498
|
+
clear( color, depth, stencil, renderTargetData = null ) {
|
|
494
499
|
|
|
495
500
|
const device = this.device;
|
|
496
|
-
const
|
|
501
|
+
const renderer = this.renderer;
|
|
497
502
|
|
|
498
|
-
const
|
|
503
|
+
const colorAttachments = [];
|
|
499
504
|
|
|
500
|
-
|
|
501
|
-
|
|
505
|
+
let depthStencilAttachment;
|
|
506
|
+
let clearValue;
|
|
502
507
|
|
|
503
|
-
|
|
504
|
-
|
|
508
|
+
let supportsDepth;
|
|
509
|
+
let supportsStencil;
|
|
505
510
|
|
|
506
|
-
|
|
511
|
+
if ( color ) {
|
|
507
512
|
|
|
508
|
-
|
|
509
|
-
if ( antialias === true ) {
|
|
513
|
+
const clearColor = this.getClearColor();
|
|
510
514
|
|
|
511
|
-
|
|
512
|
-
colorAttachment.resolveTarget = this.context.getCurrentTexture().createView();
|
|
515
|
+
clearValue = { r: clearColor.r, g: clearColor.g, b: clearColor.b, a: clearColor.a };
|
|
513
516
|
|
|
514
|
-
}
|
|
517
|
+
}
|
|
515
518
|
|
|
516
|
-
|
|
517
|
-
colorAttachment.resolveTarget = undefined;
|
|
519
|
+
if ( renderTargetData === null ) {
|
|
518
520
|
|
|
519
|
-
|
|
521
|
+
supportsDepth = renderer.depth;
|
|
522
|
+
supportsStencil = renderer.stencil;
|
|
520
523
|
|
|
521
|
-
|
|
524
|
+
depth = depth && supportsDepth;
|
|
525
|
+
stencil = stencil && supportsStencil;
|
|
522
526
|
|
|
523
|
-
|
|
527
|
+
if ( color ) {
|
|
524
528
|
|
|
525
|
-
|
|
526
|
-
colorAttachment.clearValue = renderContext.clearColorValue;
|
|
529
|
+
const antialias = this.parameters.antialias;
|
|
527
530
|
|
|
528
|
-
|
|
531
|
+
const colorAttachment = {};
|
|
529
532
|
|
|
530
|
-
|
|
533
|
+
if ( antialias === true ) {
|
|
531
534
|
|
|
532
|
-
|
|
535
|
+
colorAttachment.view = this.colorBuffer.createView();
|
|
536
|
+
colorAttachment.resolveTarget = this.context.getCurrentTexture().createView();
|
|
537
|
+
|
|
538
|
+
} else {
|
|
539
|
+
|
|
540
|
+
colorAttachment.view = this.context.getCurrentTexture().createView();
|
|
541
|
+
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
colorAttachment.clearValue = clearValue;
|
|
545
|
+
colorAttachment.loadOp = GPULoadOp.Clear;
|
|
546
|
+
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
547
|
+
|
|
548
|
+
colorAttachments.push( colorAttachment );
|
|
549
|
+
|
|
550
|
+
}
|
|
533
551
|
|
|
534
|
-
|
|
552
|
+
if ( depth || stencil ) {
|
|
535
553
|
|
|
536
|
-
|
|
537
|
-
|
|
554
|
+
depthStencilAttachment = {
|
|
555
|
+
view: this.textureUtils.getDepthBuffer( renderer.depth, renderer.stencil ).createView()
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
}
|
|
538
559
|
|
|
539
560
|
} else {
|
|
540
561
|
|
|
541
|
-
|
|
562
|
+
supportsDepth = renderTargetData.depth;
|
|
563
|
+
supportsStencil = renderTargetData.stencil;
|
|
564
|
+
|
|
565
|
+
depth = depth && supportsDepth;
|
|
566
|
+
stencil = stencil && supportsStencil;
|
|
567
|
+
|
|
568
|
+
if ( color ) {
|
|
569
|
+
|
|
570
|
+
for ( const texture of renderTargetData.textures ) {
|
|
571
|
+
|
|
572
|
+
const textureData = this.get( texture );
|
|
573
|
+
const textureView = textureData.texture.createView();
|
|
574
|
+
|
|
575
|
+
let view, resolveTarget;
|
|
576
|
+
|
|
577
|
+
if ( textureData.msaaTexture !== undefined ) {
|
|
578
|
+
|
|
579
|
+
view = textureData.msaaTexture.createView();
|
|
580
|
+
resolveTarget = textureView;
|
|
581
|
+
|
|
582
|
+
} else {
|
|
583
|
+
|
|
584
|
+
view = textureView;
|
|
585
|
+
resolveTarget = undefined;
|
|
586
|
+
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
colorAttachments.push( {
|
|
590
|
+
view,
|
|
591
|
+
resolveTarget,
|
|
592
|
+
clearValue,
|
|
593
|
+
loadOp: GPULoadOp.Clear,
|
|
594
|
+
storeOp: GPUStoreOp.Store
|
|
595
|
+
} );
|
|
596
|
+
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if ( depth || stencil ) {
|
|
602
|
+
|
|
603
|
+
const depthTextureData = this.get( renderTargetData.depthTexture );
|
|
604
|
+
|
|
605
|
+
depthStencilAttachment = {
|
|
606
|
+
view: depthTextureData.texture.createView()
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
}
|
|
542
610
|
|
|
543
611
|
}
|
|
544
612
|
|
|
545
|
-
|
|
613
|
+
//
|
|
614
|
+
|
|
615
|
+
if ( depthStencilAttachment !== undefined ) {
|
|
546
616
|
|
|
547
|
-
|
|
548
|
-
depthStencilAttachment.stencilClearValue = renderContext.clearStencilValue;
|
|
617
|
+
if ( depth ) {
|
|
549
618
|
|
|
550
|
-
|
|
619
|
+
depthStencilAttachment.depthLoadOp = GPULoadOp.Clear;
|
|
620
|
+
depthStencilAttachment.depthClearValue = renderer.getClearDepth();
|
|
621
|
+
depthStencilAttachment.depthStoreOp = GPUStoreOp.Store;
|
|
622
|
+
|
|
623
|
+
} else {
|
|
624
|
+
|
|
625
|
+
depthStencilAttachment.depthLoadOp = GPULoadOp.Load;
|
|
626
|
+
depthStencilAttachment.depthStoreOp = GPUStoreOp.Store;
|
|
627
|
+
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
//
|
|
631
|
+
|
|
632
|
+
if ( stencil ) {
|
|
633
|
+
|
|
634
|
+
depthStencilAttachment.stencilLoadOp = GPULoadOp.Clear;
|
|
635
|
+
depthStencilAttachment.stencilClearValue = renderer.getClearStencil();
|
|
636
|
+
depthStencilAttachment.stencilStoreOp = GPUStoreOp.Store;
|
|
551
637
|
|
|
552
|
-
|
|
638
|
+
} else {
|
|
639
|
+
|
|
640
|
+
depthStencilAttachment.stencilLoadOp = GPULoadOp.Load;
|
|
641
|
+
depthStencilAttachment.stencilStoreOp = GPUStoreOp.Store;
|
|
642
|
+
|
|
643
|
+
}
|
|
553
644
|
|
|
554
645
|
}
|
|
555
646
|
|
|
556
|
-
|
|
557
|
-
renderContextData.currentPass = renderContextData.encoder.beginRenderPass( descriptor );
|
|
647
|
+
//
|
|
558
648
|
|
|
559
|
-
|
|
649
|
+
const encoder = device.createCommandEncoder( {} );
|
|
650
|
+
const currentPass = encoder.beginRenderPass( {
|
|
651
|
+
colorAttachments,
|
|
652
|
+
depthStencilAttachment
|
|
653
|
+
} );
|
|
654
|
+
|
|
655
|
+
currentPass.end();
|
|
560
656
|
|
|
561
|
-
device.queue.submit( [
|
|
657
|
+
device.queue.submit( [ encoder.finish() ] );
|
|
562
658
|
|
|
563
659
|
}
|
|
564
660
|
|
|
@@ -729,9 +825,9 @@ class WebGPUBackend extends Backend {
|
|
|
729
825
|
|
|
730
826
|
// cache key
|
|
731
827
|
|
|
732
|
-
|
|
828
|
+
needsRenderUpdate( renderObject ) {
|
|
733
829
|
|
|
734
|
-
const
|
|
830
|
+
const data = this.get( renderObject );
|
|
735
831
|
|
|
736
832
|
const { object, material } = renderObject;
|
|
737
833
|
|
|
@@ -745,15 +841,35 @@ class WebGPUBackend extends Backend {
|
|
|
745
841
|
|
|
746
842
|
let needsUpdate = false;
|
|
747
843
|
|
|
748
|
-
if (
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
844
|
+
if ( data.material !== material || data.materialVersion !== material.version ||
|
|
845
|
+
data.transparent !== material.transparent || data.blending !== material.blending || data.premultipliedAlpha !== material.premultipliedAlpha ||
|
|
846
|
+
data.blendSrc !== material.blendSrc || data.blendDst !== material.blendDst || data.blendEquation !== material.blendEquation ||
|
|
847
|
+
data.blendSrcAlpha !== material.blendSrcAlpha || data.blendDstAlpha !== material.blendDstAlpha || data.blendEquationAlpha !== material.blendEquationAlpha ||
|
|
848
|
+
data.colorWrite !== material.colorWrite || data.depthWrite !== material.depthWrite || data.depthTest !== material.depthTest || data.depthFunc !== material.depthFunc ||
|
|
849
|
+
data.stencilWrite !== material.stencilWrite || data.stencilFunc !== material.stencilFunc ||
|
|
850
|
+
data.stencilFail !== material.stencilFail || data.stencilZFail !== material.stencilZFail || data.stencilZPass !== material.stencilZPass ||
|
|
851
|
+
data.stencilFuncMask !== material.stencilFuncMask || data.stencilWriteMask !== material.stencilWriteMask ||
|
|
852
|
+
data.side !== material.side || data.alphaToCoverage !== material.alphaToCoverage ||
|
|
853
|
+
data.sampleCount !== sampleCount || data.colorSpace !== colorSpace ||
|
|
854
|
+
data.colorFormat !== colorFormat || data.depthStencilFormat !== depthStencilFormat ||
|
|
855
|
+
data.primitiveTopology !== primitiveTopology
|
|
856
|
+
) {
|
|
857
|
+
|
|
858
|
+
data.material = material; data.materialVersion = material.version;
|
|
859
|
+
data.transparent = material.transparent; data.blending = material.blending; data.premultipliedAlpha = material.premultipliedAlpha;
|
|
860
|
+
data.blendSrc = material.blendSrc; data.blendDst = material.blendDst; data.blendEquation = material.blendEquation;
|
|
861
|
+
data.blendSrcAlpha = material.blendSrcAlpha; data.blendDstAlpha = material.blendDstAlpha; data.blendEquationAlpha = material.blendEquationAlpha;
|
|
862
|
+
data.colorWrite = material.colorWrite;
|
|
863
|
+
data.depthWrite = material.depthWrite; data.depthTest = material.depthTest; data.depthFunc = material.depthFunc;
|
|
864
|
+
data.stencilWrite = material.stencilWrite; data.stencilFunc = material.stencilFunc;
|
|
865
|
+
data.stencilFail = material.stencilFail; data.stencilZFail = material.stencilZFail; data.stencilZPass = material.stencilZPass;
|
|
866
|
+
data.stencilFuncMask = material.stencilFuncMask; data.stencilWriteMask = material.stencilWriteMask;
|
|
867
|
+
data.side = material.side; data.alphaToCoverage = material.alphaToCoverage;
|
|
868
|
+
data.sampleCount = sampleCount;
|
|
869
|
+
data.colorSpace = colorSpace;
|
|
870
|
+
data.colorFormat = colorFormat;
|
|
871
|
+
data.depthStencilFormat = depthStencilFormat;
|
|
872
|
+
data.primitiveTopology = primitiveTopology;
|
|
757
873
|
|
|
758
874
|
needsUpdate = true;
|
|
759
875
|
|
|
@@ -763,7 +879,7 @@ class WebGPUBackend extends Backend {
|
|
|
763
879
|
|
|
764
880
|
}
|
|
765
881
|
|
|
766
|
-
|
|
882
|
+
getRenderCacheKey( renderObject ) {
|
|
767
883
|
|
|
768
884
|
const { object, material } = renderObject;
|
|
769
885
|
|
|
@@ -771,6 +887,15 @@ class WebGPUBackend extends Backend {
|
|
|
771
887
|
const renderContext = renderObject.context;
|
|
772
888
|
|
|
773
889
|
return [
|
|
890
|
+
material.transparent, material.blending, material.premultipliedAlpha,
|
|
891
|
+
material.blendSrc, material.blendDst, material.blendEquation,
|
|
892
|
+
material.blendSrcAlpha, material.blendDstAlpha, material.blendEquationAlpha,
|
|
893
|
+
material.colorWrite,
|
|
894
|
+
material.depthWrite, material.depthTest, material.depthFunc,
|
|
895
|
+
material.stencilWrite, material.stencilFunc,
|
|
896
|
+
material.stencilFail, material.stencilZFail, material.stencilZPass,
|
|
897
|
+
material.stencilFuncMask, material.stencilWriteMask,
|
|
898
|
+
material.side,
|
|
774
899
|
utils.getSampleCount( renderContext ),
|
|
775
900
|
utils.getCurrentColorSpace( renderContext ), utils.getCurrentColorFormat( renderContext ), utils.getCurrentDepthStencilFormat( renderContext ),
|
|
776
901
|
utils.getPrimitiveTopology( object, material )
|
|
@@ -925,13 +1050,18 @@ class WebGPUBackend extends Backend {
|
|
|
925
1050
|
|
|
926
1051
|
updateSize() {
|
|
927
1052
|
|
|
928
|
-
this.
|
|
929
|
-
|
|
930
|
-
|
|
1053
|
+
this.colorBuffer = this.textureUtils.getColorBuffer();
|
|
1054
|
+
|
|
931
1055
|
}
|
|
932
1056
|
|
|
933
1057
|
// utils public
|
|
934
1058
|
|
|
1059
|
+
getMaxAnisotropy() {
|
|
1060
|
+
|
|
1061
|
+
return 16;
|
|
1062
|
+
|
|
1063
|
+
}
|
|
1064
|
+
|
|
935
1065
|
hasFeature( name ) {
|
|
936
1066
|
|
|
937
1067
|
const adapter = this.adapter || _staticAdapter;
|
|
@@ -966,7 +1096,7 @@ class WebGPUBackend extends Backend {
|
|
|
966
1096
|
|
|
967
1097
|
} else if ( texture.isDepthTexture ) {
|
|
968
1098
|
|
|
969
|
-
sourceGPU = this.
|
|
1099
|
+
sourceGPU = this.textureUtils.getDepthBuffer( renderContext.depth, renderContext.stencil );
|
|
970
1100
|
|
|
971
1101
|
}
|
|
972
1102
|
|
|
@@ -999,85 +1129,6 @@ class WebGPUBackend extends Backend {
|
|
|
999
1129
|
|
|
1000
1130
|
}
|
|
1001
1131
|
|
|
1002
|
-
// utils
|
|
1003
|
-
|
|
1004
|
-
_getDepthBufferGPU( renderContext ) {
|
|
1005
|
-
|
|
1006
|
-
const { width, height } = this.getDrawingBufferSize();
|
|
1007
|
-
|
|
1008
|
-
const depthTexture = this.defaultDepthTexture;
|
|
1009
|
-
const depthTextureGPU = this.get( depthTexture ).texture;
|
|
1010
|
-
|
|
1011
|
-
let format, type;
|
|
1012
|
-
|
|
1013
|
-
if ( renderContext.stencil ) {
|
|
1014
|
-
|
|
1015
|
-
format = DepthStencilFormat;
|
|
1016
|
-
type = UnsignedInt248Type;
|
|
1017
|
-
|
|
1018
|
-
} else if ( renderContext.depth ) {
|
|
1019
|
-
|
|
1020
|
-
format = DepthFormat;
|
|
1021
|
-
type = UnsignedIntType;
|
|
1022
|
-
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
if ( depthTextureGPU !== undefined ) {
|
|
1026
|
-
|
|
1027
|
-
if ( depthTexture.image.width === width && depthTexture.image.height === height && depthTexture.format === format && depthTexture.type === type ) {
|
|
1028
|
-
|
|
1029
|
-
return depthTextureGPU;
|
|
1030
|
-
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
this.textureUtils.destroyTexture( depthTexture );
|
|
1034
|
-
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
depthTexture.name = 'depthBuffer';
|
|
1038
|
-
depthTexture.format = format;
|
|
1039
|
-
depthTexture.type = type;
|
|
1040
|
-
depthTexture.image.width = width;
|
|
1041
|
-
depthTexture.image.height = height;
|
|
1042
|
-
|
|
1043
|
-
this.textureUtils.createTexture( depthTexture, { sampleCount: this.parameters.sampleCount, width, height } );
|
|
1044
|
-
|
|
1045
|
-
return this.get( depthTexture ).texture;
|
|
1046
|
-
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
_configureContext() {
|
|
1050
|
-
|
|
1051
|
-
this.context.configure( {
|
|
1052
|
-
device: this.device,
|
|
1053
|
-
format: GPUTextureFormat.BGRA8Unorm,
|
|
1054
|
-
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
|
|
1055
|
-
alphaMode: 'premultiplied'
|
|
1056
|
-
} );
|
|
1057
|
-
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
_setupColorBuffer() {
|
|
1061
|
-
|
|
1062
|
-
if ( this.colorBuffer ) this.colorBuffer.destroy();
|
|
1063
|
-
|
|
1064
|
-
const { width, height } = this.getDrawingBufferSize();
|
|
1065
|
-
//const format = navigator.gpu.getPreferredCanvasFormat(); // @TODO: Move to WebGPUUtils
|
|
1066
|
-
|
|
1067
|
-
this.colorBuffer = this.device.createTexture( {
|
|
1068
|
-
label: 'colorBuffer',
|
|
1069
|
-
size: {
|
|
1070
|
-
width: width,
|
|
1071
|
-
height: height,
|
|
1072
|
-
depthOrArrayLayers: 1
|
|
1073
|
-
},
|
|
1074
|
-
sampleCount: this.parameters.sampleCount,
|
|
1075
|
-
format: GPUTextureFormat.BGRA8Unorm,
|
|
1076
|
-
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC
|
|
1077
|
-
} );
|
|
1078
|
-
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
1132
|
}
|
|
1082
1133
|
|
|
1083
1134
|
export default WebGPUBackend;
|