@plastic-software/three 0.182.0 → 0.183.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/LICENSE +1 -1
- package/build/three.cjs +11521 -10878
- package/build/three.core.js +11732 -11340
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +510 -263
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +7 -11
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +3072 -2607
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +3071 -2607
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -3
- package/examples/jsm/animation/CCDIKSolver.js +2 -2
- package/examples/jsm/controls/ArcballControls.js +3 -3
- package/examples/jsm/controls/OrbitControls.js +103 -0
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +1 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +131 -4
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Inspector.js +21 -5
- package/examples/jsm/inspector/tabs/Console.js +39 -5
- package/examples/jsm/inspector/tabs/Parameters.js +16 -0
- package/examples/jsm/inspector/ui/Style.js +25 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
- package/examples/jsm/lines/LineMaterial.js +6 -0
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +122 -171
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +5 -5
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +3 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +182 -30
- package/examples/jsm/loaders/VRMLLoader.js +77 -0
- package/examples/jsm/loaders/VTKLoader.js +37 -24
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/usd/USDAParser.js +447 -366
- package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Sky.js +76 -4
- package/examples/jsm/objects/SkyMesh.js +114 -7
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/JoltPhysics.js +7 -5
- package/examples/jsm/physics/RapierPhysics.js +6 -4
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/SVGRenderer.js +2 -2
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +456 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/examples/jsm/tsl/display/BloomNode.js +5 -5
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +2 -2
- package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +3 -3
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +5 -5
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -7
- package/examples/jsm/tsl/display/SSSNode.js +2 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TRAANode.js +9 -12
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/math/Bayer.js +40 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/package.json +11 -19
- package/src/Three.Core.js +1 -1
- package/src/Three.TSL.js +5 -9
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/KeyframeTrack.js +46 -7
- package/src/animation/PropertyMixer.js +4 -4
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +30 -1
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +56 -4
- package/src/core/RenderTarget.js +3 -4
- package/src/extras/PMREMGenerator.js +4 -8
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +0 -24
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/LightShadow.js +15 -3
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/ImageBitmapLoader.js +8 -3
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/ObjectLoader.js +18 -1
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/nodes/Line2NodeMaterial.js +5 -5
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -0
- package/src/materials/nodes/NodeMaterial.js +15 -24
- package/src/materials/nodes/manager/NodeMaterialObserver.js +9 -3
- package/src/math/Line3.js +3 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix4.js +35 -26
- package/src/math/Quaternion.js +3 -29
- package/src/math/Vector3.js +3 -3
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +87 -68
- package/src/nodes/TSL.js +2 -5
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/InstanceNode.js +105 -40
- package/src/nodes/accessors/Normal.js +9 -9
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +12 -24
- package/src/nodes/accessors/StorageBufferNode.js +0 -19
- package/src/nodes/accessors/StorageTextureNode.js +37 -1
- package/src/nodes/accessors/Tangent.js +3 -3
- package/src/nodes/accessors/Texture3DNode.js +6 -34
- package/src/nodes/accessors/TextureNode.js +58 -22
- package/src/nodes/accessors/UniformArrayNode.js +2 -0
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +29 -3
- package/src/nodes/core/NodeBuilder.js +115 -40
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +2 -1
- package/src/nodes/core/StackNode.js +9 -8
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +15 -0
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformNode.js +2 -1
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -18
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +21 -2
- package/src/nodes/display/RenderOutputNode.js +3 -3
- package/src/nodes/display/ScreenNode.js +2 -1
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportTextureNode.js +21 -4
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/PhysicalLightingModel.js +25 -3
- package/src/nodes/geometry/RangeNode.js +4 -2
- package/src/nodes/gpgpu/ComputeNode.js +5 -4
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/PointShadowNode.js +24 -12
- package/src/nodes/lighting/ShadowFilterNode.js +15 -43
- package/src/nodes/lighting/ShadowNode.js +54 -32
- package/src/nodes/math/ConditionalNode.js +2 -2
- package/src/nodes/math/MathNode.js +3 -40
- package/src/nodes/math/OperatorNode.js +2 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLCore.js +13 -10
- package/src/nodes/utils/DebugNode.js +11 -11
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +2 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +4 -2
- package/src/objects/BatchedMesh.js +22 -12
- package/src/objects/InstancedMesh.js +11 -0
- package/src/renderers/WebGLRenderer.js +34 -60
- package/src/renderers/common/Backend.js +21 -0
- package/src/renderers/common/Background.js +7 -4
- package/src/renderers/common/BindGroup.js +1 -9
- package/src/renderers/common/Bindings.js +20 -5
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +50 -6
- package/src/renderers/common/Geometries.js +17 -3
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +4 -4
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/RenderBundles.js +2 -1
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -56
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +2 -3
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +18 -2
- package/src/renderers/common/RenderPipeline.js +203 -17
- package/src/renderers/common/Renderer.js +207 -40
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +16 -0
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +60 -0
- package/src/renderers/common/XRManager.js +2 -2
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +23 -1
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +55 -24
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +4 -2
- package/src/renderers/shaders/UniformsLib.js +0 -3
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +2 -2
- package/src/renderers/webgl/WebGLPrograms.js +10 -4
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +5 -4
- package/src/renderers/webgl/WebGLState.js +12 -17
- package/src/renderers/webgl-fallback/WebGLBackend.js +71 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +98 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +168 -7
- package/src/renderers/webgpu/WebGPUBackend.js +58 -9
- package/src/renderers/webgpu/WebGPURenderer.js +1 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +257 -45
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +8 -19
- package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -31
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +25 -25
- package/src/renderers/webgpu/utils/WebGPUUtils.js +10 -6
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +246 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -433
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -3,9 +3,10 @@ import {
|
|
|
3
3
|
GPUSamplerBindingType, GPUShaderStage
|
|
4
4
|
} from './WebGPUConstants.js';
|
|
5
5
|
|
|
6
|
-
import { FloatType, IntType, UnsignedIntType } from '../../../constants.js';
|
|
6
|
+
import { FloatType, IntType, UnsignedIntType, Compatibility } from '../../../constants.js';
|
|
7
7
|
import { NodeAccess } from '../../../nodes/core/constants.js';
|
|
8
8
|
import { isTypedArray, error } from '../../../utils.js';
|
|
9
|
+
import { hashString } from '../../../nodes/core/NodeUtils.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Class representing a WebGPU bind group layout.
|
|
@@ -99,7 +100,7 @@ class WebGPUBindingUtils {
|
|
|
99
100
|
// if not, assing one
|
|
100
101
|
|
|
101
102
|
const entries = this._createLayoutEntries( bindGroup );
|
|
102
|
-
const bindGroupLayoutKey = JSON.stringify( entries );
|
|
103
|
+
const bindGroupLayoutKey = hashString( JSON.stringify( entries ) );
|
|
103
104
|
|
|
104
105
|
// try to find an existing layout in the cache
|
|
105
106
|
|
|
@@ -224,8 +225,6 @@ class WebGPUBindingUtils {
|
|
|
224
225
|
|
|
225
226
|
}
|
|
226
227
|
|
|
227
|
-
binding.clearUpdateRanges();
|
|
228
|
-
|
|
229
228
|
}
|
|
230
229
|
|
|
231
230
|
}
|
|
@@ -325,20 +324,9 @@ class WebGPUBindingUtils {
|
|
|
325
324
|
|
|
326
325
|
} else if ( binding.isStorageBuffer ) {
|
|
327
326
|
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
if ( bindingData.buffer === undefined ) {
|
|
331
|
-
|
|
332
|
-
const attribute = binding.attribute;
|
|
333
|
-
//const usage = GPUBufferUsage.STORAGE | GPUBufferUsage.VERTEX | /*GPUBufferUsage.COPY_SRC |*/ GPUBufferUsage.COPY_DST;
|
|
334
|
-
|
|
335
|
-
//backend.attributeUtils.createAttribute( attribute, usage ); // @TODO: Move it to universal renderer
|
|
327
|
+
const buffer = backend.get( binding.attribute ).buffer;
|
|
336
328
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
entriesGPU.push( { binding: bindingPoint, resource: { buffer: bindingData.buffer } } );
|
|
329
|
+
entriesGPU.push( { binding: bindingPoint, resource: { buffer: buffer } } );
|
|
342
330
|
|
|
343
331
|
} else if ( binding.isSampledTexture ) {
|
|
344
332
|
|
|
@@ -582,12 +570,13 @@ class WebGPUBindingUtils {
|
|
|
582
570
|
|
|
583
571
|
if ( binding.texture.isDepthTexture ) {
|
|
584
572
|
|
|
585
|
-
if ( binding.texture.compareFunction !== null ) {
|
|
573
|
+
if ( binding.texture.compareFunction !== null && backend.hasCompatibility( Compatibility.TEXTURE_COMPARE ) ) {
|
|
586
574
|
|
|
587
575
|
sampler.type = GPUSamplerBindingType.Comparison;
|
|
588
576
|
|
|
589
|
-
} else
|
|
577
|
+
} else {
|
|
590
578
|
|
|
579
|
+
// Depth textures without compare must use non-filtering sampler
|
|
591
580
|
sampler.type = GPUSamplerBindingType.NonFiltering;
|
|
592
581
|
|
|
593
582
|
}
|
|
@@ -6,7 +6,7 @@ export const GPUPrimitiveTopology = {
|
|
|
6
6
|
TriangleStrip: 'triangle-strip',
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export const GPUShaderStage = ( typeof self !== 'undefined' ) ? self.GPUShaderStage : { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };
|
|
9
|
+
export const GPUShaderStage = ( typeof self !== 'undefined' && self.GPUShaderStage ) ? self.GPUShaderStage : { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };
|
|
10
10
|
|
|
11
11
|
export const GPUCompareFunction = {
|
|
12
12
|
Never: 'never',
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
BackSide, DoubleSide,
|
|
9
9
|
NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth,
|
|
10
|
-
NoBlending, NormalBlending, AdditiveBlending, SubtractiveBlending, MultiplyBlending, CustomBlending,
|
|
10
|
+
NoBlending, NormalBlending, AdditiveBlending, SubtractiveBlending, MultiplyBlending, CustomBlending, MaterialBlending,
|
|
11
11
|
ZeroFactor, OneFactor, SrcColorFactor, OneMinusSrcColorFactor, SrcAlphaFactor, OneMinusSrcAlphaFactor, DstColorFactor,
|
|
12
12
|
OneMinusDstColorFactor, DstAlphaFactor, OneMinusDstAlphaFactor, SrcAlphaSaturateFactor,
|
|
13
13
|
AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
NeverStencilFunc, AlwaysStencilFunc, LessStencilFunc, LessEqualStencilFunc, EqualStencilFunc, GreaterEqualStencilFunc, GreaterStencilFunc, NotEqualStencilFunc
|
|
16
16
|
} from '../../../constants.js';
|
|
17
17
|
|
|
18
|
-
import { error } from '../../../utils.js';
|
|
18
|
+
import { error, ReversedDepthFuncs, warnOnce } from '../../../utils.js';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* A WebGPU backend utility module for managing pipelines.
|
|
@@ -116,13 +116,13 @@ class WebGPUPipelineUtils {
|
|
|
116
116
|
|
|
117
117
|
const vertexBuffers = backend.attributeUtils.createShaderVertexBuffers( renderObject );
|
|
118
118
|
|
|
119
|
-
// blending
|
|
119
|
+
// material blending
|
|
120
120
|
|
|
121
|
-
let
|
|
121
|
+
let materialBlending;
|
|
122
122
|
|
|
123
123
|
if ( material.blending !== NoBlending && ( material.blending !== NormalBlending || material.transparent !== false ) ) {
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
materialBlending = this._getBlending( material );
|
|
126
126
|
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -148,28 +148,53 @@ class WebGPUPipelineUtils {
|
|
|
148
148
|
if ( renderObject.context.textures !== null ) {
|
|
149
149
|
|
|
150
150
|
const textures = renderObject.context.textures;
|
|
151
|
+
const mrt = renderObject.context.mrt;
|
|
151
152
|
|
|
152
153
|
for ( let i = 0; i < textures.length; i ++ ) {
|
|
153
154
|
|
|
154
|
-
const
|
|
155
|
+
const texture = textures[ i ];
|
|
156
|
+
const colorFormat = utils.getTextureFormatGPU( texture );
|
|
155
157
|
|
|
156
|
-
|
|
158
|
+
// mrt blending
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
let blending;
|
|
161
|
+
|
|
162
|
+
if ( mrt !== null ) {
|
|
163
|
+
|
|
164
|
+
if ( this.backend.compatibilityMode !== true ) {
|
|
165
|
+
|
|
166
|
+
const blendMode = mrt.getBlendMode( texture.name );
|
|
167
|
+
|
|
168
|
+
if ( blendMode.blending === MaterialBlending ) {
|
|
169
|
+
|
|
170
|
+
blending = materialBlending;
|
|
171
|
+
|
|
172
|
+
} else if ( blendMode.blending !== NoBlending ) {
|
|
173
|
+
|
|
174
|
+
blending = this._getBlending( blendMode );
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
} else {
|
|
179
|
+
|
|
180
|
+
warnOnce( 'WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.' );
|
|
181
|
+
|
|
182
|
+
blending = materialBlending;
|
|
183
|
+
|
|
184
|
+
}
|
|
163
185
|
|
|
164
186
|
} else {
|
|
165
187
|
|
|
166
|
-
|
|
167
|
-
format: colorFormat,
|
|
168
|
-
writeMask: colorWriteMask
|
|
169
|
-
} );
|
|
188
|
+
blending = materialBlending;
|
|
170
189
|
|
|
171
190
|
}
|
|
172
191
|
|
|
192
|
+
targets.push( {
|
|
193
|
+
format: colorFormat,
|
|
194
|
+
blend: blending,
|
|
195
|
+
writeMask: colorWriteMask
|
|
196
|
+
} );
|
|
197
|
+
|
|
173
198
|
}
|
|
174
199
|
|
|
175
200
|
} else {
|
|
@@ -178,7 +203,7 @@ class WebGPUPipelineUtils {
|
|
|
178
203
|
|
|
179
204
|
targets.push( {
|
|
180
205
|
format: colorFormat,
|
|
181
|
-
blend:
|
|
206
|
+
blend: materialBlending,
|
|
182
207
|
writeMask: colorWriteMask
|
|
183
208
|
} );
|
|
184
209
|
|
|
@@ -225,7 +250,7 @@ class WebGPUPipelineUtils {
|
|
|
225
250
|
if ( renderStencil === true ) {
|
|
226
251
|
|
|
227
252
|
depthStencil.stencilFront = stencilFront;
|
|
228
|
-
depthStencil.stencilBack =
|
|
253
|
+
depthStencil.stencilBack = stencilFront; // apply the same stencil ops to both faces, matching gl.stencilOp() which is not face-separated
|
|
229
254
|
depthStencil.stencilReadMask = material.stencilFuncMask;
|
|
230
255
|
depthStencil.stencilWriteMask = material.stencilWriteMask;
|
|
231
256
|
|
|
@@ -362,24 +387,24 @@ class WebGPUPipelineUtils {
|
|
|
362
387
|
* for the pipeline creation.
|
|
363
388
|
*
|
|
364
389
|
* @private
|
|
365
|
-
* @param {Material}
|
|
390
|
+
* @param {Material|BlendMode} object - The object containing blending information.
|
|
366
391
|
* @return {Object} The blending state.
|
|
367
392
|
*/
|
|
368
|
-
_getBlending(
|
|
393
|
+
_getBlending( object ) {
|
|
369
394
|
|
|
370
395
|
let color, alpha;
|
|
371
396
|
|
|
372
|
-
const blending =
|
|
373
|
-
const blendSrc =
|
|
374
|
-
const blendDst =
|
|
375
|
-
const blendEquation =
|
|
397
|
+
const blending = object.blending;
|
|
398
|
+
const blendSrc = object.blendSrc;
|
|
399
|
+
const blendDst = object.blendDst;
|
|
400
|
+
const blendEquation = object.blendEquation;
|
|
376
401
|
|
|
377
402
|
|
|
378
403
|
if ( blending === CustomBlending ) {
|
|
379
404
|
|
|
380
|
-
const blendSrcAlpha =
|
|
381
|
-
const blendDstAlpha =
|
|
382
|
-
const blendEquationAlpha =
|
|
405
|
+
const blendSrcAlpha = object.blendSrcAlpha !== null ? object.blendSrcAlpha : blendSrc;
|
|
406
|
+
const blendDstAlpha = object.blendDstAlpha !== null ? object.blendDstAlpha : blendDst;
|
|
407
|
+
const blendEquationAlpha = object.blendEquationAlpha !== null ? object.blendEquationAlpha : blendEquation;
|
|
383
408
|
|
|
384
409
|
color = {
|
|
385
410
|
srcFactor: this._getBlendFactor( blendSrc ),
|
|
@@ -395,7 +420,7 @@ class WebGPUPipelineUtils {
|
|
|
395
420
|
|
|
396
421
|
} else {
|
|
397
422
|
|
|
398
|
-
const premultipliedAlpha =
|
|
423
|
+
const premultipliedAlpha = object.premultipliedAlpha;
|
|
399
424
|
|
|
400
425
|
const setBlend = ( srcRGB, dstRGB, srcAlpha, dstAlpha ) => {
|
|
401
426
|
|
|
@@ -448,11 +473,11 @@ class WebGPUPipelineUtils {
|
|
|
448
473
|
break;
|
|
449
474
|
|
|
450
475
|
case SubtractiveBlending:
|
|
451
|
-
error(
|
|
476
|
+
error( `WebGPURenderer: "SubtractiveBlending" requires "${ object.isMaterial ? 'material' : 'blendMode' }.premultipliedAlpha = true".` );
|
|
452
477
|
break;
|
|
453
478
|
|
|
454
479
|
case MultiplyBlending:
|
|
455
|
-
error(
|
|
480
|
+
error( `WebGPURenderer: "MultiplyBlending" requires "${ object.isMaterial ? 'material' : 'blendMode' }.premultipliedAlpha = true".` );
|
|
456
481
|
break;
|
|
457
482
|
|
|
458
483
|
}
|
|
@@ -769,7 +794,7 @@ class WebGPUPipelineUtils {
|
|
|
769
794
|
|
|
770
795
|
} else {
|
|
771
796
|
|
|
772
|
-
const depthFunc = material.depthFunc;
|
|
797
|
+
const depthFunc = ( this.backend.parameters.reversedDepthBuffer ) ? ReversedDepthFuncs[ material.depthFunc ] : material.depthFunc;
|
|
773
798
|
|
|
774
799
|
switch ( depthFunc ) {
|
|
775
800
|
|