super-three 0.168.0 → 0.169.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 +369 -131
- package/build/three.module.js +369 -131
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +24644 -22406
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -6
- package/examples/jsm/controls/TrackballControls.js +32 -12
- package/examples/jsm/controls/TransformControls.js +97 -62
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +1 -1
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +10 -7
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +29 -10
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +5 -4
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +1 -2
- package/examples/jsm/objects/Water2Mesh.js +2 -3
- package/examples/jsm/objects/WaterMesh.js +1 -2
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +1 -0
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +2 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +2 -1
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +1 -1
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/nodes/NodeLoader.js +24 -4
- package/src/loaders/nodes/NodeMaterialLoader.js +21 -17
- package/src/loaders/nodes/NodeObjectLoader.js +19 -0
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +19 -34
- package/src/materials/nodes/Line2NodeMaterial.js +26 -26
- package/src/materials/nodes/LineBasicNodeMaterial.js +7 -3
- package/src/materials/nodes/LineDashedNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshBasicNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshLambertNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshNormalNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshPhongNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +6 -3
- package/src/materials/nodes/MeshSSSNodeMaterial.js +6 -3
- package/src/materials/nodes/MeshStandardNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshToonNodeMaterial.js +7 -3
- package/src/materials/nodes/NodeMaterial.js +20 -45
- package/src/materials/nodes/NodeMaterials.js +2 -0
- package/src/materials/nodes/PointsNodeMaterial.js +7 -3
- package/src/materials/nodes/ShadowNodeMaterial.js +7 -3
- package/src/materials/nodes/SpriteNodeMaterial.js +39 -6
- package/src/materials/nodes/VolumeNodeMaterial.js +13 -9
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +3 -3
- package/src/nodes/TSL.js +96 -93
- package/src/nodes/accessors/BatchNode.js +7 -3
- package/src/nodes/accessors/BufferAttributeNode.js +6 -3
- package/src/nodes/accessors/BufferNode.js +6 -3
- package/src/nodes/accessors/Camera.js +10 -16
- package/src/nodes/accessors/ClippingNode.js +7 -3
- package/src/nodes/accessors/CubeTextureNode.js +6 -3
- package/src/nodes/accessors/InstanceNode.js +11 -11
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +6 -3
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +8 -4
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -3
- package/src/nodes/accessors/ModelNode.js +42 -7
- package/src/nodes/accessors/ModelViewProjectionNode.js +9 -5
- package/src/nodes/accessors/MorphNode.js +7 -3
- package/src/nodes/accessors/Normal.js +32 -6
- package/src/nodes/accessors/Object3DNode.js +11 -27
- package/src/nodes/accessors/PointUVNode.js +7 -3
- package/src/nodes/accessors/ReferenceBaseNode.js +32 -4
- package/src/nodes/accessors/ReferenceNode.js +40 -3
- package/src/nodes/accessors/RendererReferenceNode.js +9 -3
- package/src/nodes/accessors/SceneNode.js +7 -3
- package/src/nodes/accessors/SkinningNode.js +7 -3
- package/src/nodes/accessors/StorageBufferNode.js +21 -3
- package/src/nodes/accessors/StorageTextureNode.js +7 -4
- package/src/nodes/accessors/Texture3DNode.js +7 -4
- package/src/nodes/accessors/TextureNode.js +19 -8
- package/src/nodes/accessors/TextureSizeNode.js +8 -5
- package/src/nodes/accessors/UniformArrayNode.js +12 -9
- package/src/nodes/accessors/UserDataNode.js +9 -6
- package/src/nodes/accessors/VelocityNode.js +74 -23
- package/src/nodes/accessors/VertexColorNode.js +6 -3
- package/src/nodes/code/CodeNode.js +7 -3
- package/src/nodes/code/ExpressionNode.js +8 -4
- package/src/nodes/code/FunctionCallNode.js +6 -3
- package/src/nodes/code/FunctionNode.js +6 -3
- package/src/nodes/code/ScriptableNode.js +11 -6
- package/src/nodes/code/ScriptableValueNode.js +7 -3
- package/src/nodes/core/AssignNode.js +9 -6
- package/src/nodes/core/AttributeNode.js +7 -3
- package/src/nodes/core/BypassNode.js +8 -4
- package/src/nodes/core/CacheNode.js +8 -4
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +7 -3
- package/src/nodes/core/IndexNode.js +25 -3
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +6 -3
- package/src/nodes/core/Node.js +10 -51
- package/src/nodes/core/NodeBuilder.js +71 -5
- package/src/nodes/core/NodeUtils.js +48 -6
- package/src/nodes/core/OutputStructNode.js +8 -4
- package/src/nodes/core/ParameterNode.js +6 -3
- package/src/nodes/core/PropertyNode.js +7 -3
- package/src/nodes/core/StackNode.js +7 -3
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +10 -6
- package/src/nodes/core/UniformNode.js +6 -3
- package/src/nodes/core/VarNode.js +8 -4
- package/src/nodes/core/VaryingNode.js +7 -3
- package/src/nodes/display/AfterImageNode.js +6 -0
- package/src/nodes/display/AnaglyphPassNode.js +6 -0
- package/src/nodes/display/AnamorphicNode.js +6 -0
- package/src/nodes/display/BloomNode.js +6 -0
- package/src/nodes/display/BumpMapNode.js +6 -0
- package/src/nodes/display/ColorSpaceFunctions.js +4 -4
- package/src/nodes/display/ColorSpaceNode.js +43 -14
- package/src/nodes/display/DenoiseNode.js +6 -3
- package/src/nodes/display/DepthOfFieldNode.js +6 -3
- package/src/nodes/display/DotScreenNode.js +8 -5
- package/src/nodes/display/FXAANode.js +6 -3
- package/src/nodes/display/FilmNode.js +6 -3
- package/src/nodes/display/FrontFacingNode.js +7 -3
- package/src/nodes/display/GTAONode.js +6 -3
- package/src/nodes/display/GaussianBlurNode.js +6 -3
- package/src/nodes/display/Lut3DNode.js +6 -3
- package/src/nodes/display/NormalMapNode.js +8 -6
- package/src/nodes/display/ParallaxBarrierPassNode.js +8 -5
- package/src/nodes/display/PassNode.js +18 -7
- package/src/nodes/display/PixelationPassNode.js +12 -5
- package/src/nodes/display/PosterizeNode.js +6 -3
- package/src/nodes/display/RGBShiftNode.js +6 -3
- package/src/nodes/display/RenderOutputNode.js +12 -8
- package/src/nodes/display/SSAAPassNode.js +6 -3
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/SobelOperatorNode.js +6 -3
- package/src/nodes/display/StereoCompositePassNode.js +6 -3
- package/src/nodes/display/StereoPassNode.js +6 -3
- package/src/nodes/display/ToneMappingFunctions.js +12 -12
- package/src/nodes/display/ToneMappingNode.js +8 -7
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +6 -3
- package/src/nodes/display/ViewportDepthNode.js +7 -3
- package/src/nodes/display/ViewportDepthTextureNode.js +8 -5
- package/src/nodes/display/ViewportSharedTextureNode.js +8 -5
- package/src/nodes/display/ViewportTextureNode.js +8 -5
- package/src/nodes/fog/FogExp2Node.js +6 -3
- package/src/nodes/fog/FogNode.js +7 -3
- package/src/nodes/fog/FogRangeNode.js +6 -3
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +7 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +8 -4
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -3
- package/src/nodes/lighting/AnalyticLightNode.js +198 -30
- package/src/nodes/lighting/BasicEnvironmentNode.js +6 -3
- package/src/nodes/lighting/BasicLightMapNode.js +6 -3
- package/src/nodes/lighting/DirectionalLightNode.js +7 -4
- package/src/nodes/lighting/EnvironmentNode.js +6 -3
- package/src/nodes/lighting/HemisphereLightNode.js +10 -6
- package/src/nodes/lighting/IESSpotLightNode.js +6 -3
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +8 -31
- package/src/nodes/lighting/LightingContextNode.js +6 -3
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +24 -5
- package/src/nodes/lighting/PointLightNode.js +11 -7
- package/src/nodes/lighting/RectAreaLightNode.js +11 -7
- package/src/nodes/lighting/SpotLightNode.js +13 -10
- package/src/nodes/math/ConditionalNode.js +23 -6
- package/src/nodes/math/MathNode.js +6 -3
- package/src/nodes/math/OperatorNode.js +6 -3
- package/src/nodes/pmrem/PMREMNode.js +6 -3
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +6 -3
- package/src/nodes/utils/EquirectUVNode.js +6 -3
- package/src/nodes/utils/FlipNode.js +7 -4
- package/src/nodes/utils/FunctionOverloadingNode.js +7 -3
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +7 -3
- package/src/nodes/utils/MatcapUVNode.js +6 -3
- package/src/nodes/utils/MaxMipLevelNode.js +6 -3
- package/src/nodes/utils/OscNode.js +7 -3
- package/src/nodes/utils/RTTNode.js +6 -3
- package/src/nodes/utils/ReflectorNode.js +8 -5
- package/src/nodes/utils/RemapNode.js +7 -3
- package/src/nodes/utils/RotateNode.js +6 -3
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +7 -3
- package/src/nodes/utils/StorageArrayElementNode.js +9 -8
- package/src/nodes/utils/TimerNode.js +6 -3
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -3
- package/src/nodes/utils/ViewportUtils.js +2 -2
- package/src/objects/BatchedMesh.js +76 -10
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +64 -41
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +4 -3
- package/src/renderers/common/RenderContext.js +4 -5
- package/src/renderers/common/RenderObject.js +116 -5
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +57 -49
- package/src/renderers/common/extras/PMREMGenerator.js +7 -9
- package/src/renderers/common/nodes/NodeBuilderState.js +3 -3
- package/src/renderers/common/nodes/Nodes.js +33 -14
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +2 -0
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +22 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +50 -45
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +4 -4
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +61 -16
- package/src/renderers/webgpu/WebGPUBackend.js +33 -25
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +5 -2
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/{common → webgpu}/nodes/StandardNodeLibrary.js +11 -11
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +91 -11
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +7 -5
- package/src/renderers/webgpu/utils/WebGPUUtils.js +1 -1
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/display/ViewportNode.js +0 -138
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/renderers/common/StandardRenderer.js +0 -18
|
@@ -3,9 +3,10 @@ import ChainMap from '../ChainMap.js';
|
|
|
3
3
|
import NodeBuilderState from './NodeBuilderState.js';
|
|
4
4
|
import { cubeMapNode } from '../../../nodes/utils/CubeMapNode.js';
|
|
5
5
|
import { NodeFrame } from '../../../nodes/Nodes.js';
|
|
6
|
-
import { objectGroup, renderGroup, frameGroup, cubeTexture, texture, rangeFog, densityFog, reference, normalWorld, pmremTexture,
|
|
6
|
+
import { objectGroup, renderGroup, frameGroup, cubeTexture, texture, rangeFog, densityFog, reference, normalWorld, pmremTexture, screenUV } from '../../../nodes/TSL.js';
|
|
7
7
|
|
|
8
|
-
import { EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../../constants.js';
|
|
8
|
+
import { CubeUVReflectionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../../constants.js';
|
|
9
|
+
import { hashArray } from '../../../nodes/core/NodeUtils.js';
|
|
9
10
|
|
|
10
11
|
const outputNodeMap = new WeakMap();
|
|
11
12
|
|
|
@@ -190,7 +191,7 @@ class Nodes extends DataMap {
|
|
|
190
191
|
nodeBuilder.updateNodes,
|
|
191
192
|
nodeBuilder.updateBeforeNodes,
|
|
192
193
|
nodeBuilder.updateAfterNodes,
|
|
193
|
-
nodeBuilder.
|
|
194
|
+
nodeBuilder.monitor,
|
|
194
195
|
nodeBuilder.transforms
|
|
195
196
|
);
|
|
196
197
|
|
|
@@ -226,15 +227,17 @@ class Nodes extends DataMap {
|
|
|
226
227
|
const environmentNode = this.getEnvironmentNode( scene );
|
|
227
228
|
const fogNode = this.getFogNode( scene );
|
|
228
229
|
|
|
229
|
-
const
|
|
230
|
+
const values = [];
|
|
230
231
|
|
|
231
|
-
if ( lightsNode )
|
|
232
|
-
if ( environmentNode )
|
|
233
|
-
if ( fogNode )
|
|
232
|
+
if ( lightsNode ) values.push( lightsNode.getCacheKey( true ) );
|
|
233
|
+
if ( environmentNode ) values.push( environmentNode.getCacheKey() );
|
|
234
|
+
if ( fogNode ) values.push( fogNode.getCacheKey() );
|
|
235
|
+
|
|
236
|
+
values.push( this.renderer.shadowMap.enabled ? 1 : 0 );
|
|
234
237
|
|
|
235
238
|
cacheKeyData = {
|
|
236
239
|
callId,
|
|
237
|
-
cacheKey:
|
|
240
|
+
cacheKey: hashArray( values )
|
|
238
241
|
};
|
|
239
242
|
|
|
240
243
|
this.callHashCache.set( chain, cacheKeyData );
|
|
@@ -272,9 +275,9 @@ class Nodes extends DataMap {
|
|
|
272
275
|
|
|
273
276
|
let backgroundNode = null;
|
|
274
277
|
|
|
275
|
-
if ( background.isCubeTexture === true || ( background.mapping === EquirectangularReflectionMapping || background.mapping === EquirectangularRefractionMapping ) ) {
|
|
278
|
+
if ( background.isCubeTexture === true || ( background.mapping === EquirectangularReflectionMapping || background.mapping === EquirectangularRefractionMapping || background.mapping === CubeUVReflectionMapping ) ) {
|
|
276
279
|
|
|
277
|
-
if ( scene.backgroundBlurriness > 0 ) {
|
|
280
|
+
if ( scene.backgroundBlurriness > 0 || background.mapping === CubeUVReflectionMapping ) {
|
|
278
281
|
|
|
279
282
|
backgroundNode = pmremTexture( background, normalWorld );
|
|
280
283
|
|
|
@@ -298,7 +301,7 @@ class Nodes extends DataMap {
|
|
|
298
301
|
|
|
299
302
|
} else if ( background.isTexture === true ) {
|
|
300
303
|
|
|
301
|
-
backgroundNode = texture( background,
|
|
304
|
+
backgroundNode = texture( background, screenUV.flipY() ).setUpdateMatrix( true );
|
|
302
305
|
|
|
303
306
|
} else if ( background.isColor !== true ) {
|
|
304
307
|
|
|
@@ -334,11 +337,18 @@ class Nodes extends DataMap {
|
|
|
334
337
|
|
|
335
338
|
if ( fog.isFogExp2 ) {
|
|
336
339
|
|
|
337
|
-
|
|
340
|
+
const color = reference( 'color', 'color', fog ).setGroup( renderGroup );
|
|
341
|
+
const density = reference( 'density', 'float', fog ).setGroup( renderGroup );
|
|
342
|
+
|
|
343
|
+
fogNode = densityFog( color, density );
|
|
338
344
|
|
|
339
345
|
} else if ( fog.isFog ) {
|
|
340
346
|
|
|
341
|
-
|
|
347
|
+
const color = reference( 'color', 'color', fog ).setGroup( renderGroup );
|
|
348
|
+
const near = reference( 'near', 'float', fog ).setGroup( renderGroup );
|
|
349
|
+
const far = reference( 'far', 'float', fog ).setGroup( renderGroup );
|
|
350
|
+
|
|
351
|
+
fogNode = rangeFog( color, near, far );
|
|
342
352
|
|
|
343
353
|
} else {
|
|
344
354
|
|
|
@@ -439,7 +449,7 @@ class Nodes extends DataMap {
|
|
|
439
449
|
const renderer = this.renderer;
|
|
440
450
|
const cacheKey = this.getOutputCacheKey();
|
|
441
451
|
|
|
442
|
-
const output = texture( outputTexture,
|
|
452
|
+
const output = texture( outputTexture, screenUV ).renderOutput( renderer.toneMapping, renderer.currentColorSpace );
|
|
443
453
|
|
|
444
454
|
outputNodeMap.set( outputTexture, cacheKey );
|
|
445
455
|
|
|
@@ -501,6 +511,15 @@ class Nodes extends DataMap {
|
|
|
501
511
|
|
|
502
512
|
}
|
|
503
513
|
|
|
514
|
+
needsRefresh( renderObject ) {
|
|
515
|
+
|
|
516
|
+
const nodeFrame = this.getNodeFrameForRender( renderObject );
|
|
517
|
+
const monitor = renderObject.getMonitor();
|
|
518
|
+
|
|
519
|
+
return monitor.needsRefresh( renderObject, nodeFrame );
|
|
520
|
+
|
|
521
|
+
}
|
|
522
|
+
|
|
504
523
|
dispose() {
|
|
505
524
|
|
|
506
525
|
super.dispose();
|
|
@@ -12,11 +12,9 @@ void main() {
|
|
|
12
12
|
|
|
13
13
|
#include <uv_vertex>
|
|
14
14
|
|
|
15
|
-
vec4 mvPosition = modelViewMatrix
|
|
15
|
+
vec4 mvPosition = modelViewMatrix[ 3 ];
|
|
16
16
|
|
|
17
|
-
vec2 scale;
|
|
18
|
-
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
|
19
|
-
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
|
17
|
+
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
|
|
20
18
|
|
|
21
19
|
#ifndef USE_SIZEATTENUATION
|
|
22
20
|
|
|
@@ -76,40 +76,71 @@ function WebGLAttributes( gl ) {
|
|
|
76
76
|
function updateBuffer( buffer, attribute, bufferType ) {
|
|
77
77
|
|
|
78
78
|
const array = attribute.array;
|
|
79
|
-
const updateRange = attribute._updateRange; // @deprecated, r159
|
|
80
79
|
const updateRanges = attribute.updateRanges;
|
|
81
80
|
|
|
82
81
|
gl.bindBuffer( bufferType, buffer );
|
|
83
82
|
|
|
84
|
-
if (
|
|
83
|
+
if ( updateRanges.length === 0 ) {
|
|
85
84
|
|
|
86
85
|
// Not using update ranges
|
|
87
86
|
gl.bufferSubData( bufferType, 0, array );
|
|
88
87
|
|
|
89
|
-
}
|
|
88
|
+
} else {
|
|
90
89
|
|
|
91
|
-
|
|
90
|
+
// Before applying update ranges, we merge any adjacent / overlapping
|
|
91
|
+
// ranges to reduce load on `gl.bufferSubData`. Empirically, this has led
|
|
92
|
+
// to performance improvements for applications which make heavy use of
|
|
93
|
+
// update ranges. Likely due to GPU command overhead.
|
|
94
|
+
//
|
|
95
|
+
// Note that to reduce garbage collection between frames, we merge the
|
|
96
|
+
// update ranges in-place. This is safe because this method will clear the
|
|
97
|
+
// update ranges once updated.
|
|
92
98
|
|
|
93
|
-
|
|
99
|
+
updateRanges.sort( ( a, b ) => a.start - b.start );
|
|
100
|
+
|
|
101
|
+
// To merge the update ranges in-place, we work from left to right in the
|
|
102
|
+
// existing updateRanges array, merging ranges. This may result in a final
|
|
103
|
+
// array which is smaller than the original. This index tracks the last
|
|
104
|
+
// index representing a merged range, any data after this index can be
|
|
105
|
+
// trimmed once the merge algorithm is completed.
|
|
106
|
+
let mergeIndex = 0;
|
|
107
|
+
|
|
108
|
+
for ( let i = 1; i < updateRanges.length; i ++ ) {
|
|
94
109
|
|
|
110
|
+
const previousRange = updateRanges[ mergeIndex ];
|
|
95
111
|
const range = updateRanges[ i ];
|
|
96
112
|
|
|
97
|
-
|
|
98
|
-
|
|
113
|
+
// We add one here to merge adjacent ranges. This is safe because ranges
|
|
114
|
+
// operate over positive integers.
|
|
115
|
+
if ( range.start <= previousRange.start + previousRange.count + 1 ) {
|
|
116
|
+
|
|
117
|
+
previousRange.count = Math.max(
|
|
118
|
+
previousRange.count,
|
|
119
|
+
range.start + range.count - previousRange.start
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
} else {
|
|
123
|
+
|
|
124
|
+
++ mergeIndex;
|
|
125
|
+
updateRanges[ mergeIndex ] = range;
|
|
126
|
+
|
|
127
|
+
}
|
|
99
128
|
|
|
100
129
|
}
|
|
101
130
|
|
|
102
|
-
|
|
131
|
+
// Trim the array to only contain the merged ranges.
|
|
132
|
+
updateRanges.length = mergeIndex + 1;
|
|
103
133
|
|
|
104
|
-
|
|
134
|
+
for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
|
|
135
|
+
|
|
136
|
+
const range = updateRanges[ i ];
|
|
105
137
|
|
|
106
|
-
|
|
107
|
-
|
|
138
|
+
gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
|
|
139
|
+
array, range.start, range.count );
|
|
108
140
|
|
|
109
|
-
|
|
110
|
-
array, updateRange.offset, updateRange.count );
|
|
141
|
+
}
|
|
111
142
|
|
|
112
|
-
|
|
143
|
+
attribute.clearUpdateRanges();
|
|
113
144
|
|
|
114
145
|
}
|
|
115
146
|
|
|
@@ -92,6 +92,14 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
|
|
95
|
+
const reverseDepthBuffer = parameters.reverseDepthBuffer === true && extensions.has( 'EXT_clip_control' );
|
|
96
|
+
|
|
97
|
+
if ( reverseDepthBuffer === true ) {
|
|
98
|
+
|
|
99
|
+
const ext = extensions.get( 'EXT_clip_control' );
|
|
100
|
+
ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.ZERO_TO_ONE_EXT );
|
|
101
|
+
|
|
102
|
+
}
|
|
95
103
|
|
|
96
104
|
const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
|
|
97
105
|
const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
|
|
@@ -119,6 +127,7 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
|
|
|
119
127
|
|
|
120
128
|
precision: precision,
|
|
121
129
|
logarithmicDepthBuffer: logarithmicDepthBuffer,
|
|
130
|
+
reverseDepthBuffer: reverseDepthBuffer,
|
|
122
131
|
|
|
123
132
|
maxTextures: maxTextures,
|
|
124
133
|
maxVertexTextures: maxVertexTextures,
|
|
@@ -659,6 +659,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
659
659
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
660
660
|
|
|
661
661
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
662
|
+
parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
|
|
662
663
|
|
|
663
664
|
'uniform mat4 modelMatrix;',
|
|
664
665
|
'uniform mat4 modelViewMatrix;',
|
|
@@ -824,6 +825,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
824
825
|
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
|
|
825
826
|
|
|
826
827
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
828
|
+
parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
|
|
827
829
|
|
|
828
830
|
'uniform mat4 viewMatrix;',
|
|
829
831
|
'uniform vec3 cameraPosition;',
|
|
@@ -14,6 +14,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
14
14
|
const programs = [];
|
|
15
15
|
|
|
16
16
|
const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
|
|
17
|
+
const reverseDepthBuffer = capabilities.reverseDepthBuffer;
|
|
17
18
|
const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
|
|
18
19
|
|
|
19
20
|
let precision = capabilities.precision;
|
|
@@ -308,6 +309,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
308
309
|
|
|
309
310
|
sizeAttenuation: material.sizeAttenuation === true,
|
|
310
311
|
logarithmicDepthBuffer: logarithmicDepthBuffer,
|
|
312
|
+
reverseDepthBuffer: reverseDepthBuffer,
|
|
311
313
|
|
|
312
314
|
skinning: object.isSkinnedMesh === true,
|
|
313
315
|
|
|
@@ -527,40 +529,42 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
527
529
|
_programLayers.enable( 2 );
|
|
528
530
|
if ( parameters.logarithmicDepthBuffer )
|
|
529
531
|
_programLayers.enable( 3 );
|
|
530
|
-
if ( parameters.
|
|
532
|
+
if ( parameters.reverseDepthBuffer )
|
|
531
533
|
_programLayers.enable( 4 );
|
|
532
|
-
if ( parameters.
|
|
534
|
+
if ( parameters.skinning )
|
|
533
535
|
_programLayers.enable( 5 );
|
|
534
|
-
if ( parameters.
|
|
536
|
+
if ( parameters.morphTargets )
|
|
535
537
|
_programLayers.enable( 6 );
|
|
536
|
-
if ( parameters.
|
|
538
|
+
if ( parameters.morphNormals )
|
|
537
539
|
_programLayers.enable( 7 );
|
|
538
|
-
if ( parameters.
|
|
540
|
+
if ( parameters.morphColors )
|
|
539
541
|
_programLayers.enable( 8 );
|
|
540
|
-
if ( parameters.
|
|
542
|
+
if ( parameters.premultipliedAlpha )
|
|
541
543
|
_programLayers.enable( 9 );
|
|
542
|
-
if ( parameters.
|
|
544
|
+
if ( parameters.shadowMapEnabled )
|
|
543
545
|
_programLayers.enable( 10 );
|
|
544
|
-
if ( parameters.
|
|
546
|
+
if ( parameters.doubleSided )
|
|
545
547
|
_programLayers.enable( 11 );
|
|
546
|
-
if ( parameters.
|
|
548
|
+
if ( parameters.flipSided )
|
|
547
549
|
_programLayers.enable( 12 );
|
|
548
|
-
if ( parameters.
|
|
550
|
+
if ( parameters.useDepthPacking )
|
|
549
551
|
_programLayers.enable( 13 );
|
|
550
|
-
if ( parameters.
|
|
552
|
+
if ( parameters.dithering )
|
|
551
553
|
_programLayers.enable( 14 );
|
|
552
|
-
if ( parameters.
|
|
554
|
+
if ( parameters.transmission )
|
|
553
555
|
_programLayers.enable( 15 );
|
|
554
|
-
if ( parameters.
|
|
556
|
+
if ( parameters.sheen )
|
|
555
557
|
_programLayers.enable( 16 );
|
|
556
|
-
if ( parameters.
|
|
558
|
+
if ( parameters.opaque )
|
|
557
559
|
_programLayers.enable( 17 );
|
|
558
|
-
if ( parameters.
|
|
560
|
+
if ( parameters.pointsUvs )
|
|
559
561
|
_programLayers.enable( 18 );
|
|
560
|
-
if ( parameters.
|
|
562
|
+
if ( parameters.decodeVideoTexture )
|
|
561
563
|
_programLayers.enable( 19 );
|
|
562
|
-
if ( parameters.
|
|
564
|
+
if ( parameters.alphaToCoverage )
|
|
563
565
|
_programLayers.enable( 20 );
|
|
566
|
+
if ( parameters.numMultiviewViews )
|
|
567
|
+
_programLayers.enable( 21 );
|
|
564
568
|
|
|
565
569
|
array.push( _programLayers.mask );
|
|
566
570
|
|
|
@@ -2,6 +2,18 @@ import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDe
|
|
|
2
2
|
import { Color } from '../../math/Color.js';
|
|
3
3
|
import { Vector4 } from '../../math/Vector4.js';
|
|
4
4
|
|
|
5
|
+
const reversedFuncs = {
|
|
6
|
+
[ NeverDepth ]: AlwaysDepth,
|
|
7
|
+
[ LessDepth ]: GreaterDepth,
|
|
8
|
+
[ EqualDepth ]: NotEqualDepth,
|
|
9
|
+
[ LessEqualDepth ]: GreaterEqualDepth,
|
|
10
|
+
|
|
11
|
+
[ AlwaysDepth ]: NeverDepth,
|
|
12
|
+
[ GreaterDepth ]: LessDepth,
|
|
13
|
+
[ NotEqualDepth ]: EqualDepth,
|
|
14
|
+
[ GreaterEqualDepth ]: LessEqualDepth,
|
|
15
|
+
};
|
|
16
|
+
|
|
5
17
|
function WebGLState( gl ) {
|
|
6
18
|
|
|
7
19
|
function ColorBuffer() {
|
|
@@ -66,6 +78,7 @@ function WebGLState( gl ) {
|
|
|
66
78
|
function DepthBuffer() {
|
|
67
79
|
|
|
68
80
|
let locked = false;
|
|
81
|
+
let reversed = false;
|
|
69
82
|
|
|
70
83
|
let currentDepthMask = null;
|
|
71
84
|
let currentDepthFunc = null;
|
|
@@ -73,6 +86,12 @@ function WebGLState( gl ) {
|
|
|
73
86
|
|
|
74
87
|
return {
|
|
75
88
|
|
|
89
|
+
setReversed: function ( value ) {
|
|
90
|
+
|
|
91
|
+
reversed = value;
|
|
92
|
+
|
|
93
|
+
},
|
|
94
|
+
|
|
76
95
|
setTest: function ( depthTest ) {
|
|
77
96
|
|
|
78
97
|
if ( depthTest ) {
|
|
@@ -100,6 +119,8 @@ function WebGLState( gl ) {
|
|
|
100
119
|
|
|
101
120
|
setFunc: function ( depthFunc ) {
|
|
102
121
|
|
|
122
|
+
if ( reversed ) depthFunc = reversedFuncs[ depthFunc ];
|
|
123
|
+
|
|
103
124
|
if ( currentDepthFunc !== depthFunc ) {
|
|
104
125
|
|
|
105
126
|
switch ( depthFunc ) {
|
|
@@ -171,6 +171,28 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
171
171
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
if ( glFormat === _gl.RGB_INTEGER ) {
|
|
175
|
+
|
|
176
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGB8UI;
|
|
177
|
+
if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RGB16UI;
|
|
178
|
+
if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RGB32UI;
|
|
179
|
+
if ( glType === _gl.BYTE ) internalFormat = _gl.RGB8I;
|
|
180
|
+
if ( glType === _gl.SHORT ) internalFormat = _gl.RGB16I;
|
|
181
|
+
if ( glType === _gl.INT ) internalFormat = _gl.RGB32I;
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if ( glFormat === _gl.RGBA_INTEGER ) {
|
|
186
|
+
|
|
187
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8UI;
|
|
188
|
+
if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RGBA16UI;
|
|
189
|
+
if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RGBA32UI;
|
|
190
|
+
if ( glType === _gl.BYTE ) internalFormat = _gl.RGBA8I;
|
|
191
|
+
if ( glType === _gl.SHORT ) internalFormat = _gl.RGBA16I;
|
|
192
|
+
if ( glType === _gl.INT ) internalFormat = _gl.RGBA32I;
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
174
196
|
if ( glFormat === _gl.RGB ) {
|
|
175
197
|
|
|
176
198
|
if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
|
|
@@ -62,6 +62,7 @@ class WebGLBackend extends Backend {
|
|
|
62
62
|
|
|
63
63
|
this.disjoint = this.extensions.get( 'EXT_disjoint_timer_query_webgl2' );
|
|
64
64
|
this.parallel = this.extensions.get( 'KHR_parallel_shader_compile' );
|
|
65
|
+
|
|
65
66
|
this._currentContext = null;
|
|
66
67
|
|
|
67
68
|
}
|
|
@@ -597,6 +598,10 @@ class WebGLBackend extends Backend {
|
|
|
597
598
|
|
|
598
599
|
const contextData = this.get( context );
|
|
599
600
|
|
|
601
|
+
const drawParms = renderObject.getDrawParameters();
|
|
602
|
+
|
|
603
|
+
if ( drawParms === null ) return;
|
|
604
|
+
|
|
600
605
|
//
|
|
601
606
|
|
|
602
607
|
this._bindUniforms( renderObject.getBindings() );
|
|
@@ -635,10 +640,6 @@ class WebGLBackend extends Backend {
|
|
|
635
640
|
|
|
636
641
|
const index = renderObject.getIndex();
|
|
637
642
|
|
|
638
|
-
const geometry = renderObject.geometry;
|
|
639
|
-
const drawRange = renderObject.drawRange;
|
|
640
|
-
const firstVertex = drawRange.start;
|
|
641
|
-
|
|
642
643
|
//
|
|
643
644
|
|
|
644
645
|
const lastObject = contextData.lastOcclusionObject;
|
|
@@ -669,7 +670,6 @@ class WebGLBackend extends Backend {
|
|
|
669
670
|
}
|
|
670
671
|
|
|
671
672
|
//
|
|
672
|
-
|
|
673
673
|
const renderer = this.bufferRenderer;
|
|
674
674
|
|
|
675
675
|
if ( object.isPoints ) renderer.mode = gl.POINTS;
|
|
@@ -693,33 +693,26 @@ class WebGLBackend extends Backend {
|
|
|
693
693
|
|
|
694
694
|
//
|
|
695
695
|
|
|
696
|
-
|
|
697
|
-
let
|
|
696
|
+
const { vertexCount, instanceCount } = drawParms;
|
|
697
|
+
let { firstVertex } = drawParms;
|
|
698
698
|
|
|
699
699
|
renderer.object = object;
|
|
700
700
|
|
|
701
701
|
if ( index !== null ) {
|
|
702
702
|
|
|
703
|
+
firstVertex *= index.array.BYTES_PER_ELEMENT;
|
|
704
|
+
|
|
703
705
|
const indexData = this.get( index );
|
|
704
|
-
const indexCount = ( drawRange.count !== Infinity ) ? drawRange.count : index.count;
|
|
705
706
|
|
|
706
707
|
renderer.index = index.count;
|
|
707
708
|
renderer.type = indexData.type;
|
|
708
709
|
|
|
709
|
-
count = indexCount;
|
|
710
|
-
|
|
711
710
|
} else {
|
|
712
711
|
|
|
713
712
|
renderer.index = 0;
|
|
714
713
|
|
|
715
|
-
const vertexCount = ( drawRange.count !== Infinity ) ? drawRange.count : geometry.attributes.position.count;
|
|
716
|
-
|
|
717
|
-
count = vertexCount;
|
|
718
|
-
|
|
719
714
|
}
|
|
720
715
|
|
|
721
|
-
const instanceCount = this.getInstanceCount( renderObject );
|
|
722
|
-
|
|
723
716
|
if ( object.isBatchedMesh ) {
|
|
724
717
|
|
|
725
718
|
if ( object._multiDrawInstances !== null ) {
|
|
@@ -738,11 +731,11 @@ class WebGLBackend extends Backend {
|
|
|
738
731
|
|
|
739
732
|
} else if ( instanceCount > 1 ) {
|
|
740
733
|
|
|
741
|
-
renderer.renderInstances( firstVertex,
|
|
734
|
+
renderer.renderInstances( firstVertex, vertexCount, instanceCount );
|
|
742
735
|
|
|
743
736
|
} else {
|
|
744
737
|
|
|
745
|
-
renderer.render( firstVertex,
|
|
738
|
+
renderer.render( firstVertex, vertexCount );
|
|
746
739
|
|
|
747
740
|
}
|
|
748
741
|
//
|
|
@@ -796,9 +789,9 @@ class WebGLBackend extends Backend {
|
|
|
796
789
|
|
|
797
790
|
}
|
|
798
791
|
|
|
799
|
-
copyTextureToBuffer( texture, x, y, width, height ) {
|
|
792
|
+
copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
|
|
800
793
|
|
|
801
|
-
return this.textureUtils.copyTextureToBuffer( texture, x, y, width, height );
|
|
794
|
+
return this.textureUtils.copyTextureToBuffer( texture, x, y, width, height, faceIndex );
|
|
802
795
|
|
|
803
796
|
}
|
|
804
797
|
|
|
@@ -1114,40 +1107,52 @@ class WebGLBackend extends Backend {
|
|
|
1114
1107
|
|
|
1115
1108
|
updateBindings( bindGroup, bindings ) {
|
|
1116
1109
|
|
|
1117
|
-
|
|
1110
|
+
if ( ! bindGroup ) return;
|
|
1111
|
+
|
|
1112
|
+
const { gl } = this;
|
|
1118
1113
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1114
|
+
const bindingsData = this.get( bindings );
|
|
1115
|
+
const bindGroupData = this.get( bindGroup );
|
|
1121
1116
|
|
|
1122
|
-
|
|
1117
|
+
if ( bindingsData.textureIndex === undefined ) bindingsData.textureIndex = 0;
|
|
1123
1118
|
|
|
1124
|
-
|
|
1119
|
+
if ( bindGroupData.textureIndex === undefined ) {
|
|
1125
1120
|
|
|
1126
|
-
|
|
1121
|
+
bindGroupData.textureIndex = bindingsData.textureIndex;
|
|
1127
1122
|
|
|
1128
|
-
|
|
1129
|
-
const data = binding.buffer;
|
|
1123
|
+
} else {
|
|
1130
1124
|
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
state.bindBufferBase( gl.UNIFORM_BUFFER, groupIndex, bufferGPU );
|
|
1125
|
+
// reset textureIndex to match previous mappimgs when rebuilt
|
|
1126
|
+
bindingsData.textureIndex = bindGroupData.textureIndex;
|
|
1134
1127
|
|
|
1135
|
-
|
|
1136
|
-
index: groupIndex ++,
|
|
1137
|
-
bufferGPU
|
|
1138
|
-
} );
|
|
1128
|
+
}
|
|
1139
1129
|
|
|
1140
|
-
|
|
1130
|
+
let i = 0;
|
|
1141
1131
|
|
|
1142
|
-
|
|
1132
|
+
for ( const binding of bindGroup.bindings ) {
|
|
1143
1133
|
|
|
1144
|
-
|
|
1145
|
-
index: textureIndex ++,
|
|
1146
|
-
textureGPU,
|
|
1147
|
-
glTextureType
|
|
1148
|
-
} );
|
|
1134
|
+
if ( binding.isUniformsGroup || binding.isUniformBuffer ) {
|
|
1149
1135
|
|
|
1150
|
-
|
|
1136
|
+
const data = binding.buffer;
|
|
1137
|
+
const bufferGPU = gl.createBuffer();
|
|
1138
|
+
|
|
1139
|
+
gl.bindBuffer( gl.UNIFORM_BUFFER, bufferGPU );
|
|
1140
|
+
gl.bufferData( gl.UNIFORM_BUFFER, data, gl.DYNAMIC_DRAW );
|
|
1141
|
+
|
|
1142
|
+
this.set( binding, {
|
|
1143
|
+
index: bindGroup.index * 2 + i ++,
|
|
1144
|
+
bufferGPU
|
|
1145
|
+
} );
|
|
1146
|
+
|
|
1147
|
+
} else if ( binding.isSampledTexture ) {
|
|
1148
|
+
|
|
1149
|
+
const { textureGPU, glTextureType } = this.get( binding.texture );
|
|
1150
|
+
|
|
1151
|
+
this.set( binding, {
|
|
1152
|
+
index: bindingsData.textureIndex ++,
|
|
1153
|
+
textureGPU,
|
|
1154
|
+
glTextureType
|
|
1155
|
+
} );
|
|
1151
1156
|
|
|
1152
1157
|
}
|
|
1153
1158
|
|
|
@@ -1248,9 +1253,9 @@ class WebGLBackend extends Backend {
|
|
|
1248
1253
|
|
|
1249
1254
|
}
|
|
1250
1255
|
|
|
1251
|
-
copyFramebufferToTexture( texture, renderContext ) {
|
|
1256
|
+
copyFramebufferToTexture( texture, renderContext, rectangle ) {
|
|
1252
1257
|
|
|
1253
|
-
this.textureUtils.copyFramebufferToTexture( texture, renderContext );
|
|
1258
|
+
this.textureUtils.copyFramebufferToTexture( texture, renderContext, rectangle );
|
|
1254
1259
|
|
|
1255
1260
|
}
|
|
1256
1261
|
|
|
@@ -56,8 +56,6 @@ class GLSLNodeBuilder extends NodeBuilder {
|
|
|
56
56
|
this.transforms = [];
|
|
57
57
|
this.extensions = {};
|
|
58
58
|
|
|
59
|
-
this.instanceBindGroups = false;
|
|
60
|
-
|
|
61
59
|
this.useComparisonMethod = true;
|
|
62
60
|
|
|
63
61
|
}
|
|
@@ -234,7 +232,7 @@ ${ flowData.code }
|
|
|
234
232
|
|
|
235
233
|
this.getVarFromNode( node, propertySizeName, 'uint' );
|
|
236
234
|
|
|
237
|
-
this.addLineFlowCode( `${ propertySizeName } = uint( textureSize( ${ textureName }, 0 ).x )
|
|
235
|
+
this.addLineFlowCode( `${ propertySizeName } = uint( textureSize( ${ textureName }, 0 ).x )`, storageArrayElementNode );
|
|
238
236
|
|
|
239
237
|
bufferNodeData.propertySizeName = propertySizeName;
|
|
240
238
|
|
|
@@ -264,7 +262,7 @@ ${ flowData.code }
|
|
|
264
262
|
|
|
265
263
|
}
|
|
266
264
|
|
|
267
|
-
this.addLineFlowCode( `${ propertyName } = ${prefix}(${ snippet })${channel}
|
|
265
|
+
this.addLineFlowCode( `${ propertyName } = ${prefix}(${ snippet })${channel}`, storageArrayElementNode );
|
|
268
266
|
|
|
269
267
|
elementNodeData.propertyName = propertyName;
|
|
270
268
|
|
|
@@ -854,6 +852,8 @@ void main() {
|
|
|
854
852
|
|
|
855
853
|
const shadersData = this.material !== null ? { fragment: {}, vertex: {} } : { compute: {} };
|
|
856
854
|
|
|
855
|
+
this.sortBindingGroups();
|
|
856
|
+
|
|
857
857
|
for ( const shaderStage in shadersData ) {
|
|
858
858
|
|
|
859
859
|
let flow = '// code\n\n';
|
|
@@ -233,10 +233,16 @@ class WebGLAttributeUtils {
|
|
|
233
233
|
|
|
234
234
|
const dstBuffer = new attribute.array.constructor( array.length );
|
|
235
235
|
|
|
236
|
+
// Ensure the buffer is bound before reading
|
|
237
|
+
gl.bindBuffer( gl.COPY_WRITE_BUFFER, writeBuffer );
|
|
238
|
+
|
|
236
239
|
gl.getBufferSubData( gl.COPY_WRITE_BUFFER, 0, dstBuffer );
|
|
237
240
|
|
|
238
241
|
gl.deleteBuffer( writeBuffer );
|
|
239
242
|
|
|
243
|
+
gl.bindBuffer( gl.COPY_READ_BUFFER, null );
|
|
244
|
+
gl.bindBuffer( gl.COPY_WRITE_BUFFER, null );
|
|
245
|
+
|
|
240
246
|
return dstBuffer.buffer;
|
|
241
247
|
|
|
242
248
|
}
|
|
@@ -512,7 +512,7 @@ class WebGLState {
|
|
|
512
512
|
|
|
513
513
|
this.setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );
|
|
514
514
|
|
|
515
|
-
material.alphaToCoverage === true
|
|
515
|
+
material.alphaToCoverage === true && this.backend.renderer.samples > 1
|
|
516
516
|
? this.enable( gl.SAMPLE_ALPHA_TO_COVERAGE )
|
|
517
517
|
: this.disable( gl.SAMPLE_ALPHA_TO_COVERAGE );
|
|
518
518
|
|
|
@@ -649,7 +649,6 @@ class WebGLState {
|
|
|
649
649
|
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
-
|
|
653
652
|
}
|
|
654
653
|
|
|
655
654
|
|
|
@@ -711,10 +710,8 @@ class WebGLState {
|
|
|
711
710
|
boundTexture.type = webglType;
|
|
712
711
|
boundTexture.texture = webglTexture;
|
|
713
712
|
|
|
714
|
-
|
|
715
713
|
}
|
|
716
714
|
|
|
717
|
-
|
|
718
715
|
}
|
|
719
716
|
|
|
720
717
|
bindBufferBase( target, index, buffer ) {
|