super-three 0.155.0 → 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.
Files changed (108) hide show
  1. package/build/three.cjs +107 -125
  2. package/build/three.js +107 -125
  3. package/build/three.min.js +1 -1
  4. package/build/three.module.js +104 -126
  5. package/build/three.module.min.js +1 -1
  6. package/examples/jsm/controls/OrbitControls.js +13 -5
  7. package/examples/jsm/csm/CSMShader.js +35 -1
  8. package/examples/jsm/libs/tween.module.js +790 -735
  9. package/examples/jsm/libs/utif.module.js +1644 -1558
  10. package/examples/jsm/loaders/DDSLoader.js +46 -3
  11. package/examples/jsm/loaders/EXRLoader.js +4 -4
  12. package/examples/jsm/loaders/FBXLoader.js +2 -0
  13. package/examples/jsm/loaders/GLTFLoader.js +17 -7
  14. package/examples/jsm/loaders/KTX2Loader.js +126 -77
  15. package/examples/jsm/loaders/LogLuvLoader.js +2 -2
  16. package/examples/jsm/loaders/MMDLoader.js +10 -7
  17. package/examples/jsm/loaders/RGBELoader.js +48 -66
  18. package/examples/jsm/loaders/STLLoader.js +7 -0
  19. package/examples/jsm/nodes/Nodes.js +3 -0
  20. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +28 -2
  21. package/examples/jsm/nodes/accessors/CubeTextureNode.js +18 -3
  22. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +2 -4
  23. package/examples/jsm/nodes/accessors/LineMaterialNode.js +31 -0
  24. package/examples/jsm/nodes/accessors/MaterialNode.js +55 -33
  25. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +3 -0
  26. package/examples/jsm/nodes/accessors/Object3DNode.js +2 -2
  27. package/examples/jsm/nodes/accessors/TextureNode.js +6 -2
  28. package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
  29. package/examples/jsm/nodes/core/AttributeNode.js +2 -2
  30. package/examples/jsm/nodes/core/Node.js +17 -1
  31. package/examples/jsm/nodes/core/NodeBuilder.js +94 -12
  32. package/examples/jsm/nodes/core/NodeUniform.js +1 -1
  33. package/examples/jsm/nodes/core/OutputStructNode.js +58 -0
  34. package/examples/jsm/nodes/core/PropertyNode.js +2 -0
  35. package/examples/jsm/nodes/core/StackNode.js +4 -4
  36. package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
  37. package/examples/jsm/nodes/display/ViewportNode.js +19 -5
  38. package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
  39. package/examples/jsm/nodes/materials/Materials.js +1 -0
  40. package/examples/jsm/nodes/materials/NodeMaterial.js +12 -3
  41. package/examples/jsm/nodes/math/HashNode.js +35 -0
  42. package/examples/jsm/nodes/shadernode/ShaderNode.js +4 -0
  43. package/examples/jsm/nodes/utils/SplitNode.js +1 -1
  44. package/examples/jsm/postprocessing/FilmPass.js +3 -5
  45. package/examples/jsm/postprocessing/RenderPass.js +30 -12
  46. package/examples/jsm/postprocessing/SAOPass.js +23 -98
  47. package/examples/jsm/postprocessing/SSAOPass.js +10 -30
  48. package/examples/jsm/renderers/common/Backend.js +11 -8
  49. package/examples/jsm/renderers/common/Binding.js +6 -0
  50. package/examples/jsm/renderers/common/Bindings.js +5 -4
  51. package/examples/jsm/renderers/common/Pipelines.js +2 -2
  52. package/examples/jsm/renderers/common/RenderContexts.js +26 -1
  53. package/examples/jsm/renderers/common/RenderList.js +12 -4
  54. package/examples/jsm/renderers/common/RenderObject.js +6 -2
  55. package/examples/jsm/renderers/common/Renderer.js +12 -3
  56. package/examples/jsm/renderers/common/SampledTexture.js +2 -1
  57. package/examples/jsm/renderers/common/Sampler.js +1 -1
  58. package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
  59. package/examples/jsm/renderers/common/Textures.js +155 -15
  60. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +2 -2
  61. package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -1
  62. package/examples/jsm/renderers/common/nodes/Nodes.js +43 -9
  63. package/examples/jsm/renderers/webgl/WebGLBackend.js +607 -0
  64. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +118 -17
  65. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
  66. package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
  67. package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
  68. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +199 -0
  69. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
  70. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
  71. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +1 -1
  72. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +279 -40
  73. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
  74. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +89 -59
  75. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
  76. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +15 -2
  77. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +34 -9
  78. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +26 -135
  79. package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +6 -5
  80. package/examples/jsm/shaders/FilmShader.js +11 -54
  81. package/examples/jsm/shaders/SAOShader.js +0 -13
  82. package/examples/jsm/shaders/SSAOShader.js +33 -26
  83. package/package.json +1 -1
  84. package/src/Three.js +1 -0
  85. package/src/audio/Audio.js +6 -0
  86. package/src/constants.js +4 -1
  87. package/src/core/Object3D.js +1 -14
  88. package/src/core/UniformsGroup.js +2 -2
  89. package/src/loaders/DataTextureLoader.js +0 -2
  90. package/src/materials/Material.js +2 -2
  91. package/src/math/Vector2.js +2 -2
  92. package/src/math/Vector3.js +3 -3
  93. package/src/math/Vector4.js +4 -4
  94. package/src/objects/Line.js +1 -1
  95. package/src/objects/Mesh.js +1 -1
  96. package/src/objects/Points.js +1 -1
  97. package/src/renderers/WebGLRenderer.js +21 -49
  98. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
  99. package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
  100. package/src/renderers/webgl/WebGLBackground.js +5 -14
  101. package/src/renderers/webgl/WebGLProgram.js +2 -0
  102. package/src/renderers/webgl/WebGLPrograms.js +5 -1
  103. package/src/renderers/webgl/WebGLTextures.js +4 -4
  104. package/src/renderers/webgl/WebGLUtils.js +27 -20
  105. package/src/textures/Texture.js +2 -2
  106. package/src/utils.js +9 -1
  107. /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
  108. /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +0 -0
