super-three 0.161.0 → 0.163.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 +822 -1332
- package/build/three.module.js +820 -1328
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/DragControls.js +91 -30
- package/examples/jsm/controls/OrbitControls.js +32 -6
- package/examples/jsm/controls/TransformControls.js +9 -9
- package/examples/jsm/exporters/GLTFExporter.js +30 -3
- package/examples/jsm/exporters/USDZExporter.js +15 -0
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/interactive/InteractiveGroup.js +15 -25
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/tween.module.js +32 -14
- package/examples/jsm/lines/LineMaterial.js +0 -2
- package/examples/jsm/loaders/3DMLoader.js +13 -21
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/EXRLoader.js +89 -19
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +6 -0
- package/examples/jsm/loaders/KTX2Loader.js +2 -6
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/loaders/VOXLoader.js +9 -2
- package/examples/jsm/loaders/VRMLLoader.js +6 -2
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
- package/examples/jsm/nodes/Nodes.js +15 -8
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
- package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
- package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
- package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
- package/examples/jsm/nodes/accessors/MorphNode.js +20 -10
- package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
- package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +18 -0
- package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
- package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
- package/examples/jsm/nodes/code/CodeNode.js +6 -0
- package/examples/jsm/nodes/core/AssignNode.js +68 -12
- package/examples/jsm/nodes/core/Node.js +67 -6
- package/examples/jsm/nodes/core/NodeBuilder.js +23 -24
- package/examples/jsm/nodes/core/NodeFrame.js +8 -8
- package/examples/jsm/nodes/core/NodeUtils.js +2 -2
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +20 -0
- package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
- package/examples/jsm/nodes/display/PassNode.js +17 -1
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
- package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
- package/examples/jsm/nodes/fog/FogNode.js +13 -3
- package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
- package/examples/jsm/nodes/materials/NodeMaterial.js +70 -17
- package/examples/jsm/nodes/math/CondNode.js +42 -7
- package/examples/jsm/nodes/math/MathNode.js +20 -0
- package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
- package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -6
- package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
- package/examples/jsm/nodes/utils/LoopNode.js +2 -0
- package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
- package/examples/jsm/objects/QuadMesh.js +7 -23
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAOPass.js +0 -3
- package/examples/jsm/renderers/common/Animation.js +3 -0
- package/examples/jsm/renderers/common/Background.js +3 -3
- package/examples/jsm/renderers/common/ClippingContext.js +165 -0
- package/examples/jsm/renderers/common/Info.js +11 -19
- package/examples/jsm/renderers/common/PostProcessing.js +12 -4
- package/examples/jsm/renderers/common/RenderContext.js +3 -1
- package/examples/jsm/renderers/common/RenderContexts.js +2 -13
- package/examples/jsm/renderers/common/RenderObject.js +46 -3
- package/examples/jsm/renderers/common/RenderObjects.js +2 -0
- package/examples/jsm/renderers/common/Renderer.js +113 -39
- package/examples/jsm/renderers/common/StorageBufferAttribute.js +2 -2
- package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +3 -13
- package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
- package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
- package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +6 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +174 -30
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +136 -11
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +8 -2
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +90 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +67 -37
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +20 -43
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +32 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +94 -20
- package/examples/jsm/shaders/OutputShader.js +4 -0
- package/examples/jsm/utils/GPUStatsPanel.js +10 -45
- package/examples/jsm/utils/SkeletonUtils.js +14 -3
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/examples/jsm/webxr/VRButton.js +13 -5
- package/examples/jsm/webxr/XRButton.js +0 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +8 -0
- package/package.json +4 -3
- package/src/Three.Legacy.js +20 -0
- package/src/Three.js +0 -2
- package/src/animation/AnimationClip.js +1 -1
- package/src/constants.js +4 -7
- package/src/core/BufferAttribute.js +0 -11
- package/src/core/BufferGeometry.js +23 -29
- package/src/core/Object3D.js +21 -7
- package/src/core/Raycaster.js +18 -4
- package/src/core/RenderTarget.js +44 -21
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/curves/EllipseCurve.js +2 -2
- package/src/helpers/SpotLightHelper.js +18 -1
- package/src/loaders/DataTextureLoader.js +0 -4
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/loaders/ObjectLoader.js +4 -1
- package/src/materials/Material.js +2 -1
- package/src/materials/MeshBasicMaterial.js +3 -0
- package/src/materials/MeshLambertMaterial.js +3 -0
- package/src/materials/MeshPhongMaterial.js +3 -0
- package/src/materials/MeshStandardMaterial.js +3 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/math/Quaternion.js +13 -12
- package/src/math/Spherical.js +4 -5
- package/src/math/Vector3.js +7 -7
- package/src/objects/BatchedMesh.js +4 -3
- package/src/objects/InstancedMesh.js +63 -0
- package/src/objects/Mesh.js +0 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -10
- package/src/renderers/WebGLRenderer.js +70 -136
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +23 -0
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
- 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/linedashed.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +3 -2
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +6 -33
- package/src/renderers/webgl/WebGLBackground.js +18 -0
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLCapabilities.js +2 -12
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +4 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLLights.js +6 -32
- package/src/renderers/webgl/WebGLMaterials.js +26 -4
- package/src/renderers/webgl/WebGLMorphtargets.js +79 -210
- package/src/renderers/webgl/WebGLProgram.js +30 -48
- package/src/renderers/webgl/WebGLPrograms.js +5 -14
- package/src/renderers/webgl/WebGLRenderStates.js +8 -6
- package/src/renderers/webgl/WebGLState.js +21 -75
- package/src/renderers/webgl/WebGLTextures.js +143 -275
- package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
- package/src/renderers/webgl/WebGLUtils.js +6 -57
- package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/scenes/Scene.js +14 -0
- package/src/textures/Texture.js +6 -24
- package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/src/renderers/WebGL1Renderer.js +0 -7
- package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { MathNode, GLSLNodeParser, NodeBuilder } from '../../../nodes/Nodes.js';
|
|
1
|
+
import { MathNode, GLSLNodeParser, NodeBuilder, UniformNode, vectorComponents } from '../../../nodes/Nodes.js';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import NodeUniformBuffer from '../../common/nodes/NodeUniformBuffer.js';
|
|
4
4
|
import NodeUniformsGroup from '../../common/nodes/NodeUniformsGroup.js';
|
|
5
5
|
|
|
6
6
|
import { NodeSampledTexture, NodeSampledCubeTexture } from '../../common/nodes/NodeSampledTexture.js';
|
|
7
7
|
|
|
8
|
-
import { IntType } from 'three';
|
|
8
|
+
import { RedFormat, RGFormat, IntType, DataTexture, RGBFormat, RGBAFormat, FloatType } from 'three';
|
|
9
9
|
|
|
10
10
|
const glslMethods = {
|
|
11
11
|
[ MathNode.ATAN2 ]: 'atan',
|
|
12
|
-
textureDimensions: 'textureSize'
|
|
12
|
+
textureDimensions: 'textureSize',
|
|
13
|
+
equals: 'equal'
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
const precisionLib = {
|
|
@@ -19,7 +20,8 @@ const precisionLib = {
|
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
const supports = {
|
|
22
|
-
instance: true
|
|
23
|
+
instance: true,
|
|
24
|
+
swizzleAssign: true
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
const defaultPrecisions = `
|
|
@@ -84,6 +86,130 @@ ${ flowData.code }
|
|
|
84
86
|
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
setupPBO( storageBufferNode ) {
|
|
90
|
+
|
|
91
|
+
const attribute = storageBufferNode.value;
|
|
92
|
+
|
|
93
|
+
if ( attribute.pbo === undefined ) {
|
|
94
|
+
|
|
95
|
+
const originalArray = attribute.array;
|
|
96
|
+
const numElements = attribute.count * attribute.itemSize;
|
|
97
|
+
|
|
98
|
+
const { itemSize } = attribute;
|
|
99
|
+
let format = RedFormat;
|
|
100
|
+
|
|
101
|
+
if ( itemSize === 2 ) {
|
|
102
|
+
|
|
103
|
+
format = RGFormat;
|
|
104
|
+
|
|
105
|
+
} else if ( itemSize === 3 ) {
|
|
106
|
+
|
|
107
|
+
format = RGBFormat;
|
|
108
|
+
|
|
109
|
+
} else if ( itemSize === 4 ) {
|
|
110
|
+
|
|
111
|
+
format = RGBAFormat;
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const width = Math.pow( 2, Math.ceil( Math.log2( Math.sqrt( numElements / itemSize ) ) ) );
|
|
116
|
+
let height = Math.ceil( ( numElements / itemSize ) / width );
|
|
117
|
+
if ( width * height * itemSize < numElements ) height ++; // Ensure enough space
|
|
118
|
+
|
|
119
|
+
const newSize = width * height * itemSize;
|
|
120
|
+
|
|
121
|
+
const newArray = new Float32Array( newSize );
|
|
122
|
+
|
|
123
|
+
newArray.set( originalArray, 0 );
|
|
124
|
+
|
|
125
|
+
attribute.array = newArray;
|
|
126
|
+
|
|
127
|
+
const pboTexture = new DataTexture( attribute.array, width, height, format, FloatType );
|
|
128
|
+
pboTexture.needsUpdate = true;
|
|
129
|
+
pboTexture.isPBOTexture = true;
|
|
130
|
+
|
|
131
|
+
const pbo = new UniformNode( pboTexture );
|
|
132
|
+
pbo.setPrecision( 'high' );
|
|
133
|
+
|
|
134
|
+
attribute.pboNode = pbo;
|
|
135
|
+
attribute.pbo = pbo.value;
|
|
136
|
+
|
|
137
|
+
this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.label );
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
generatePBO( storageArrayElementNode ) {
|
|
144
|
+
|
|
145
|
+
const { node, indexNode } = storageArrayElementNode;
|
|
146
|
+
const attribute = node.value;
|
|
147
|
+
|
|
148
|
+
if ( this.renderer.backend.has( attribute ) ) {
|
|
149
|
+
|
|
150
|
+
const attributeData = this.renderer.backend.get( attribute );
|
|
151
|
+
attributeData.pbo = attribute.pbo;
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
const nodeUniform = this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.label );
|
|
157
|
+
const textureName = this.getPropertyName( nodeUniform );
|
|
158
|
+
|
|
159
|
+
indexNode.increaseUsage( this ); // force cache generate to be used as index in x,y
|
|
160
|
+
const indexSnippet = indexNode.build( this, 'uint' );
|
|
161
|
+
|
|
162
|
+
const elementNodeData = this.getDataFromNode( storageArrayElementNode );
|
|
163
|
+
|
|
164
|
+
let propertyName = elementNodeData.propertyName;
|
|
165
|
+
|
|
166
|
+
if ( propertyName === undefined ) {
|
|
167
|
+
|
|
168
|
+
// property element
|
|
169
|
+
|
|
170
|
+
const nodeVar = this.getVarFromNode( storageArrayElementNode );
|
|
171
|
+
|
|
172
|
+
propertyName = this.getPropertyName( nodeVar );
|
|
173
|
+
|
|
174
|
+
// property size
|
|
175
|
+
|
|
176
|
+
const bufferNodeData = this.getDataFromNode( node );
|
|
177
|
+
|
|
178
|
+
let propertySizeName = bufferNodeData.propertySizeName;
|
|
179
|
+
|
|
180
|
+
if ( propertySizeName === undefined ) {
|
|
181
|
+
|
|
182
|
+
propertySizeName = propertyName + 'Size';
|
|
183
|
+
|
|
184
|
+
this.getVarFromNode( node, propertySizeName, 'uint' );
|
|
185
|
+
|
|
186
|
+
this.addLineFlowCode( `${ propertySizeName } = uint( textureSize( ${ textureName }, 0 ).x )` );
|
|
187
|
+
|
|
188
|
+
bufferNodeData.propertySizeName = propertySizeName;
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
//
|
|
193
|
+
|
|
194
|
+
const { itemSize } = attribute;
|
|
195
|
+
|
|
196
|
+
const channel = '.' + vectorComponents.join( '' ).slice( 0, itemSize );
|
|
197
|
+
const uvSnippet = `ivec2(${indexSnippet} % ${ propertySizeName }, ${indexSnippet} / ${ propertySizeName })`;
|
|
198
|
+
|
|
199
|
+
const snippet = this.generateTextureLoad( null, textureName, uvSnippet, null, '0' );
|
|
200
|
+
|
|
201
|
+
//
|
|
202
|
+
|
|
203
|
+
this.addLineFlowCode( `${ propertyName } = ${ snippet + channel }` );
|
|
204
|
+
|
|
205
|
+
elementNodeData.propertyName = propertyName;
|
|
206
|
+
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return propertyName;
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
87
213
|
generateTextureLoad( texture, textureProperty, uvIndexSnippet, depthSnippet, levelSnippet = '0' ) {
|
|
88
214
|
|
|
89
215
|
if ( depthSnippet ) {
|
|
@@ -264,7 +390,7 @@ ${ flowData.code }
|
|
|
264
390
|
|
|
265
391
|
const array = dataAttribute.array;
|
|
266
392
|
|
|
267
|
-
if ( ( array instanceof Uint32Array || array instanceof Int32Array ) === false ) {
|
|
393
|
+
if ( ( array instanceof Uint32Array || array instanceof Int32Array || array instanceof Uint16Array || array instanceof Int16Array ) === false ) {
|
|
268
394
|
|
|
269
395
|
nodeType = nodeType.slice( 1 );
|
|
270
396
|
|
|
@@ -416,7 +542,6 @@ ${ flowData.code }
|
|
|
416
542
|
|
|
417
543
|
}
|
|
418
544
|
|
|
419
|
-
|
|
420
545
|
isFlipY() {
|
|
421
546
|
|
|
422
547
|
return true;
|
|
@@ -630,11 +755,11 @@ void main() {
|
|
|
630
755
|
|
|
631
756
|
} else if ( type === 'buffer' ) {
|
|
632
757
|
|
|
633
|
-
node.name = `NodeBuffer_${node.id}`;
|
|
634
|
-
|
|
635
|
-
const buffer = new UniformBuffer( node.name, node.value );
|
|
758
|
+
node.name = `NodeBuffer_${ node.id }`;
|
|
759
|
+
uniformNode.name = `buffer${ node.id }`;
|
|
636
760
|
|
|
637
|
-
|
|
761
|
+
const buffer = new NodeUniformBuffer( node );
|
|
762
|
+
buffer.name = node.name;
|
|
638
763
|
|
|
639
764
|
this.bindings[ shaderStage ].push( buffer );
|
|
640
765
|
|
|
@@ -8,6 +8,9 @@ class DualAttributeData {
|
|
|
8
8
|
|
|
9
9
|
this.buffers = [ attributeData.bufferGPU, dualBuffer ];
|
|
10
10
|
this.type = attributeData.type;
|
|
11
|
+
this.bufferType = attributeData.bufferType;
|
|
12
|
+
this.pbo = attributeData.pbo;
|
|
13
|
+
this.byteLength = attributeData.byteLength;
|
|
11
14
|
this.bytesPerElement = attributeData.BYTES_PER_ELEMENT;
|
|
12
15
|
this.version = attributeData.version;
|
|
13
16
|
this.isInteger = attributeData.isInteger;
|
|
@@ -126,14 +129,17 @@ class WebGLAttributeUtils {
|
|
|
126
129
|
|
|
127
130
|
let attributeData = {
|
|
128
131
|
bufferGPU,
|
|
132
|
+
bufferType,
|
|
129
133
|
type,
|
|
134
|
+
byteLength: array.byteLength,
|
|
130
135
|
bytesPerElement: array.BYTES_PER_ELEMENT,
|
|
131
136
|
version: attribute.version,
|
|
132
|
-
|
|
137
|
+
pbo: attribute.pbo,
|
|
138
|
+
isInteger: type === gl.INT || type === gl.UNSIGNED_INT || type === gl.UNSIGNED_SHORT || attribute.gpuType === IntType,
|
|
133
139
|
id: _id ++
|
|
134
140
|
};
|
|
135
141
|
|
|
136
|
-
if ( attribute.isStorageBufferAttribute ) {
|
|
142
|
+
if ( attribute.isStorageBufferAttribute || attribute.isStorageInstancedBufferAttribute ) {
|
|
137
143
|
|
|
138
144
|
// create buffer for tranform feedback use
|
|
139
145
|
const bufferGPUDual = this._createBuffer( gl, bufferType, array, usage );
|
|
@@ -7,5 +7,6 @@ export const GLFeatureName = {
|
|
|
7
7
|
'WEBKIT_WEBGL_compressed_texture_pvrtc': 'texture-compression-pvrtc',
|
|
8
8
|
'WEBGL_compressed_texture_s3tc': 'texture-compression-bc',
|
|
9
9
|
'EXT_texture_compression_bptc': 'texture-compression-bptc',
|
|
10
|
+
'EXT_disjoint_timer_query_webgl2': 'timestamp-query',
|
|
10
11
|
|
|
11
12
|
};
|
|
@@ -135,6 +135,18 @@ class WebGLTextureUtils {
|
|
|
135
135
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
if ( glFormat === gl.RGB ) {
|
|
139
|
+
|
|
140
|
+
if ( glType === gl.FLOAT ) internalFormat = gl.RGB32F;
|
|
141
|
+
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RGB16F;
|
|
142
|
+
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RGB8;
|
|
143
|
+
if ( glType === gl.UNSIGNED_SHORT_5_6_5 ) internalFormat = gl.RGB565;
|
|
144
|
+
if ( glType === gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = gl.RGB5_A1;
|
|
145
|
+
if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = gl.RGB4;
|
|
146
|
+
if ( glType === gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = gl.RGB9_E5;
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
138
150
|
if ( glFormat === gl.RGBA ) {
|
|
139
151
|
|
|
140
152
|
if ( glType === gl.FLOAT ) internalFormat = gl.RGBA32F;
|
|
@@ -207,6 +219,7 @@ class WebGLTextureUtils {
|
|
|
207
219
|
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
|
|
208
220
|
|
|
209
221
|
if ( texture.anisotropy > 1 || currentAnisotropy !== texture.anisotropy ) {
|
|
222
|
+
|
|
210
223
|
const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
|
|
211
224
|
gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, backend.getMaxAnisotropy() ) );
|
|
212
225
|
backend.get( texture ).currentAnisotropy = texture.anisotropy;
|
|
@@ -289,6 +302,41 @@ class WebGLTextureUtils {
|
|
|
289
302
|
|
|
290
303
|
}
|
|
291
304
|
|
|
305
|
+
copyBufferToTexture( buffer, texture ) {
|
|
306
|
+
|
|
307
|
+
const { gl, backend } = this;
|
|
308
|
+
|
|
309
|
+
const { textureGPU, glTextureType, glFormat, glType } = backend.get( texture );
|
|
310
|
+
|
|
311
|
+
const { width, height } = texture.source.data;
|
|
312
|
+
|
|
313
|
+
gl.bindBuffer( gl.PIXEL_UNPACK_BUFFER, buffer );
|
|
314
|
+
|
|
315
|
+
backend.state.bindTexture( glTextureType, textureGPU );
|
|
316
|
+
|
|
317
|
+
gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, false );
|
|
318
|
+
gl.pixelStorei( gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false );
|
|
319
|
+
gl.texSubImage2D( glTextureType, 0, 0, 0, width, height, glFormat, glType, 0 );
|
|
320
|
+
|
|
321
|
+
gl.bindBuffer( gl.PIXEL_UNPACK_BUFFER, null );
|
|
322
|
+
|
|
323
|
+
backend.state.unbindTexture();
|
|
324
|
+
// debug
|
|
325
|
+
// const framebuffer = gl.createFramebuffer();
|
|
326
|
+
// gl.bindFramebuffer( gl.FRAMEBUFFER, framebuffer );
|
|
327
|
+
// gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, glTextureType, textureGPU, 0 );
|
|
328
|
+
|
|
329
|
+
// const readout = new Float32Array( width * height * 4 );
|
|
330
|
+
|
|
331
|
+
// const altFormat = gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_FORMAT );
|
|
332
|
+
// const altType = gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_TYPE );
|
|
333
|
+
|
|
334
|
+
// gl.readPixels( 0, 0, width, height, altFormat, altType, readout );
|
|
335
|
+
// gl.bindFramebuffer( gl.FRAMEBUFFER, null );
|
|
336
|
+
// console.log( readout );
|
|
337
|
+
|
|
338
|
+
}
|
|
339
|
+
|
|
292
340
|
updateTexture( texture, options ) {
|
|
293
341
|
|
|
294
342
|
const { gl } = this;
|
|
@@ -476,6 +524,48 @@ class WebGLTextureUtils {
|
|
|
476
524
|
|
|
477
525
|
}
|
|
478
526
|
|
|
527
|
+
copyTextureToTexture( position, srcTexture, dstTexture, level = 0 ) {
|
|
528
|
+
|
|
529
|
+
const { gl, backend } = this;
|
|
530
|
+
const { state } = this.backend;
|
|
531
|
+
|
|
532
|
+
const width = srcTexture.image.width;
|
|
533
|
+
const height = srcTexture.image.height;
|
|
534
|
+
const { textureGPU: dstTextureGPU, glTextureType, glType, glFormat } = backend.get( dstTexture );
|
|
535
|
+
|
|
536
|
+
state.bindTexture( glTextureType, dstTextureGPU );
|
|
537
|
+
|
|
538
|
+
// As another texture upload may have changed pixelStorei
|
|
539
|
+
// parameters, make sure they are correct for the dstTexture
|
|
540
|
+
gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
|
|
541
|
+
gl.pixelStorei( gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
542
|
+
gl.pixelStorei( gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
543
|
+
|
|
544
|
+
if ( srcTexture.isDataTexture ) {
|
|
545
|
+
|
|
546
|
+
gl.texSubImage2D( gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );
|
|
547
|
+
|
|
548
|
+
} else {
|
|
549
|
+
|
|
550
|
+
if ( srcTexture.isCompressedTexture ) {
|
|
551
|
+
|
|
552
|
+
gl.compressedTexSubImage2D( gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data );
|
|
553
|
+
|
|
554
|
+
} else {
|
|
555
|
+
|
|
556
|
+
gl.texSubImage2D( gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );
|
|
557
|
+
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// Generate mipmaps only when copying level 0
|
|
563
|
+
if ( level === 0 && dstTexture.generateMipmaps ) gl.generateMipmap( gl.TEXTURE_2D );
|
|
564
|
+
|
|
565
|
+
state.unbindTexture();
|
|
566
|
+
|
|
567
|
+
}
|
|
568
|
+
|
|
479
569
|
copyFramebufferToTexture( texture, renderContext ) {
|
|
480
570
|
|
|
481
571
|
const { gl } = this;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format,
|
|
1
|
+
import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, SRGBColorSpace, NoColorSpace } from 'three';
|
|
2
2
|
|
|
3
3
|
class WebGLUtils {
|
|
4
4
|
|
|
@@ -20,6 +20,7 @@ class WebGLUtils {
|
|
|
20
20
|
if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
|
|
21
21
|
if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
|
|
22
22
|
if ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;
|
|
23
|
+
if ( p === UnsignedInt5999Type ) return gl.UNSIGNED_INT_5_9_9_9_REV;
|
|
23
24
|
|
|
24
25
|
if ( p === ByteType ) return gl.BYTE;
|
|
25
26
|
if ( p === ShortType ) return gl.SHORT;
|
|
@@ -35,6 +36,7 @@ class WebGLUtils {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
if ( p === AlphaFormat ) return gl.ALPHA;
|
|
39
|
+
if ( p === RGBFormat ) return gl.RGB;
|
|
38
40
|
if ( p === RGBAFormat ) return gl.RGBA;
|
|
39
41
|
if ( p === LuminanceFormat ) return gl.LUMINANCE;
|
|
40
42
|
if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
|
|
@@ -40,8 +40,6 @@ class GLSL1NodeBuilder extends NodeBuilder {
|
|
|
40
40
|
|
|
41
41
|
getTextureBias( texture, textureProperty, uvSnippet, biasSnippet ) {
|
|
42
42
|
|
|
43
|
-
if ( this.material.extensions !== undefined ) this.material.extensions.shaderTextureLOD = true;
|
|
44
|
-
|
|
45
43
|
return `textureLod( ${textureProperty}, ${uvSnippet}, ${biasSnippet} )`;
|
|
46
44
|
|
|
47
45
|
}
|
|
@@ -433,8 +433,6 @@ class WebGLNodeBuilder extends NodeBuilder {
|
|
|
433
433
|
|
|
434
434
|
generateTextureLevel( texture, textureProperty, uvSnippet, biasSnippet ) {
|
|
435
435
|
|
|
436
|
-
if ( this.material.extensions !== undefined ) this.material.extensions.shaderTextureLOD = true;
|
|
437
|
-
|
|
438
436
|
return `textureLod( ${textureProperty}, ${uvSnippet}, ${biasSnippet} )`;
|
|
439
437
|
|
|
440
438
|
}
|
|
@@ -602,9 +602,6 @@ class WebGPUBackend extends Backend {
|
|
|
602
602
|
supportsDepth = renderer.depth;
|
|
603
603
|
supportsStencil = renderer.stencil;
|
|
604
604
|
|
|
605
|
-
depth = depth && supportsDepth;
|
|
606
|
-
stencil = stencil && supportsStencil;
|
|
607
|
-
|
|
608
605
|
const descriptor = this._getDefaultRenderPassDescriptor();
|
|
609
606
|
|
|
610
607
|
if ( color ) {
|
|
@@ -619,7 +616,7 @@ class WebGPUBackend extends Backend {
|
|
|
619
616
|
|
|
620
617
|
}
|
|
621
618
|
|
|
622
|
-
if (
|
|
619
|
+
if ( supportsDepth || supportsStencil ) {
|
|
623
620
|
|
|
624
621
|
depthStencilAttachment = descriptor.depthStencilAttachment;
|
|
625
622
|
|
|
@@ -630,9 +627,6 @@ class WebGPUBackend extends Backend {
|
|
|
630
627
|
supportsDepth = renderTargetData.depth;
|
|
631
628
|
supportsStencil = renderTargetData.stencil;
|
|
632
629
|
|
|
633
|
-
depth = depth && supportsDepth;
|
|
634
|
-
stencil = stencil && supportsStencil;
|
|
635
|
-
|
|
636
630
|
if ( color ) {
|
|
637
631
|
|
|
638
632
|
for ( const texture of renderTargetData.textures ) {
|
|
@@ -666,7 +660,7 @@ class WebGPUBackend extends Backend {
|
|
|
666
660
|
|
|
667
661
|
}
|
|
668
662
|
|
|
669
|
-
if (
|
|
663
|
+
if ( supportsDepth || supportsStencil ) {
|
|
670
664
|
|
|
671
665
|
const depthTextureData = this.get( renderTargetData.depthTexture );
|
|
672
666
|
|
|
@@ -680,7 +674,7 @@ class WebGPUBackend extends Backend {
|
|
|
680
674
|
|
|
681
675
|
//
|
|
682
676
|
|
|
683
|
-
if (
|
|
677
|
+
if ( supportsDepth ) {
|
|
684
678
|
|
|
685
679
|
if ( depth ) {
|
|
686
680
|
|
|
@@ -695,7 +689,11 @@ class WebGPUBackend extends Backend {
|
|
|
695
689
|
|
|
696
690
|
}
|
|
697
691
|
|
|
698
|
-
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
//
|
|
695
|
+
|
|
696
|
+
if ( supportsStencil ) {
|
|
699
697
|
|
|
700
698
|
if ( stencil ) {
|
|
701
699
|
|
|
@@ -929,7 +927,8 @@ class WebGPUBackend extends Backend {
|
|
|
929
927
|
data.side !== material.side || data.alphaToCoverage !== material.alphaToCoverage ||
|
|
930
928
|
data.sampleCount !== sampleCount || data.colorSpace !== colorSpace ||
|
|
931
929
|
data.colorFormat !== colorFormat || data.depthStencilFormat !== depthStencilFormat ||
|
|
932
|
-
data.primitiveTopology !== primitiveTopology
|
|
930
|
+
data.primitiveTopology !== primitiveTopology ||
|
|
931
|
+
data.clippingContextVersion !== renderObject.clippingContextVersion
|
|
933
932
|
) {
|
|
934
933
|
|
|
935
934
|
data.material = material; data.materialVersion = material.version;
|
|
@@ -947,6 +946,7 @@ class WebGPUBackend extends Backend {
|
|
|
947
946
|
data.colorFormat = colorFormat;
|
|
948
947
|
data.depthStencilFormat = depthStencilFormat;
|
|
949
948
|
data.primitiveTopology = primitiveTopology;
|
|
949
|
+
data.clippingContextVersion = renderObject.clippingContextVersion;
|
|
950
950
|
|
|
951
951
|
needsUpdate = true;
|
|
952
952
|
|
|
@@ -975,7 +975,8 @@ class WebGPUBackend extends Backend {
|
|
|
975
975
|
material.side,
|
|
976
976
|
utils.getSampleCount( renderContext ),
|
|
977
977
|
utils.getCurrentColorSpace( renderContext ), utils.getCurrentColorFormat( renderContext ), utils.getCurrentDepthStencilFormat( renderContext ),
|
|
978
|
-
utils.getPrimitiveTopology( object, material )
|
|
978
|
+
utils.getPrimitiveTopology( object, material ),
|
|
979
|
+
renderObject.clippingContextVersion
|
|
979
980
|
].join();
|
|
980
981
|
|
|
981
982
|
}
|
|
@@ -1048,9 +1049,11 @@ class WebGPUBackend extends Backend {
|
|
|
1048
1049
|
beginningOfPassWriteIndex: 0, // Write timestamp in index 0 when pass begins.
|
|
1049
1050
|
endOfPassWriteIndex: 1, // Write timestamp in index 1 when pass ends.
|
|
1050
1051
|
};
|
|
1052
|
+
|
|
1051
1053
|
Object.assign( descriptor, {
|
|
1052
1054
|
timestampWrites,
|
|
1053
1055
|
} );
|
|
1056
|
+
|
|
1054
1057
|
renderContextData.timeStampQuerySet = timeStampQuerySet;
|
|
1055
1058
|
|
|
1056
1059
|
}
|
|
@@ -1083,33 +1086,29 @@ class WebGPUBackend extends Backend {
|
|
|
1083
1086
|
|
|
1084
1087
|
}
|
|
1085
1088
|
|
|
1086
|
-
async resolveTimestampAsync(
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
const renderContextData = this.get( renderContext );
|
|
1091
|
-
|
|
1092
|
-
// handle timestamp query results
|
|
1093
|
-
|
|
1089
|
+
async resolveTimestampAsync(renderContext, type = 'render') {
|
|
1090
|
+
if (!this.hasFeature(GPUFeatureName.TimestampQuery) || !this.trackTimestamp) return;
|
|
1091
|
+
|
|
1092
|
+
const renderContextData = this.get(renderContext);
|
|
1094
1093
|
const { currentTimestampQueryBuffer } = renderContextData;
|
|
1095
|
-
|
|
1096
|
-
if (
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
const times = new BigUint64Array(
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1094
|
+
|
|
1095
|
+
if (currentTimestampQueryBuffer === undefined) return;
|
|
1096
|
+
|
|
1097
|
+
const buffer = currentTimestampQueryBuffer;
|
|
1098
|
+
|
|
1099
|
+
try {
|
|
1100
|
+
await buffer.mapAsync(GPUMapMode.READ);
|
|
1101
|
+
const times = new BigUint64Array(buffer.getMappedRange());
|
|
1102
|
+
const duration = Number(times[1] - times[0]) / 1000000;
|
|
1103
|
+
this.renderer.info.updateTimestamp(type, duration);
|
|
1104
|
+
} catch (error) {
|
|
1105
|
+
console.error(`Error mapping buffer: ${error}`);
|
|
1106
|
+
// Optionally handle the error, e.g., re-queue the buffer or skip it
|
|
1107
|
+
} finally {
|
|
1108
|
+
buffer.unmap();
|
|
1110
1109
|
}
|
|
1111
|
-
|
|
1112
1110
|
}
|
|
1111
|
+
|
|
1113
1112
|
|
|
1114
1113
|
// node builder
|
|
1115
1114
|
|
|
@@ -1235,7 +1234,7 @@ class WebGPUBackend extends Backend {
|
|
|
1235
1234
|
|
|
1236
1235
|
if ( ! this.adapter ) {
|
|
1237
1236
|
|
|
1238
|
-
console.warn( 'WebGPUBackend: WebGPU adapter has not been initialized yet. Please use
|
|
1237
|
+
console.warn( 'WebGPUBackend: WebGPU adapter has not been initialized yet. Please use hasFeatureAsync instead' );
|
|
1239
1238
|
|
|
1240
1239
|
return false;
|
|
1241
1240
|
|
|
@@ -1245,6 +1244,37 @@ class WebGPUBackend extends Backend {
|
|
|
1245
1244
|
|
|
1246
1245
|
}
|
|
1247
1246
|
|
|
1247
|
+
copyTextureToTexture( position, srcTexture, dstTexture, level = 0 ) {
|
|
1248
|
+
|
|
1249
|
+
const encoder = this.device.createCommandEncoder( { label: 'copyTextureToTexture_' + srcTexture.id + '_' + dstTexture.id } );
|
|
1250
|
+
|
|
1251
|
+
const sourceGPU = this.get( srcTexture ).texture;
|
|
1252
|
+
const destinationGPU = this.get( dstTexture ).texture;
|
|
1253
|
+
|
|
1254
|
+
encoder.copyTextureToTexture(
|
|
1255
|
+
{
|
|
1256
|
+
texture: sourceGPU,
|
|
1257
|
+
mipLevel: level,
|
|
1258
|
+
origin: { x: 0, y: 0, z: 0 }
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
texture: destinationGPU,
|
|
1262
|
+
mipLevel: level,
|
|
1263
|
+
origin: { x: position.x, y: position.y, z: position.z }
|
|
1264
|
+
},
|
|
1265
|
+
[
|
|
1266
|
+
srcTexture.image.width,
|
|
1267
|
+
srcTexture.image.height
|
|
1268
|
+
]
|
|
1269
|
+
);
|
|
1270
|
+
|
|
1271
|
+
this.device.queue.submit( [ encoder.finish() ] );
|
|
1272
|
+
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
|
|
1276
|
+
|
|
1277
|
+
|
|
1248
1278
|
copyFramebufferToTexture( texture, renderContext ) {
|
|
1249
1279
|
|
|
1250
1280
|
const renderContextData = this.get( renderContext );
|