super-three 0.154.1 → 0.156.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +360 -160
- package/build/three.js +360 -160
- package/build/three.min.js +1 -1
- package/build/three.module.js +355 -161
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +155 -25
- package/examples/jsm/csm/CSMShader.js +35 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +1 -0
- package/examples/jsm/interactive/SelectionHelper.js +7 -0
- package/examples/jsm/libs/tween.module.js +790 -735
- package/examples/jsm/libs/utif.module.js +1644 -1558
- package/examples/jsm/loaders/DDSLoader.js +46 -3
- package/examples/jsm/loaders/EXRLoader.js +4 -4
- package/examples/jsm/loaders/FBXLoader.js +3 -1
- package/examples/jsm/loaders/GLTFLoader.js +25 -10
- package/examples/jsm/loaders/KTX2Loader.js +128 -79
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LogLuvLoader.js +2 -2
- package/examples/jsm/loaders/MMDLoader.js +10 -7
- package/examples/jsm/loaders/NRRDLoader.js +3 -3
- package/examples/jsm/loaders/PLYLoader.js +1 -1
- package/examples/jsm/loaders/RGBELoader.js +48 -66
- package/examples/jsm/loaders/STLLoader.js +7 -0
- package/examples/jsm/loaders/TGALoader.js +10 -10
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -9
- package/examples/jsm/misc/Volume.js +4 -6
- package/examples/jsm/nodes/Nodes.js +8 -6
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +29 -3
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +20 -3
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +15 -4
- package/examples/jsm/nodes/accessors/InstanceNode.js +8 -8
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +31 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +73 -61
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +3 -0
- package/examples/jsm/nodes/accessors/Object3DNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +6 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +54 -9
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
- package/examples/jsm/nodes/core/AttributeNode.js +2 -2
- package/examples/jsm/nodes/core/LightingModel.js +7 -9
- package/examples/jsm/nodes/core/Node.js +28 -3
- package/examples/jsm/nodes/core/NodeBuilder.js +94 -12
- package/examples/jsm/nodes/core/NodeUniform.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +58 -0
- package/examples/jsm/nodes/core/PropertyNode.js +6 -0
- package/examples/jsm/nodes/core/StackNode.js +4 -4
- package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
- package/examples/jsm/nodes/display/BumpMapNode.js +77 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportNode.js +19 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -2
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +13 -0
- package/examples/jsm/nodes/functions/PhongLightingModel.js +53 -14
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +236 -97
- package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +13 -0
- package/examples/jsm/nodes/lighting/AONode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +58 -20
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +7 -10
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +22 -12
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightingContextNode.js +12 -9
- package/examples/jsm/nodes/lighting/PointLightNode.js +7 -10
- package/examples/jsm/nodes/lighting/SpotLightNode.js +7 -10
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
- package/examples/jsm/nodes/materials/Materials.js +2 -0
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -0
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +19 -2
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/NodeMaterial.js +61 -26
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
- package/examples/jsm/nodes/math/HashNode.js +35 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +6 -2
- package/examples/jsm/nodes/utils/SplitNode.js +1 -1
- package/examples/jsm/objects/Reflector.js +1 -9
- package/examples/jsm/objects/Refractor.js +0 -8
- package/examples/jsm/offscreen/scene.js +0 -1
- package/examples/jsm/postprocessing/FilmPass.js +3 -5
- package/examples/jsm/postprocessing/MaskPass.js +4 -1
- package/examples/jsm/postprocessing/OutputPass.js +33 -14
- package/examples/jsm/postprocessing/RenderPass.js +30 -12
- package/examples/jsm/postprocessing/SAOPass.js +23 -98
- package/examples/jsm/postprocessing/SSAOPass.js +10 -30
- package/examples/jsm/postprocessing/UnrealBloomPass.js +21 -17
- package/examples/jsm/renderers/common/Backend.js +11 -8
- package/examples/jsm/renderers/common/Background.js +22 -20
- package/examples/jsm/renderers/common/Binding.js +14 -0
- package/examples/jsm/renderers/common/Bindings.js +7 -10
- package/examples/jsm/renderers/common/Geometries.js +1 -1
- package/examples/jsm/renderers/common/Pipelines.js +96 -47
- package/examples/jsm/renderers/common/RenderContext.js +1 -0
- package/examples/jsm/renderers/common/RenderContexts.js +41 -5
- package/examples/jsm/renderers/common/RenderList.js +12 -4
- package/examples/jsm/renderers/common/RenderObject.js +26 -6
- package/examples/jsm/renderers/common/RenderObjects.js +10 -7
- package/examples/jsm/renderers/common/Renderer.js +82 -42
- package/examples/jsm/renderers/common/SampledTexture.js +2 -1
- package/examples/jsm/renderers/common/Sampler.js +1 -1
- package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
- package/examples/jsm/renderers/common/Textures.js +172 -20
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +58 -13
- package/examples/jsm/renderers/webgl/WebGLBackend.js +607 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +118 -17
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +199 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +320 -84
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +120 -66
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +55 -36
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +96 -5
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +24 -22
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +117 -139
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +60 -142
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +7 -6
- package/examples/jsm/shaders/FilmShader.js +11 -54
- package/examples/jsm/shaders/OutputShader.js +19 -2
- package/examples/jsm/shaders/SAOShader.js +0 -13
- package/examples/jsm/shaders/SSAOShader.js +33 -26
- package/examples/jsm/utils/BufferGeometryUtils.js +13 -4
- package/examples/jsm/webxr/OculusHandPointerModel.js +2 -2
- package/package.json +2 -2
- package/src/Three.js +3 -0
- package/src/animation/PropertyBinding.js +1 -1
- package/src/audio/Audio.js +6 -0
- package/src/cameras/CubeCamera.js +1 -4
- package/src/constants.js +4 -1
- package/src/core/BufferAttribute.js +20 -0
- package/src/core/Object3D.js +2 -15
- package/src/core/RenderTarget.js +122 -0
- package/src/core/UniformsGroup.js +2 -2
- package/src/geometries/CapsuleGeometry.js +1 -1
- package/src/loaders/DataTextureLoader.js +19 -2
- package/src/materials/Material.js +2 -2
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +3 -3
- package/src/math/Vector4.js +4 -4
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/renderers/WebGLMultipleRenderTargets.js +0 -2
- package/src/renderers/WebGLRenderTarget.js +3 -110
- package/src/renderers/WebGLRenderer.js +83 -57
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +1 -2
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
- package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
- package/src/renderers/webgl/WebGLBackground.js +5 -14
- package/src/renderers/webgl/WebGLGeometries.js +5 -1
- package/src/renderers/webgl/WebGLMaterials.js +1 -1
- package/src/renderers/webgl/WebGLProgram.js +2 -0
- package/src/renderers/webgl/WebGLPrograms.js +19 -3
- package/src/renderers/webgl/WebGLTextures.js +101 -16
- package/src/renderers/webgl/WebGLUtils.js +27 -20
- package/src/textures/CompressedCubeTexture.js +19 -0
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +9 -1
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +0 -30
- package/examples/jsm/renderers/common/RenderTarget.js +0 -15
- package/examples/jsm/renderers/common/nodes/NodeRender.js +0 -302
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +0 -0
|
@@ -214,12 +214,6 @@ export const GPUAddressMode = {
|
|
|
214
214
|
MirrorRepeat: 'mirror-repeat'
|
|
215
215
|
};
|
|
216
216
|
|
|
217
|
-
export const GPUSamplerBindingType = {
|
|
218
|
-
Filtering: 'filtering',
|
|
219
|
-
NonFiltering: 'non-filtering',
|
|
220
|
-
Comparison: 'comparison'
|
|
221
|
-
};
|
|
222
|
-
|
|
223
217
|
export const GPUFilterMode = {
|
|
224
218
|
Linear: 'linear',
|
|
225
219
|
Nearest: 'nearest'
|
|
@@ -228,17 +222,17 @@ export const GPUFilterMode = {
|
|
|
228
222
|
export const GPUBlendFactor = {
|
|
229
223
|
Zero: 'zero',
|
|
230
224
|
One: 'one',
|
|
231
|
-
|
|
232
|
-
|
|
225
|
+
Src: 'src',
|
|
226
|
+
OneMinusSrc: 'one-minus-src',
|
|
233
227
|
SrcAlpha: 'src-alpha',
|
|
234
228
|
OneMinusSrcAlpha: 'one-minus-src-alpha',
|
|
235
|
-
|
|
236
|
-
OneMinusDstColor: 'one-minus-dst
|
|
229
|
+
Dst: 'dst',
|
|
230
|
+
OneMinusDstColor: 'one-minus-dst',
|
|
237
231
|
DstAlpha: 'dst-alpha',
|
|
238
232
|
OneMinusDstAlpha: 'one-minus-dst-alpha',
|
|
239
233
|
SrcAlphaSaturated: 'src-alpha-saturated',
|
|
240
|
-
|
|
241
|
-
|
|
234
|
+
Constant: 'constant',
|
|
235
|
+
OneMinusConstant: 'one-minus-constant'
|
|
242
236
|
};
|
|
243
237
|
|
|
244
238
|
export const GPUBlendOperation = {
|
|
@@ -269,16 +263,24 @@ export const GPUStencilOperation = {
|
|
|
269
263
|
DecrementWrap: 'decrement-wrap'
|
|
270
264
|
};
|
|
271
265
|
|
|
272
|
-
export const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
266
|
+
export const GPUBufferBindingType = {
|
|
267
|
+
Uniform: 'uniform',
|
|
268
|
+
Storage: 'storage',
|
|
269
|
+
ReadOnlyStorage: 'read-only-storage'
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export const GPUSamplerBindingType = {
|
|
273
|
+
Filtering: 'filtering',
|
|
274
|
+
NonFiltering: 'non-filtering',
|
|
275
|
+
Comparison: 'comparison'
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export const GPUTextureSampleType = {
|
|
279
|
+
Float: 'float',
|
|
280
|
+
UnfilterableFloat: 'unfilterable-float',
|
|
281
|
+
Depth: 'depth',
|
|
282
|
+
SInt: 'sint',
|
|
283
|
+
UInt: 'uint'
|
|
282
284
|
};
|
|
283
285
|
|
|
284
286
|
export const GPUTextureDimension = {
|
|
@@ -33,24 +33,11 @@ class WebGPUPipelineUtils {
|
|
|
33
33
|
const utils = backend.utils;
|
|
34
34
|
|
|
35
35
|
const pipelineData = backend.get( pipeline );
|
|
36
|
-
|
|
37
|
-
// determine shader attributes
|
|
38
|
-
|
|
39
|
-
const shaderAttributes = backend.attributeUtils.createShaderAttributes( renderObject );
|
|
36
|
+
const bindingsData = backend.get( renderObject.getBindings() );
|
|
40
37
|
|
|
41
38
|
// vertex buffers
|
|
42
39
|
|
|
43
|
-
const vertexBuffers =
|
|
44
|
-
|
|
45
|
-
for ( const attribute of shaderAttributes ) {
|
|
46
|
-
|
|
47
|
-
vertexBuffers.push( {
|
|
48
|
-
arrayStride: attribute.arrayStride,
|
|
49
|
-
attributes: [ { shaderLocation: attribute.slot, offset: attribute.offset, format: attribute.format } ],
|
|
50
|
-
stepMode: attribute.stepMode
|
|
51
|
-
} );
|
|
52
|
-
|
|
53
|
-
}
|
|
40
|
+
const vertexBuffers = backend.attributeUtils.createShaderVertexBuffers( renderObject );
|
|
54
41
|
|
|
55
42
|
// blending
|
|
56
43
|
|
|
@@ -58,10 +45,7 @@ class WebGPUPipelineUtils {
|
|
|
58
45
|
|
|
59
46
|
if ( material.transparent === true && material.blending !== NoBlending ) {
|
|
60
47
|
|
|
61
|
-
blending =
|
|
62
|
-
alpha: this._getAlphaBlend( material ),
|
|
63
|
-
color: this._getColorBlend( material )
|
|
64
|
-
};
|
|
48
|
+
blending = this._getBlending( material );
|
|
65
49
|
|
|
66
50
|
}
|
|
67
51
|
|
|
@@ -80,25 +64,49 @@ class WebGPUPipelineUtils {
|
|
|
80
64
|
|
|
81
65
|
}
|
|
82
66
|
|
|
83
|
-
|
|
67
|
+
const colorWriteMask = this._getColorWriteMask( material );
|
|
68
|
+
|
|
69
|
+
const targets = [];
|
|
70
|
+
|
|
71
|
+
if ( renderObject.context.textures !== null ) {
|
|
72
|
+
|
|
73
|
+
const textures = renderObject.context.textures;
|
|
74
|
+
|
|
75
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
76
|
+
|
|
77
|
+
const colorFormat = utils.getTextureFormatGPU( textures[ i ] );
|
|
78
|
+
|
|
79
|
+
targets.push( {
|
|
80
|
+
format: colorFormat,
|
|
81
|
+
blend: blending,
|
|
82
|
+
writeMask: colorWriteMask
|
|
83
|
+
} );
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
} else {
|
|
88
|
+
|
|
89
|
+
const colorFormat = utils.getCurrentColorFormat( renderObject.context );
|
|
90
|
+
|
|
91
|
+
targets.push( {
|
|
92
|
+
format: colorFormat,
|
|
93
|
+
blend: blending,
|
|
94
|
+
writeMask: colorWriteMask
|
|
95
|
+
} );
|
|
96
|
+
|
|
97
|
+
}
|
|
84
98
|
|
|
85
99
|
const vertexModule = backend.get( vertexProgram ).module;
|
|
86
100
|
const fragmentModule = backend.get( fragmentProgram ).module;
|
|
87
101
|
|
|
88
102
|
const primitiveState = this._getPrimitiveState( object, geometry, material );
|
|
89
|
-
const colorWriteMask = this._getColorWriteMask( material );
|
|
90
103
|
const depthCompare = this._getDepthCompare( material );
|
|
91
|
-
const colorFormat = utils.getCurrentColorFormat( renderObject.context );
|
|
92
104
|
const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderObject.context );
|
|
93
105
|
const sampleCount = utils.getSampleCount( renderObject.context );
|
|
94
106
|
|
|
95
107
|
pipelineData.pipeline = device.createRenderPipeline( {
|
|
96
108
|
vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),
|
|
97
|
-
fragment: Object.assign( {}, fragmentModule, { targets
|
|
98
|
-
format: colorFormat,
|
|
99
|
-
blend: blending,
|
|
100
|
-
writeMask: colorWriteMask
|
|
101
|
-
} ] } ),
|
|
109
|
+
fragment: Object.assign( {}, fragmentModule, { targets } ),
|
|
102
110
|
primitive: primitiveState,
|
|
103
111
|
depthStencil: {
|
|
104
112
|
format: depthStencilFormat,
|
|
@@ -110,14 +118,17 @@ class WebGPUPipelineUtils {
|
|
|
110
118
|
stencilWriteMask: material.stencilWriteMask
|
|
111
119
|
},
|
|
112
120
|
multisample: {
|
|
113
|
-
count: sampleCount
|
|
121
|
+
count: sampleCount,
|
|
122
|
+
alphaToCoverageEnabled: material.alphaToCoverage
|
|
114
123
|
},
|
|
115
|
-
layout:
|
|
124
|
+
layout: device.createPipelineLayout( {
|
|
125
|
+
bindGroupLayouts: [ bindingsData.layout ]
|
|
126
|
+
} )
|
|
116
127
|
} );
|
|
117
128
|
|
|
118
129
|
}
|
|
119
130
|
|
|
120
|
-
createComputePipeline( pipeline ) {
|
|
131
|
+
createComputePipeline( pipeline, bindings ) {
|
|
121
132
|
|
|
122
133
|
const backend = this.backend;
|
|
123
134
|
const device = backend.device;
|
|
@@ -125,100 +136,119 @@ class WebGPUPipelineUtils {
|
|
|
125
136
|
const computeProgram = backend.get( pipeline.computeProgram ).module;
|
|
126
137
|
|
|
127
138
|
const pipelineGPU = backend.get( pipeline );
|
|
139
|
+
const bindingsData = backend.get( bindings );
|
|
128
140
|
|
|
129
141
|
pipelineGPU.pipeline = device.createComputePipeline( {
|
|
130
142
|
compute: computeProgram,
|
|
131
|
-
layout:
|
|
143
|
+
layout: device.createPipelineLayout( {
|
|
144
|
+
bindGroupLayouts: [ bindingsData.layout ]
|
|
145
|
+
} )
|
|
132
146
|
} );
|
|
133
147
|
|
|
134
148
|
}
|
|
135
149
|
|
|
136
|
-
|
|
150
|
+
_getBlending( material ) {
|
|
151
|
+
|
|
152
|
+
let color, alpha;
|
|
137
153
|
|
|
138
154
|
const blending = material.blending;
|
|
139
|
-
const premultipliedAlpha = material.premultipliedAlpha;
|
|
140
155
|
|
|
141
|
-
|
|
156
|
+
if ( blending === CustomBlending ) {
|
|
142
157
|
|
|
143
|
-
|
|
158
|
+
const blendSrcAlpha = material.blendSrcAlpha !== null ? material.blendSrcAlpha : GPUBlendFactor.One;
|
|
159
|
+
const blendDstAlpha = material.blendDstAlpha !== null ? material.blendDstAlpha : GPUBlendFactor.Zero;
|
|
160
|
+
const blendEquationAlpha = material.blendEquationAlpha !== null ? material.blendEquationAlpha : GPUBlendFactor.Add;
|
|
144
161
|
|
|
145
|
-
|
|
162
|
+
color = {
|
|
163
|
+
srcFactor: this._getBlendFactor( material.blendSrc ),
|
|
164
|
+
dstFactor: this._getBlendFactor( material.blendDst ),
|
|
165
|
+
operation: this._getBlendOperation( material.blendEquation )
|
|
166
|
+
};
|
|
146
167
|
|
|
147
|
-
|
|
168
|
+
alpha = {
|
|
169
|
+
srcFactor: this._getBlendFactor( blendSrcAlpha ),
|
|
170
|
+
dstFactor: this._getBlendFactor( blendDstAlpha ),
|
|
171
|
+
operation: this._getBlendOperation( blendEquationAlpha )
|
|
172
|
+
};
|
|
148
173
|
|
|
149
|
-
|
|
150
|
-
srcFactor: GPUBlendFactor.One,
|
|
151
|
-
dstFactor: GPUBlendFactor.OneMinusSrcAlpha,
|
|
152
|
-
operation: GPUBlendOperation.Add
|
|
153
|
-
};
|
|
174
|
+
} else {
|
|
154
175
|
|
|
155
|
-
|
|
176
|
+
const premultipliedAlpha = material.premultipliedAlpha;
|
|
156
177
|
|
|
157
|
-
|
|
178
|
+
const setBlend = ( srcRGB, dstRGB, srcAlpha, dstAlpha ) => {
|
|
158
179
|
|
|
159
|
-
|
|
180
|
+
color = {
|
|
181
|
+
srcFactor: srcRGB,
|
|
182
|
+
dstFactor: dstRGB,
|
|
183
|
+
operation: GPUBlendOperation.Add
|
|
184
|
+
};
|
|
160
185
|
|
|
161
|
-
|
|
162
|
-
srcFactor:
|
|
163
|
-
dstFactor:
|
|
186
|
+
alpha = {
|
|
187
|
+
srcFactor: srcAlpha,
|
|
188
|
+
dstFactor: dstAlpha,
|
|
164
189
|
operation: GPUBlendOperation.Add
|
|
165
190
|
};
|
|
166
191
|
|
|
167
|
-
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
if ( premultipliedAlpha ) {
|
|
195
|
+
|
|
196
|
+
switch ( blending ) {
|
|
197
|
+
|
|
198
|
+
case NormalBlending:
|
|
199
|
+
setBlend( GPUBlendFactor.SrcAlpha, GPUBlendFactor.OneMinusSrcAlpha, GPUBlendFactor.One, GPUBlendFactor.OneMinusSrcAlpha );
|
|
200
|
+
break;
|
|
168
201
|
|
|
169
|
-
|
|
202
|
+
case AdditiveBlending:
|
|
203
|
+
setBlend( GPUBlendFactor.SrcAlpha, GPUBlendFactor.One, GPUBlendFactor.One, GPUBlendFactor.One );
|
|
204
|
+
break;
|
|
170
205
|
|
|
171
|
-
|
|
206
|
+
case SubtractiveBlending:
|
|
207
|
+
setBlend( GPUBlendFactor.Zero, GPUBlendFactor.OneMinusSrc, GPUBlendFactor.Zero, GPUBlendFactor.One );
|
|
208
|
+
break;
|
|
172
209
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
operation: GPUBlendOperation.Add
|
|
177
|
-
};
|
|
210
|
+
case MultiplyBlending:
|
|
211
|
+
setBlend( GPUBlendFactor.Zero, GPUBlendFactor.Src, GPUBlendFactor.Zero, GPUBlendFactor.SrcAlpha );
|
|
212
|
+
break;
|
|
178
213
|
|
|
179
214
|
}
|
|
180
215
|
|
|
181
|
-
|
|
216
|
+
} else {
|
|
182
217
|
|
|
183
|
-
|
|
218
|
+
switch ( blending ) {
|
|
184
219
|
|
|
185
|
-
|
|
220
|
+
case NormalBlending:
|
|
221
|
+
setBlend( GPUBlendFactor.SrcAlpha, GPUBlendFactor.OneMinusSrcAlpha, GPUBlendFactor.One, GPUBlendFactor.OneMinusSrcAlpha );
|
|
222
|
+
break;
|
|
186
223
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
operation: GPUBlendOperation.Add
|
|
191
|
-
};
|
|
224
|
+
case AdditiveBlending:
|
|
225
|
+
setBlend( GPUBlendFactor.SrcAlpha, GPUBlendFactor.One, GPUBlendFactor.SrcAlpha, GPUBlendFactor.One );
|
|
226
|
+
break;
|
|
192
227
|
|
|
193
|
-
|
|
228
|
+
case SubtractiveBlending:
|
|
229
|
+
setBlend( GPUBlendFactor.Zero, GPUBlendFactor.OneMinusSrc, GPUBlendFactor.Zero, GPUBlendFactor.One );
|
|
230
|
+
break;
|
|
194
231
|
|
|
195
|
-
|
|
232
|
+
case MultiplyBlending:
|
|
233
|
+
setBlend( GPUBlendFactor.Zero, GPUBlendFactor.Src, GPUBlendFactor.Zero, GPUBlendFactor.Src );
|
|
234
|
+
break;
|
|
196
235
|
|
|
197
|
-
|
|
236
|
+
}
|
|
198
237
|
|
|
199
|
-
|
|
200
|
-
const blendDstAlpha = material.blendDstAlpha;
|
|
201
|
-
const blendEquationAlpha = material.blendEquationAlpha;
|
|
238
|
+
}
|
|
202
239
|
|
|
203
|
-
|
|
240
|
+
}
|
|
204
241
|
|
|
205
|
-
|
|
206
|
-
srcFactor: this._getBlendFactor( blendSrcAlpha ),
|
|
207
|
-
dstFactor: this._getBlendFactor( blendDstAlpha ),
|
|
208
|
-
operation: this._getBlendOperation( blendEquationAlpha )
|
|
209
|
-
};
|
|
242
|
+
if ( color !== undefined && alpha !== undefined ) {
|
|
210
243
|
|
|
211
|
-
|
|
244
|
+
return { color, alpha };
|
|
212
245
|
|
|
213
|
-
|
|
246
|
+
} else {
|
|
214
247
|
|
|
215
|
-
|
|
216
|
-
console.error( 'THREE.WebGPURenderer: Blending not supported.', blending );
|
|
248
|
+
console.error( 'THREE.WebGPURenderer: Invalid blending: ', blending );
|
|
217
249
|
|
|
218
250
|
}
|
|
219
251
|
|
|
220
|
-
return alphaBlend;
|
|
221
|
-
|
|
222
252
|
}
|
|
223
253
|
|
|
224
254
|
_getBlendFactor( blend ) {
|
|
@@ -236,11 +266,11 @@ class WebGPUPipelineUtils {
|
|
|
236
266
|
break;
|
|
237
267
|
|
|
238
268
|
case SrcColorFactor:
|
|
239
|
-
blendFactor = GPUBlendFactor.
|
|
269
|
+
blendFactor = GPUBlendFactor.Src;
|
|
240
270
|
break;
|
|
241
271
|
|
|
242
272
|
case OneMinusSrcColorFactor:
|
|
243
|
-
blendFactor = GPUBlendFactor.
|
|
273
|
+
blendFactor = GPUBlendFactor.OneMinusSrc;
|
|
244
274
|
break;
|
|
245
275
|
|
|
246
276
|
case SrcAlphaFactor:
|
|
@@ -252,7 +282,7 @@ class WebGPUPipelineUtils {
|
|
|
252
282
|
break;
|
|
253
283
|
|
|
254
284
|
case DstColorFactor:
|
|
255
|
-
blendFactor = GPUBlendFactor.
|
|
285
|
+
blendFactor = GPUBlendFactor.Dst;
|
|
256
286
|
break;
|
|
257
287
|
|
|
258
288
|
case OneMinusDstColorFactor:
|
|
@@ -272,11 +302,11 @@ class WebGPUPipelineUtils {
|
|
|
272
302
|
break;
|
|
273
303
|
|
|
274
304
|
case BlendColorFactor:
|
|
275
|
-
blendFactor = GPUBlendFactor.
|
|
305
|
+
blendFactor = GPUBlendFactor.Constant;
|
|
276
306
|
break;
|
|
277
307
|
|
|
278
308
|
case OneMinusBlendColorFactor:
|
|
279
|
-
blendFactor = GPUBlendFactor.
|
|
309
|
+
blendFactor = GPUBlendFactor.OneMinusConstant;
|
|
280
310
|
break;
|
|
281
311
|
|
|
282
312
|
default:
|
|
@@ -288,58 +318,6 @@ class WebGPUPipelineUtils {
|
|
|
288
318
|
|
|
289
319
|
}
|
|
290
320
|
|
|
291
|
-
_getColorBlend( material ) {
|
|
292
|
-
|
|
293
|
-
const blending = material.blending;
|
|
294
|
-
const premultipliedAlpha = material.premultipliedAlpha;
|
|
295
|
-
|
|
296
|
-
const colorBlend = {
|
|
297
|
-
srcFactor: null,
|
|
298
|
-
dstFactor: null,
|
|
299
|
-
operation: null
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
switch ( blending ) {
|
|
303
|
-
|
|
304
|
-
case NormalBlending:
|
|
305
|
-
colorBlend.srcFactor = ( premultipliedAlpha === true ) ? GPUBlendFactor.One : GPUBlendFactor.SrcAlpha;
|
|
306
|
-
colorBlend.dstFactor = GPUBlendFactor.OneMinusSrcAlpha;
|
|
307
|
-
colorBlend.operation = GPUBlendOperation.Add;
|
|
308
|
-
break;
|
|
309
|
-
|
|
310
|
-
case AdditiveBlending:
|
|
311
|
-
colorBlend.srcFactor = ( premultipliedAlpha === true ) ? GPUBlendFactor.One : GPUBlendFactor.SrcAlpha;
|
|
312
|
-
colorBlend.dstFactor = GPUBlendFactor.One;
|
|
313
|
-
colorBlend.operation = GPUBlendOperation.Add;
|
|
314
|
-
break;
|
|
315
|
-
|
|
316
|
-
case SubtractiveBlending:
|
|
317
|
-
colorBlend.srcFactor = GPUBlendFactor.Zero;
|
|
318
|
-
colorBlend.dstFactor = ( premultipliedAlpha === true ) ? GPUBlendFactor.Zero : GPUBlendFactor.OneMinusSrcColor;
|
|
319
|
-
colorBlend.operation = GPUBlendOperation.Add;
|
|
320
|
-
break;
|
|
321
|
-
|
|
322
|
-
case MultiplyBlending:
|
|
323
|
-
colorBlend.srcFactor = GPUBlendFactor.Zero;
|
|
324
|
-
colorBlend.dstFactor = GPUBlendFactor.SrcColor;
|
|
325
|
-
colorBlend.operation = GPUBlendOperation.Add;
|
|
326
|
-
break;
|
|
327
|
-
|
|
328
|
-
case CustomBlending:
|
|
329
|
-
colorBlend.srcFactor = this._getBlendFactor( material.blendSrc );
|
|
330
|
-
colorBlend.dstFactor = this._getBlendFactor( material.blendDst );
|
|
331
|
-
colorBlend.operation = this._getBlendOperation( material.blendEquation );
|
|
332
|
-
break;
|
|
333
|
-
|
|
334
|
-
default:
|
|
335
|
-
console.error( 'THREE.WebGPURenderer: Blending not supported.', blending );
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return colorBlend;
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
|
|
343
321
|
_getStencilCompare( material ) {
|
|
344
322
|
|
|
345
323
|
let stencilCompare;
|