@@ -1,10 +1,7 @@
1
- import { RenderTarget, NoColorSpace } from 'three';
1
+ import { NoColorSpace, FloatType } from 'three';
2
2
 
3
3
  import UniformsGroup from '../../common/UniformsGroup.js';
4
- import {
5
- FloatNodeUniform, Vector2NodeUniform, Vector3NodeUniform, Vector4NodeUniform,
6
- ColorNodeUniform, Matrix3NodeUniform, Matrix4NodeUniform
7
- } from '../../common/nodes/NodeUniform.js';
4
+
8
5
  import NodeSampler from '../../common/nodes/NodeSampler.js';
9
6
  import { NodeSampledTexture, NodeSampledCubeTexture } from '../../common/nodes/NodeSampledTexture.js';
10
7
 
@@ -12,8 +9,6 @@ import UniformBuffer from '../../common/UniformBuffer.js';
12
9
  import StorageBuffer from '../../common/StorageBuffer.js';
13
10
  import { getVectorLength, getStrideLength } from '../../common/BufferUtils.js';
14
11
 
15
- import CubeRenderTarget from '../../common/CubeRenderTarget.js';
16
-
17
12
  import { NodeBuilder, CodeNode, NodeMaterial } from '../../../nodes/Nodes.js';
18
13
 
19
14
  import WGSLNodeParser from './WGSLNodeParser.js';
@@ -136,7 +131,7 @@ class WGSLNodeBuilder extends NodeBuilder {
136
131
 
137
132
  }
138
133
 
139
- getSampler( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
134
+ _getSampler( texture, textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
140
135
 
141
136
  if ( shaderStage === 'fragment' ) {
142
137
 
@@ -144,17 +139,13 @@ class WGSLNodeBuilder extends NodeBuilder {
144
139
 
145
140
  } else {
146
141
 
147
- this._include( 'repeatWrapping' );
148
-
149
- const dimension = `textureDimensions( ${textureProperty}, 0 )`;
150
-
151
- return `textureLoad( ${textureProperty}, threejs_repeatWrapping( ${uvSnippet}, ${dimension} ), 0 )`;
142
+ return this.getTextureLoad( texture, textureProperty, uvSnippet );
152
143
 
153
144
  }
154
145
 
155
146
  }
156
147
 
157
- getVideoSampler( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
148
+ _getVideoSampler( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
158
149
 
159
150
  if ( shaderStage === 'fragment' ) {
160
151
 
@@ -168,21 +159,33 @@ class WGSLNodeBuilder extends NodeBuilder {
168
159
 
169
160
  }
170
161
 
171
- getSamplerLevel( textureProperty, uvSnippet, biasSnippet, shaderStage = this.shaderStage ) {
162
+ _getSamplerLevel( texture, textureProperty, uvSnippet, biasSnippet, shaderStage = this.shaderStage ) {
172
163
 
173
- if ( shaderStage === 'fragment' ) {
164
+ if ( shaderStage === 'fragment' && this.isUnfilterable( texture ) === false ) {
174
165
 
175
166
  return `textureSampleLevel( ${textureProperty}, ${textureProperty}_sampler, ${uvSnippet}, ${biasSnippet} )`;
176
167
 
177
168
  } else {
178
169
 
179
- this._include( 'repeatWrapping' );
170
+ return this.getTextureLoad( texture, textureProperty, uvSnippet, biasSnippet );
180
171
 
181
- const dimension = `textureDimensions( ${textureProperty}, 0 )`;
172
+ }
182
173
 
183
- return `textureLoad( ${textureProperty}, threejs_repeatWrapping( ${uvSnippet}, ${dimension} ), i32( ${biasSnippet} ) )`;
174
+ }
184
175
 
185
- }
176
+ getTextureLoad( texture, textureProperty, uvSnippet, biasSnippet = '0' ) {
177
+
178
+ this._include( 'repeatWrapping' );
179
+
180
+ const dimension = `textureDimensions( ${textureProperty}, 0 )`;
181
+
182
+ return `textureLoad( ${textureProperty}, threejs_repeatWrapping( ${uvSnippet}, ${dimension} ), i32( ${biasSnippet} ) )`;
183
+
184
+ }
185
+
186
+ isUnfilterable( texture ) {
187
+
188
+ return texture.isDataTexture === true && texture.type === FloatType;
186
189
 
187
190
  }
188
191
 
@@ -192,11 +195,15 @@ class WGSLNodeBuilder extends NodeBuilder {
192
195
 
193
196
  if ( texture.isVideoTexture === true ) {
194
197
 
195
- snippet = this.getVideoSampler( textureProperty, uvSnippet, shaderStage );
198
+ snippet = this._getVideoSampler( textureProperty, uvSnippet, shaderStage );
199
+
200
+ } else if ( this.isUnfilterable( texture ) ) {
201
+
202
+ snippet = this.getTextureLoad( texture, textureProperty, uvSnippet );
196
203
 
197
204
  } else {
198
205
 
199
- snippet = this.getSampler( textureProperty, uvSnippet, shaderStage );
206
+ snippet = this._getSampler( texture, textureProperty, uvSnippet, shaderStage );
200
207
 
201
208
  }
202
209
 
@@ -224,11 +231,11 @@ class WGSLNodeBuilder extends NodeBuilder {
224
231
 
225
232
  if ( texture.isVideoTexture === true ) {
226
233
 
227
- snippet = this.getVideoSampler( textureProperty, uvSnippet, shaderStage );
234
+ snippet = this._getVideoSampler( textureProperty, uvSnippet, shaderStage );
228
235
 
229
236
  } else {
230
237
 
231
- snippet = this.getSamplerLevel( textureProperty, uvSnippet, biasSnippet, shaderStage );
238
+ snippet = this._getSamplerLevel( texture, textureProperty, uvSnippet, biasSnippet, shaderStage );
232
239
 
233
240
  }
234
241
 
@@ -296,13 +303,14 @@ class WGSLNodeBuilder extends NodeBuilder {
296
303
 
297
304
  }
298
305
 
306
+ texture.store = node.isStoreTextureNode === true;
299
307
  texture.setVisibility( gpuShaderStageLib[ shaderStage ] );
300
308
 
301
309
  // add first textures in sequence and group for last
302
310
  const lastBinding = bindings[ bindings.length - 1 ];
303
311
  const index = lastBinding && lastBinding.isUniformsGroup ? bindings.length - 1 : bindings.length;
304
312
 
305
- if ( shaderStage === 'fragment' ) {
313
+ if ( shaderStage === 'fragment' && this.isUnfilterable( node.value ) === false && texture.store === false ) {
306
314
 
307
315
  const sampler = new NodeSampler( `${uniformNode.name}_sampler`, uniformNode.node );
308
316
  sampler.setVisibility( gpuShaderStageLib[ shaderStage ] );
@@ -354,7 +362,7 @@ class WGSLNodeBuilder extends NodeBuilder {
354
362
 
355
363
  for ( const uniformNode of node.nodes ) {
356
364
 
357
- const uniformNodeGPU = this._getNodeUniform( uniformNode, type );
365
+ const uniformNodeGPU = this.getNodeUniform( uniformNode, type );
358
366
 
359
367
  // fit bounds to buffer
360
368
  uniformNodeGPU.boundary = getVectorLength( uniformNodeGPU.itemSize );
@@ -368,7 +376,7 @@ class WGSLNodeBuilder extends NodeBuilder {
368
376
 
369
377
  } else {
370
378
 
371
- uniformGPU = this._getNodeUniform( uniformNode, type );
379
+ uniformGPU = this.getNodeUniform( uniformNode, type );
372
380
 
373
381
  uniformsGroup.addUniform( uniformGPU );
374
382
 
@@ -392,7 +400,7 @@ class WGSLNodeBuilder extends NodeBuilder {
392
400
 
393
401
  isReference( type ) {
394
402
 
395
- return super.isReference( type ) || type === 'texture_2d' || type === 'texture_cube';
403
+ return super.isReference( type ) || type === 'texture_2d' || type === 'texture_cube' || type === 'texture_storage_2d';
396
404
 
397
405
  }
398
406
 
@@ -492,6 +500,44 @@ class WGSLNodeBuilder extends NodeBuilder {
492
500
 
493
501
  }
494
502
 
503
+ getStructMembers( struct ) {
504
+
505
+ const snippets = [];
506
+ const members = struct.getMemberTypes();
507
+
508
+ for ( let i = 0; i < members.length; i ++ ) {
509
+
510
+ const member = members[ i ];
511
+ snippets.push( `\t@location( ${i} ) m${i} : ${ member }<f32>` );
512
+
513
+ }
514
+
515
+ return snippets.join( ',\n' );
516
+
517
+ }
518
+
519
+ getStructs( shaderStage ) {
520
+
521
+ const snippets = [];
522
+ const structs = this.structs[ shaderStage ];
523
+
524
+ for ( let index = 0, length = structs.length; index < length; index ++ ) {
525
+
526
+ const struct = structs[ index ];
527
+ const name = struct.name;
528
+
529
+ let snippet = `\struct ${ name } {\n`;
530
+ snippet += this.getStructMembers( struct );
531
+ snippet += '\n}';
532
+
533
+ snippets.push( snippet );
534
+
535
+ }
536
+
537
+ return snippets.join( '\n\n' );
538
+
539
+ }
540
+
495
541
  getVar( type, name ) {
496
542
 
497
543
  return `var ${ name } : ${ this.getType( type ) }`;
@@ -540,6 +586,7 @@ class WGSLNodeBuilder extends NodeBuilder {
540
586
 
541
587
  attributesSnippet += ' @interpolate( flat )';
542
588
 
589
+
543
590
  }
544
591
 
545
592
  snippets.push( `${ attributesSnippet } ${ varying.name } : ${ this.getType( varying.type ) }` );
@@ -580,9 +627,9 @@ class WGSLNodeBuilder extends NodeBuilder {
580
627
 
581
628
  if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' ) {
582
629
 
583
- if ( shaderStage === 'fragment' ) {
630
+ const texture = uniform.node.value;
584
631
 
585
- const texture = uniform.node.value;
632
+ if ( shaderStage === 'fragment' && this.isUnfilterable( texture ) === false && uniform.node.isStoreTextureNode !== true ) {
586
633
 
587
634
  if ( texture.isDepthTexture === true && texture.compareFunction !== null ) {
588
635
 
@@ -596,8 +643,6 @@ class WGSLNodeBuilder extends NodeBuilder {
596
643
 
597
644
  }
598
645
 
599
- const texture = uniform.node.value;
600
-
601
646
  let textureType;
602
647
 
603
648
  if ( texture.isCubeTexture === true ) {
@@ -612,6 +657,11 @@ class WGSLNodeBuilder extends NodeBuilder {
612
657
 
613
658
  textureType = 'texture_external';
614
659
 
660
+ } else if ( uniform.node.isStoreTextureNode === true ) {
661
+
662
+ // @TODO: Add support for other formats
663
+ textureType = 'texture_storage_2d<rgba8unorm, write>';
664
+
615
665
  } else {
616
666
 
617
667
  textureType = 'texture_2d<f32>';
@@ -712,13 +762,16 @@ class WGSLNodeBuilder extends NodeBuilder {
712
762
 
713
763
  }
714
764
 
765
+ const outputNode = mainNode.outputNode;
715
766
  const stageData = shadersData[ shaderStage ];
716
767
 
717
768
  stageData.uniforms = this.getUniforms( shaderStage );
718
769
  stageData.attributes = this.getAttributes( shaderStage );
719
770
  stageData.varyings = this.getVaryings( shaderStage );
771
+ stageData.structs = this.getStructs( shaderStage );
720
772
  stageData.vars = this.getVars( shaderStage );
721
773
  stageData.codes = this.getCodes( shaderStage );
774
+ stageData.returnType = ( outputNode !== undefined && outputNode.isOutputStructNode === true ) ? outputNode.nodeType : '@location( 0 ) vec4<f32>';
722
775
  stageData.flow = flow;
723
776
 
724
777
  }
@@ -736,18 +789,6 @@ class WGSLNodeBuilder extends NodeBuilder {
736
789
 
737
790
  }
738
791
 
739
- getRenderTarget( width, height, options ) {
740
-
741
- return new RenderTarget( width, height, options );
742
-
743
- }
744
-
745
- getCubeRenderTarget( size, options ) {
746
-
747
- return new CubeRenderTarget( size, options );
748
-
749
- }
750
-
751
792
  getMethod( method ) {
752
793
 
753
794
  if ( wgslPolyfill[ method ] !== undefined ) {
@@ -778,20 +819,6 @@ class WGSLNodeBuilder extends NodeBuilder {
778
819
 
779
820
  }
780
821
 
781
- _getNodeUniform( uniformNode, type ) {
782
-
783
- if ( type === 'float' ) return new FloatNodeUniform( uniformNode );
784
- if ( type === 'vec2' ) return new Vector2NodeUniform( uniformNode );
785
- if ( type === 'vec3' ) return new Vector3NodeUniform( uniformNode );
786
- if ( type === 'vec4' ) return new Vector4NodeUniform( uniformNode );
787
- if ( type === 'color' ) return new ColorNodeUniform( uniformNode );
788
- if ( type === 'mat3' ) return new Matrix3NodeUniform( uniformNode );
789
- if ( type === 'mat4' ) return new Matrix4NodeUniform( uniformNode );
790
-
791
- throw new Error( `Uniform "${type}" not declared.` );
792
-
793
- }
794
-
795
822
  _getWGSLVertexCode( shaderData ) {
796
823
 
797
824
  return `${ this.getSignature() }
@@ -831,11 +858,14 @@ fn main( ${shaderData.attributes} ) -> NodeVaryingsStruct {
831
858
  // uniforms
832
859
  ${shaderData.uniforms}
833
860
 
861
+ // structs
862
+ ${shaderData.structs}
863
+
834
864
  // codes
835
865
  ${shaderData.codes}
836
866
 
837
867
  @fragment
838
- fn main( ${shaderData.varyings} ) -> @location( 0 ) vec4<f32> {
868
+ fn main( ${shaderData.varyings} ) -> ${shaderData.returnType} {
839
869
 
840
870
  // vars
841
871
  ${shaderData.vars}
@@ -2,7 +2,7 @@ import NodeFunction from '../../../nodes/core/NodeFunction.js';
2
2
  import NodeFunctionInput from '../../../nodes/core/NodeFunctionInput.js';
3
3
 
4
4
  const declarationRegexp = /^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+)?/i;
5
- const propertiesRegexp = /[a-z_0-9]+/ig;
5
+ const propertiesRegexp = /[a-z_0-9]+|<(.*?)>+/ig;
6
6
 
7
7
  const wgslTypeLib = {
8
8
  f32: 'float'
@@ -46,7 +46,7 @@ const parse = ( source ) => {
46
46
 
47
47
  // precision
48
48
 
49
- if ( i < propsMatches.length && /^[fui]\d{2}$/.test( propsMatches[ i ][ 0 ] ) === true )
49
+ if ( i < propsMatches.length && propsMatches[ i ][ 0 ].startsWith( '<' ) === true )
50
50
  i ++;
51
51
 
52
52
  // add input
@@ -1,6 +1,7 @@
1
1
  import {
2
- GPUTextureAspect, GPUTextureViewDimension, GPUBufferBindingType
2
+ GPUTextureAspect, GPUTextureViewDimension, GPUBufferBindingType, GPUTextureSampleType
3
3
  } from './WebGPUConstants.js';
4
+ import { FloatType } from 'three';
4
5
 
5
6
  class WebGPUBindingUtils {
6
7
 
@@ -58,13 +59,25 @@ class WebGPUBindingUtils {
58
59
 
59
60
  bindingGPU.externalTexture = {}; // GPUExternalTextureBindingLayout
60
61
 
62
+ } else if ( binding.isSampledTexture && binding.store ) {
63
+
64
+ const format = this.backend.get( binding.texture ).texture.format;
65
+
66
+ bindingGPU.storageTexture = { format }; // GPUStorageTextureBindingLayout
67
+
61
68
  } else if ( binding.isSampledTexture ) {
62
69
 
63
70
  const texture = {}; // GPUTextureBindingLayout
64
71
 
65
72
  if ( binding.texture.isDepthTexture ) {
66
73
 
67
- texture.sampleType = 'depth';
74
+ texture.sampleType = GPUTextureSampleType.Depth;
75
+
76
+ } else if ( binding.texture.isDataTexture && binding.texture.type === FloatType ) {
77
+
78
+ // @TODO: Add support for this soon: backend.hasFeature( 'float32-filterable' )
79
+
80
+ texture.sampleType = GPUTextureSampleType.UnfilterableFloat;
68
81
 
69
82
  }
70
83
 
@@ -64,25 +64,49 @@ class WebGPUPipelineUtils {
64
64
 
65
65
  }
66
66
 
67
- //
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
+ }
68
98
 
69
99
  const vertexModule = backend.get( vertexProgram ).module;
70
100
  const fragmentModule = backend.get( fragmentProgram ).module;
71
101
 
72
102
  const primitiveState = this._getPrimitiveState( object, geometry, material );
73
- const colorWriteMask = this._getColorWriteMask( material );
74
103
  const depthCompare = this._getDepthCompare( material );
75
- const colorFormat = utils.getCurrentColorFormat( renderObject.context );
76
104
  const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderObject.context );
77
105
  const sampleCount = utils.getSampleCount( renderObject.context );
78
106
 
79
107
  pipelineData.pipeline = device.createRenderPipeline( {
80
108
  vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),
81
- fragment: Object.assign( {}, fragmentModule, { targets: [ {
82
- format: colorFormat,
83
- blend: blending,
84
- writeMask: colorWriteMask
85
- } ] } ),
109
+ fragment: Object.assign( {}, fragmentModule, { targets } ),
86
110
  primitive: primitiveState,
87
111
  depthStencil: {
88
112
  format: depthStencilFormat,
@@ -94,7 +118,8 @@ class WebGPUPipelineUtils {
94
118
  stencilWriteMask: material.stencilWriteMask
95
119
  },
96
120
  multisample: {
97
- count: sampleCount
121
+ count: sampleCount,
122
+ alphaToCoverageEnabled: material.alphaToCoverage
98
123
  },
99
124
  layout: device.createPipelineLayout( {
100
125
  bindGroupLayouts: [ bindingsData.layout ]