super-three 0.167.0 → 0.168.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 +165 -44
- package/build/three.module.js +165 -45
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +23600 -21931
- package/build/three.webgpu.min.js +1 -1
- package/examples/jsm/Addons.js +3 -1
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +453 -452
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +11 -4
- package/examples/jsm/loaders/PCDLoader.js +9 -9
- package/examples/jsm/objects/SkyMesh.js +188 -0
- package/examples/jsm/objects/Water2Mesh.js +159 -0
- package/examples/jsm/objects/WaterMesh.js +102 -0
- package/examples/jsm/physics/RapierPhysics.js +20 -0
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +2 -1
- package/src/Three.WebGPU.js +6 -0
- package/src/Three.js +1 -0
- package/src/constants.js +1 -1
- package/src/extras/Controls.js +32 -0
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
- package/src/materials/Material.js +4 -7
- package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +176 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +48 -20
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +5 -5
- package/src/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
- package/src/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +5 -7
- package/src/nodes/accessors/InstanceNode.js +17 -13
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
- package/src/nodes/accessors/MaterialNode.js +52 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +11 -11
- package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/src/nodes/accessors/MorphNode.js +12 -12
- package/src/nodes/accessors/Normal.js +62 -0
- package/src/nodes/accessors/Object3DNode.js +10 -10
- package/src/nodes/accessors/PointUVNode.js +4 -4
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/src/nodes/accessors/ReferenceNode.js +13 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +6 -6
- package/src/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +84 -21
- package/src/nodes/accessors/StorageBufferNode.js +4 -5
- package/src/nodes/accessors/StorageTextureNode.js +5 -5
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +11 -11
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +16 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -6
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
- package/src/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/src/nodes/accessors/VertexColorNode.js +4 -4
- package/src/nodes/code/CodeNode.js +5 -5
- package/src/nodes/code/ExpressionNode.js +4 -4
- package/src/nodes/code/FunctionCallNode.js +5 -5
- package/src/nodes/code/FunctionNode.js +5 -23
- package/src/nodes/code/ScriptableNode.js +4 -6
- package/src/nodes/code/ScriptableValueNode.js +4 -6
- package/src/nodes/core/AssignNode.js +5 -5
- package/src/nodes/core/AttributeNode.js +7 -20
- package/src/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +5 -5
- package/src/nodes/core/ConstNode.js +2 -2
- package/src/nodes/core/ContextNode.js +17 -11
- package/src/nodes/core/IndexNode.js +12 -7
- package/src/nodes/core/InputNode.js +2 -2
- package/src/nodes/core/MRTNode.js +12 -6
- package/src/nodes/core/Node.js +39 -19
- package/src/nodes/core/NodeBuilder.js +46 -33
- package/src/nodes/core/NodeUtils.js +1 -0
- package/src/nodes/core/OutputStructNode.js +4 -4
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +32 -32
- package/src/nodes/core/StackNode.js +26 -10
- package/src/nodes/core/StructTypeNode.js +2 -2
- package/src/nodes/core/TempNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +8 -9
- package/src/nodes/core/UniformNode.js +4 -4
- package/src/nodes/core/VarNode.js +6 -6
- package/src/nodes/core/VaryingNode.js +5 -5
- package/src/nodes/display/AfterImageNode.js +9 -9
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/src/nodes/display/AnamorphicNode.js +11 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +21 -19
- package/src/nodes/display/BumpMapNode.js +7 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +40 -63
- package/src/nodes/display/DenoiseNode.js +20 -17
- package/src/nodes/display/DepthOfFieldNode.js +8 -6
- package/src/nodes/display/DotScreenNode.js +10 -22
- package/src/nodes/display/FXAANode.js +17 -15
- package/src/nodes/display/FilmNode.js +7 -6
- package/src/nodes/display/FrontFacingNode.js +5 -5
- package/src/nodes/display/GTAONode.js +19 -15
- package/src/nodes/display/GaussianBlurNode.js +11 -8
- package/src/nodes/display/Lut3DNode.js +6 -5
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +8 -10
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +84 -8
- package/src/nodes/display/PixelationPassNode.js +12 -7
- package/src/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +8 -7
- package/src/nodes/display/RenderOutputNode.js +9 -9
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +9 -7
- package/src/nodes/display/StereoCompositePassNode.js +107 -0
- package/src/nodes/display/StereoPassNode.js +80 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +12 -173
- package/src/nodes/display/TransitionNode.js +9 -8
- package/src/nodes/display/ViewportDepthNode.js +30 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
- package/src/nodes/display/ViewportNode.js +26 -25
- package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
- package/src/nodes/display/ViewportTextureNode.js +7 -10
- package/src/nodes/fog/FogExp2Node.js +4 -6
- package/src/nodes/fog/FogNode.js +5 -7
- package/src/nodes/fog/FogRangeNode.js +4 -6
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +32 -31
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/geometry/RangeNode.js +4 -4
- package/src/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +2 -2
- package/src/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +34 -13
- package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
- package/src/nodes/lighting/BasicLightMapNode.js +3 -3
- package/src/nodes/lighting/DirectionalLightNode.js +2 -7
- package/src/nodes/lighting/EnvironmentNode.js +20 -19
- package/src/nodes/lighting/HemisphereLightNode.js +3 -7
- package/src/nodes/lighting/IESSpotLightNode.js +3 -8
- package/src/nodes/lighting/IrradianceNode.js +2 -2
- package/src/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +15 -17
- package/src/nodes/lighting/LightingNode.js +2 -2
- package/src/nodes/lighting/LightsNode.js +94 -76
- package/src/nodes/lighting/PointLightNode.js +3 -8
- package/src/nodes/lighting/RectAreaLightNode.js +2 -6
- package/src/nodes/lighting/SpotLightNode.js +3 -8
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +18 -7
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +124 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +94 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +58 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +2 -2
- package/src/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +12 -6
- package/src/nodes/utils/MatcapUVNode.js +6 -6
- package/src/nodes/utils/MaxMipLevelNode.js +4 -4
- package/src/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +8 -8
- package/src/nodes/utils/ReflectorNode.js +8 -3
- package/src/nodes/utils/RemapNode.js +7 -7
- package/src/nodes/utils/RotateNode.js +4 -12
- package/src/nodes/utils/SetNode.js +2 -2
- package/src/nodes/utils/SplitNode.js +2 -2
- package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +4 -6
- package/src/nodes/utils/TimerNode.js +5 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +2 -3
- package/src/renderers/WebGLRenderer.js +24 -0
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/ClippingContext.js +14 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +24 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/Renderer.js +75 -49
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/StandardRenderer.js +18 -0
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +12 -13
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +36 -9
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +61 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
- package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
- package/src/renderers/webgpu/WebGPUBackend.js +86 -68
- package/src/renderers/webgpu/WebGPURenderer.js +8 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +6 -15
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import GLSLNodeBuilder from './nodes/GLSLNodeBuilder.js';
|
|
2
2
|
import Backend from '../common/Backend.js';
|
|
3
|
+
import { getCacheKey } from '../common/RenderContext.js';
|
|
3
4
|
|
|
4
5
|
import WebGLAttributeUtils from './utils/WebGLAttributeUtils.js';
|
|
5
6
|
import WebGLState from './utils/WebGLState.js';
|
|
@@ -52,6 +53,11 @@ class WebGLBackend extends Backend {
|
|
|
52
53
|
this.trackTimestamp = ( parameters.trackTimestamp === true );
|
|
53
54
|
|
|
54
55
|
this.extensions.get( 'EXT_color_buffer_float' );
|
|
56
|
+
this.extensions.get( 'WEBGL_clip_cull_distance' );
|
|
57
|
+
this.extensions.get( 'OES_texture_float_linear' );
|
|
58
|
+
this.extensions.get( 'EXT_color_buffer_half_float' );
|
|
59
|
+
this.extensions.get( 'WEBGL_multisampled_render_to_texture' );
|
|
60
|
+
this.extensions.get( 'WEBGL_render_shared_exponent' );
|
|
55
61
|
this.extensions.get( 'WEBGL_multi_draw' );
|
|
56
62
|
|
|
57
63
|
this.disjoint = this.extensions.get( 'EXT_disjoint_timer_query_webgl2' );
|
|
@@ -201,7 +207,7 @@ class WebGLBackend extends Backend {
|
|
|
201
207
|
|
|
202
208
|
const { x, y, width, height } = renderContext.scissorValue;
|
|
203
209
|
|
|
204
|
-
gl.scissor( x, y, width, height );
|
|
210
|
+
gl.scissor( x, renderContext.height - height - y, width, height );
|
|
205
211
|
|
|
206
212
|
}
|
|
207
213
|
|
|
@@ -229,6 +235,20 @@ class WebGLBackend extends Backend {
|
|
|
229
235
|
const renderContextData = this.get( renderContext );
|
|
230
236
|
const previousContext = renderContextData.previousContext;
|
|
231
237
|
|
|
238
|
+
const occlusionQueryCount = renderContext.occlusionQueryCount;
|
|
239
|
+
|
|
240
|
+
if ( occlusionQueryCount > 0 ) {
|
|
241
|
+
|
|
242
|
+
if ( occlusionQueryCount > renderContextData.occlusionQueryIndex ) {
|
|
243
|
+
|
|
244
|
+
gl.endQuery( gl.ANY_SAMPLES_PASSED );
|
|
245
|
+
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
this.resolveOccludedAsync( renderContext );
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
|
|
232
252
|
const textures = renderContext.textures;
|
|
233
253
|
|
|
234
254
|
if ( textures !== null ) {
|
|
@@ -249,18 +269,18 @@ class WebGLBackend extends Backend {
|
|
|
249
269
|
|
|
250
270
|
this._currentContext = previousContext;
|
|
251
271
|
|
|
252
|
-
|
|
253
272
|
if ( renderContext.textures !== null && renderContext.renderTarget ) {
|
|
254
273
|
|
|
255
274
|
const renderTargetContextData = this.get( renderContext.renderTarget );
|
|
256
275
|
|
|
257
276
|
const { samples } = renderContext.renderTarget;
|
|
258
|
-
const fb = renderTargetContextData.framebuffer;
|
|
259
|
-
|
|
260
|
-
const mask = gl.COLOR_BUFFER_BIT;
|
|
261
277
|
|
|
262
278
|
if ( samples > 0 ) {
|
|
263
279
|
|
|
280
|
+
const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ];
|
|
281
|
+
|
|
282
|
+
const mask = gl.COLOR_BUFFER_BIT;
|
|
283
|
+
|
|
264
284
|
const msaaFrameBuffer = renderTargetContextData.msaaFrameBuffer;
|
|
265
285
|
|
|
266
286
|
const textures = renderContext.textures;
|
|
@@ -272,9 +292,21 @@ class WebGLBackend extends Backend {
|
|
|
272
292
|
|
|
273
293
|
// TODO Add support for MRT
|
|
274
294
|
|
|
275
|
-
|
|
295
|
+
if ( renderContext.scissor ) {
|
|
296
|
+
|
|
297
|
+
const { x, y, width, height } = renderContext.scissorValue;
|
|
298
|
+
|
|
299
|
+
const viewY = renderContext.height - height - y;
|
|
300
|
+
|
|
301
|
+
gl.blitFramebuffer( x, viewY, x + width, viewY + height, x, viewY, x + width, viewY + height, mask, gl.NEAREST );
|
|
302
|
+
gl.invalidateSubFramebuffer( gl.READ_FRAMEBUFFER, renderTargetContextData.invalidationArray, x, viewY, width, height );
|
|
303
|
+
|
|
304
|
+
} else {
|
|
305
|
+
|
|
306
|
+
gl.blitFramebuffer( 0, 0, renderContext.width, renderContext.height, 0, 0, renderContext.width, renderContext.height, mask, gl.NEAREST );
|
|
307
|
+
gl.invalidateFramebuffer( gl.READ_FRAMEBUFFER, renderTargetContextData.invalidationArray );
|
|
276
308
|
|
|
277
|
-
|
|
309
|
+
}
|
|
278
310
|
|
|
279
311
|
}
|
|
280
312
|
|
|
@@ -293,32 +325,12 @@ class WebGLBackend extends Backend {
|
|
|
293
325
|
|
|
294
326
|
} else {
|
|
295
327
|
|
|
296
|
-
const gl = this.gl;
|
|
297
|
-
|
|
298
328
|
gl.viewport( 0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight );
|
|
299
329
|
|
|
300
330
|
}
|
|
301
331
|
|
|
302
332
|
}
|
|
303
333
|
|
|
304
|
-
const occlusionQueryCount = renderContext.occlusionQueryCount;
|
|
305
|
-
|
|
306
|
-
if ( occlusionQueryCount > 0 ) {
|
|
307
|
-
|
|
308
|
-
const renderContextData = this.get( renderContext );
|
|
309
|
-
|
|
310
|
-
if ( occlusionQueryCount > renderContextData.occlusionQueryIndex ) {
|
|
311
|
-
|
|
312
|
-
const { gl } = this;
|
|
313
|
-
|
|
314
|
-
gl.endQuery( gl.ANY_SAMPLES_PASSED );
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
this.resolveOccludedAsync( renderContext );
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
|
|
322
334
|
this.prepareTimestampBuffer( renderContext );
|
|
323
335
|
|
|
324
336
|
}
|
|
@@ -394,7 +406,7 @@ class WebGLBackend extends Backend {
|
|
|
394
406
|
const gl = this.gl;
|
|
395
407
|
const { x, y, width, height } = renderContext.viewportValue;
|
|
396
408
|
|
|
397
|
-
gl.viewport( x, y, width, height );
|
|
409
|
+
gl.viewport( x, renderContext.height - height - y, width, height );
|
|
398
410
|
|
|
399
411
|
}
|
|
400
412
|
|
|
@@ -439,6 +451,12 @@ class WebGLBackend extends Backend {
|
|
|
439
451
|
|
|
440
452
|
const clearColor = descriptor.clearColorValue || this.getClearColor();
|
|
441
453
|
|
|
454
|
+
// premultiply alpha
|
|
455
|
+
|
|
456
|
+
clearColor.r *= clearColor.a;
|
|
457
|
+
clearColor.g *= clearColor.a;
|
|
458
|
+
clearColor.b *= clearColor.a;
|
|
459
|
+
|
|
442
460
|
if ( depth ) this.state.setDepthMask( true );
|
|
443
461
|
|
|
444
462
|
if ( descriptor.textures === null ) {
|
|
@@ -482,16 +500,16 @@ class WebGLBackend extends Backend {
|
|
|
482
500
|
|
|
483
501
|
beginCompute( computeGroup ) {
|
|
484
502
|
|
|
485
|
-
const gl = this
|
|
503
|
+
const { state, gl } = this;
|
|
486
504
|
|
|
487
|
-
|
|
505
|
+
state.bindFramebuffer( gl.FRAMEBUFFER, null );
|
|
488
506
|
this.initTimestampQuery( computeGroup );
|
|
489
507
|
|
|
490
508
|
}
|
|
491
509
|
|
|
492
510
|
compute( computeGroup, computeNode, bindings, pipeline ) {
|
|
493
511
|
|
|
494
|
-
const gl = this
|
|
512
|
+
const { state, gl } = this;
|
|
495
513
|
|
|
496
514
|
if ( ! this.discard ) {
|
|
497
515
|
|
|
@@ -517,7 +535,7 @@ class WebGLBackend extends Backend {
|
|
|
517
535
|
|
|
518
536
|
}
|
|
519
537
|
|
|
520
|
-
|
|
538
|
+
state.useProgram( programGPU );
|
|
521
539
|
|
|
522
540
|
this._bindUniforms( bindings );
|
|
523
541
|
|
|
@@ -587,7 +605,7 @@ class WebGLBackend extends Backend {
|
|
|
587
605
|
|
|
588
606
|
state.setMaterial( material, frontFaceCW );
|
|
589
607
|
|
|
590
|
-
|
|
608
|
+
state.useProgram( programGPU );
|
|
591
609
|
|
|
592
610
|
//
|
|
593
611
|
|
|
@@ -739,9 +757,9 @@ class WebGLBackend extends Backend {
|
|
|
739
757
|
|
|
740
758
|
}
|
|
741
759
|
|
|
742
|
-
getRenderCacheKey( renderObject ) {
|
|
760
|
+
getRenderCacheKey( /*renderObject*/ ) {
|
|
743
761
|
|
|
744
|
-
return
|
|
762
|
+
return '';
|
|
745
763
|
|
|
746
764
|
}
|
|
747
765
|
|
|
@@ -966,7 +984,7 @@ class WebGLBackend extends Backend {
|
|
|
966
984
|
|
|
967
985
|
_completeCompile( renderObject, pipeline ) {
|
|
968
986
|
|
|
969
|
-
const gl = this
|
|
987
|
+
const { state, gl } = this;
|
|
970
988
|
const pipelineData = this.get( pipeline );
|
|
971
989
|
const { programGPU, fragmentShader, vertexShader } = pipelineData;
|
|
972
990
|
|
|
@@ -976,7 +994,7 @@ class WebGLBackend extends Backend {
|
|
|
976
994
|
|
|
977
995
|
}
|
|
978
996
|
|
|
979
|
-
|
|
997
|
+
state.useProgram( programGPU );
|
|
980
998
|
|
|
981
999
|
// Bindings
|
|
982
1000
|
|
|
@@ -994,7 +1012,7 @@ class WebGLBackend extends Backend {
|
|
|
994
1012
|
|
|
995
1013
|
createComputePipeline( computePipeline, bindings ) {
|
|
996
1014
|
|
|
997
|
-
const gl = this
|
|
1015
|
+
const { state, gl } = this;
|
|
998
1016
|
|
|
999
1017
|
// Program
|
|
1000
1018
|
|
|
@@ -1044,7 +1062,7 @@ class WebGLBackend extends Backend {
|
|
|
1044
1062
|
|
|
1045
1063
|
}
|
|
1046
1064
|
|
|
1047
|
-
|
|
1065
|
+
state.useProgram( programGPU );
|
|
1048
1066
|
|
|
1049
1067
|
// Bindings
|
|
1050
1068
|
|
|
@@ -1096,7 +1114,7 @@ class WebGLBackend extends Backend {
|
|
|
1096
1114
|
|
|
1097
1115
|
updateBindings( bindGroup, bindings ) {
|
|
1098
1116
|
|
|
1099
|
-
const { gl } = this;
|
|
1117
|
+
const { state, gl } = this;
|
|
1100
1118
|
|
|
1101
1119
|
let groupIndex = 0;
|
|
1102
1120
|
let textureIndex = 0;
|
|
@@ -1112,7 +1130,7 @@ class WebGLBackend extends Backend {
|
|
|
1112
1130
|
|
|
1113
1131
|
gl.bindBuffer( gl.UNIFORM_BUFFER, bufferGPU );
|
|
1114
1132
|
gl.bufferData( gl.UNIFORM_BUFFER, data, gl.DYNAMIC_DRAW );
|
|
1115
|
-
|
|
1133
|
+
state.bindBufferBase( gl.UNIFORM_BUFFER, groupIndex, bufferGPU );
|
|
1116
1134
|
|
|
1117
1135
|
this.set( binding, {
|
|
1118
1136
|
index: groupIndex ++,
|
|
@@ -1218,7 +1236,6 @@ class WebGLBackend extends Backend {
|
|
|
1218
1236
|
|
|
1219
1237
|
}
|
|
1220
1238
|
|
|
1221
|
-
|
|
1222
1239
|
getMaxAnisotropy() {
|
|
1223
1240
|
|
|
1224
1241
|
return this.capabilities.getMaxAnisotropy();
|
|
@@ -1237,38 +1254,38 @@ class WebGLBackend extends Backend {
|
|
|
1237
1254
|
|
|
1238
1255
|
}
|
|
1239
1256
|
|
|
1240
|
-
_setFramebuffer(
|
|
1257
|
+
_setFramebuffer( descriptor ) {
|
|
1241
1258
|
|
|
1242
1259
|
const { gl, state } = this;
|
|
1243
1260
|
|
|
1244
1261
|
let currentFrameBuffer = null;
|
|
1245
1262
|
|
|
1246
|
-
if (
|
|
1263
|
+
if ( descriptor.textures !== null ) {
|
|
1247
1264
|
|
|
1248
|
-
const renderTarget =
|
|
1265
|
+
const renderTarget = descriptor.renderTarget;
|
|
1249
1266
|
const renderTargetContextData = this.get( renderTarget );
|
|
1250
1267
|
const { samples, depthBuffer, stencilBuffer } = renderTarget;
|
|
1251
|
-
|
|
1268
|
+
|
|
1252
1269
|
const isCube = renderTarget.isWebGLCubeRenderTarget === true;
|
|
1253
1270
|
|
|
1254
1271
|
let msaaFb = renderTargetContextData.msaaFrameBuffer;
|
|
1255
1272
|
let depthRenderbuffer = renderTargetContextData.depthRenderbuffer;
|
|
1256
1273
|
|
|
1274
|
+
const cacheKey = getCacheKey( descriptor );
|
|
1275
|
+
|
|
1257
1276
|
let fb;
|
|
1258
1277
|
|
|
1259
1278
|
if ( isCube ) {
|
|
1260
1279
|
|
|
1261
|
-
|
|
1280
|
+
renderTargetContextData.cubeFramebuffers || ( renderTargetContextData.cubeFramebuffers = {} );
|
|
1262
1281
|
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
fb = renderTargetContextData.cubeFramebuffers[ cubeFace ];
|
|
1282
|
+
fb = renderTargetContextData.cubeFramebuffers[ cacheKey ];
|
|
1268
1283
|
|
|
1269
1284
|
} else {
|
|
1270
1285
|
|
|
1271
|
-
|
|
1286
|
+
renderTargetContextData.framebuffers || ( renderTargetContextData.framebuffers = {} );
|
|
1287
|
+
|
|
1288
|
+
fb = renderTargetContextData.framebuffers[ cacheKey ];
|
|
1272
1289
|
|
|
1273
1290
|
}
|
|
1274
1291
|
|
|
@@ -1278,22 +1295,27 @@ class WebGLBackend extends Backend {
|
|
|
1278
1295
|
|
|
1279
1296
|
state.bindFramebuffer( gl.FRAMEBUFFER, fb );
|
|
1280
1297
|
|
|
1281
|
-
const textures =
|
|
1298
|
+
const textures = descriptor.textures;
|
|
1282
1299
|
|
|
1283
1300
|
if ( isCube ) {
|
|
1284
1301
|
|
|
1285
|
-
renderTargetContextData.cubeFramebuffers[
|
|
1302
|
+
renderTargetContextData.cubeFramebuffers[ cacheKey ] = fb;
|
|
1303
|
+
|
|
1286
1304
|
const { textureGPU } = this.get( textures[ 0 ] );
|
|
1287
1305
|
|
|
1306
|
+
const cubeFace = this.renderer._activeCubeFace;
|
|
1307
|
+
|
|
1288
1308
|
gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + cubeFace, textureGPU, 0 );
|
|
1289
1309
|
|
|
1290
1310
|
} else {
|
|
1291
1311
|
|
|
1312
|
+
renderTargetContextData.framebuffers[ cacheKey ] = fb;
|
|
1313
|
+
|
|
1292
1314
|
for ( let i = 0; i < textures.length; i ++ ) {
|
|
1293
1315
|
|
|
1294
1316
|
const texture = textures[ i ];
|
|
1295
1317
|
const textureData = this.get( texture );
|
|
1296
|
-
textureData.renderTarget =
|
|
1318
|
+
textureData.renderTarget = descriptor.renderTarget;
|
|
1297
1319
|
|
|
1298
1320
|
const attachment = gl.COLOR_ATTACHMENT0 + i;
|
|
1299
1321
|
|
|
@@ -1301,15 +1323,13 @@ class WebGLBackend extends Backend {
|
|
|
1301
1323
|
|
|
1302
1324
|
}
|
|
1303
1325
|
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
state.drawBuffers( renderContext, fb );
|
|
1326
|
+
state.drawBuffers( descriptor, fb );
|
|
1307
1327
|
|
|
1308
1328
|
}
|
|
1309
1329
|
|
|
1310
|
-
if (
|
|
1330
|
+
if ( descriptor.depthTexture !== null ) {
|
|
1311
1331
|
|
|
1312
|
-
const textureData = this.get(
|
|
1332
|
+
const textureData = this.get( descriptor.depthTexture );
|
|
1313
1333
|
const depthStyle = stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;
|
|
1314
1334
|
|
|
1315
1335
|
gl.framebufferTexture2D( gl.FRAMEBUFFER, depthStyle, gl.TEXTURE_2D, textureData.textureGPU, 0 );
|
|
@@ -1330,11 +1350,10 @@ class WebGLBackend extends Backend {
|
|
|
1330
1350
|
|
|
1331
1351
|
const msaaRenderbuffers = [];
|
|
1332
1352
|
|
|
1333
|
-
const textures =
|
|
1353
|
+
const textures = descriptor.textures;
|
|
1334
1354
|
|
|
1335
1355
|
for ( let i = 0; i < textures.length; i ++ ) {
|
|
1336
1356
|
|
|
1337
|
-
|
|
1338
1357
|
msaaRenderbuffers[ i ] = gl.createRenderbuffer();
|
|
1339
1358
|
|
|
1340
1359
|
gl.bindRenderbuffer( gl.RENDERBUFFER, msaaRenderbuffers[ i ] );
|
|
@@ -1348,10 +1367,10 @@ class WebGLBackend extends Backend {
|
|
|
1348
1367
|
|
|
1349
1368
|
}
|
|
1350
1369
|
|
|
1351
|
-
const texture =
|
|
1370
|
+
const texture = descriptor.textures[ i ];
|
|
1352
1371
|
const textureData = this.get( texture );
|
|
1353
1372
|
|
|
1354
|
-
gl.renderbufferStorageMultisample( gl.RENDERBUFFER, samples, textureData.glInternalFormat,
|
|
1373
|
+
gl.renderbufferStorageMultisample( gl.RENDERBUFFER, samples, textureData.glInternalFormat, descriptor.width, descriptor.height );
|
|
1355
1374
|
gl.framebufferRenderbuffer( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, msaaRenderbuffers[ i ] );
|
|
1356
1375
|
|
|
1357
1376
|
|
|
@@ -1363,7 +1382,7 @@ class WebGLBackend extends Backend {
|
|
|
1363
1382
|
if ( depthRenderbuffer === undefined ) {
|
|
1364
1383
|
|
|
1365
1384
|
depthRenderbuffer = gl.createRenderbuffer();
|
|
1366
|
-
this.textureUtils.setupRenderBufferStorage( depthRenderbuffer,
|
|
1385
|
+
this.textureUtils.setupRenderBufferStorage( depthRenderbuffer, descriptor );
|
|
1367
1386
|
|
|
1368
1387
|
renderTargetContextData.depthRenderbuffer = depthRenderbuffer;
|
|
1369
1388
|
|
|
@@ -1510,7 +1529,7 @@ class WebGLBackend extends Backend {
|
|
|
1510
1529
|
|
|
1511
1530
|
}
|
|
1512
1531
|
|
|
1513
|
-
const gl = this
|
|
1532
|
+
const { gl } = this;
|
|
1514
1533
|
|
|
1515
1534
|
transformFeedbackGPU = gl.createTransformFeedback();
|
|
1516
1535
|
|
|
@@ -1575,7 +1594,8 @@ class WebGLBackend extends Backend {
|
|
|
1575
1594
|
|
|
1576
1595
|
if ( binding.isUniformsGroup || binding.isUniformBuffer ) {
|
|
1577
1596
|
|
|
1578
|
-
|
|
1597
|
+
// TODO USE bindBufferRange to group multiple uniform buffers
|
|
1598
|
+
state.bindBufferBase( gl.UNIFORM_BUFFER, index, bindingData.bufferGPU );
|
|
1579
1599
|
|
|
1580
1600
|
} else if ( binding.isSampledTexture ) {
|
|
1581
1601
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GLSLNodeParser, NodeBuilder, TextureNode, vectorComponents } from '../../../nodes/Nodes.js';
|
|
2
2
|
|
|
3
3
|
import NodeUniformBuffer from '../../common/nodes/NodeUniformBuffer.js';
|
|
4
4
|
import NodeUniformsGroup from '../../common/nodes/NodeUniformsGroup.js';
|
|
5
5
|
|
|
6
6
|
import { NodeSampledTexture, NodeSampledCubeTexture, NodeSampledTexture3D } from '../../common/nodes/NodeSampledTexture.js';
|
|
7
7
|
|
|
8
|
-
import { ByteType, ShortType, RGBAIntegerFormat, RGBIntegerFormat, RedIntegerFormat, RGIntegerFormat, UnsignedByteType, UnsignedIntType, UnsignedShortType, RedFormat, RGFormat, IntType, RGBFormat, RGBAFormat, FloatType } from '../../../constants.js';
|
|
8
|
+
import { NoColorSpace, ByteType, ShortType, RGBAIntegerFormat, RGBIntegerFormat, RedIntegerFormat, RGIntegerFormat, UnsignedByteType, UnsignedIntType, UnsignedShortType, RedFormat, RGFormat, IntType, RGBFormat, RGBAFormat, FloatType } from '../../../constants.js';
|
|
9
9
|
import { DataTexture } from '../../../textures/DataTexture.js';
|
|
10
10
|
|
|
11
11
|
const glslMethods = {
|
|
12
|
-
|
|
12
|
+
atan2: 'atan',
|
|
13
13
|
textureDimensions: 'textureSize',
|
|
14
14
|
equals: 'equal'
|
|
15
15
|
};
|
|
@@ -54,9 +54,18 @@ class GLSLNodeBuilder extends NodeBuilder {
|
|
|
54
54
|
|
|
55
55
|
this.uniformGroups = {};
|
|
56
56
|
this.transforms = [];
|
|
57
|
+
this.extensions = {};
|
|
57
58
|
|
|
58
59
|
this.instanceBindGroups = false;
|
|
59
60
|
|
|
61
|
+
this.useComparisonMethod = true;
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
needsColorSpaceToLinearSRGB( texture ) {
|
|
66
|
+
|
|
67
|
+
return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace;
|
|
68
|
+
|
|
60
69
|
}
|
|
61
70
|
|
|
62
71
|
getMethod( method ) {
|
|
@@ -198,7 +207,7 @@ ${ flowData.code }
|
|
|
198
207
|
const nodeUniform = this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.label );
|
|
199
208
|
const textureName = this.getPropertyName( nodeUniform );
|
|
200
209
|
|
|
201
|
-
|
|
210
|
+
this.increaseUsage( indexNode ); // force cache generate to be used as index in x,y
|
|
202
211
|
const indexSnippet = indexNode.build( this, 'uint' );
|
|
203
212
|
|
|
204
213
|
const elementNodeData = this.getDataFromNode( storageArrayElementNode );
|
|
@@ -384,7 +393,7 @@ ${ flowData.code }
|
|
|
384
393
|
|
|
385
394
|
snippet = `sampler2DShadow ${ uniform.name };`;
|
|
386
395
|
|
|
387
|
-
} else if ( texture.isDataArrayTexture === true ) {
|
|
396
|
+
} else if ( texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
388
397
|
|
|
389
398
|
snippet = `${typePrefix}sampler2DArray ${ uniform.name };`;
|
|
390
399
|
|
|
@@ -604,6 +613,16 @@ ${ flowData.code }
|
|
|
604
613
|
|
|
605
614
|
}
|
|
606
615
|
|
|
616
|
+
getInvocationLocalIndex() {
|
|
617
|
+
|
|
618
|
+
const workgroupSize = this.object.workgroupSize;
|
|
619
|
+
|
|
620
|
+
const size = workgroupSize.reduce( ( acc, curr ) => acc * curr, 1 );
|
|
621
|
+
|
|
622
|
+
return `uint( gl_InstanceID ) % ${size}u`;
|
|
623
|
+
|
|
624
|
+
}
|
|
625
|
+
|
|
607
626
|
getDrawIndex() {
|
|
608
627
|
|
|
609
628
|
const extensions = this.renderer.backend.extensions;
|
|
@@ -626,7 +645,7 @@ ${ flowData.code }
|
|
|
626
645
|
|
|
627
646
|
getFragCoord() {
|
|
628
647
|
|
|
629
|
-
return 'gl_FragCoord';
|
|
648
|
+
return 'gl_FragCoord.xy';
|
|
630
649
|
|
|
631
650
|
}
|
|
632
651
|
|
|
@@ -636,9 +655,24 @@ ${ flowData.code }
|
|
|
636
655
|
|
|
637
656
|
}
|
|
638
657
|
|
|
658
|
+
enableExtension( name, behavior, shaderStage = this.shaderStage ) {
|
|
659
|
+
|
|
660
|
+
const map = this.extensions[ shaderStage ] || ( this.extensions[ shaderStage ] = new Map() );
|
|
661
|
+
|
|
662
|
+
if ( map.has( name ) === false ) {
|
|
663
|
+
|
|
664
|
+
map.set( name, {
|
|
665
|
+
name,
|
|
666
|
+
behavior
|
|
667
|
+
} );
|
|
668
|
+
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
}
|
|
672
|
+
|
|
639
673
|
getExtensions( shaderStage ) {
|
|
640
674
|
|
|
641
|
-
|
|
675
|
+
const snippets = [];
|
|
642
676
|
|
|
643
677
|
if ( shaderStage === 'vertex' ) {
|
|
644
678
|
|
|
@@ -647,13 +681,25 @@ ${ flowData.code }
|
|
|
647
681
|
|
|
648
682
|
if ( isBatchedMesh && ext.has( 'WEBGL_multi_draw' ) ) {
|
|
649
683
|
|
|
650
|
-
|
|
684
|
+
this.enableExtension( 'GL_ANGLE_multi_draw', 'require', shaderStage );
|
|
651
685
|
|
|
652
686
|
}
|
|
653
687
|
|
|
654
688
|
}
|
|
655
689
|
|
|
656
|
-
|
|
690
|
+
const extensions = this.extensions[ shaderStage ];
|
|
691
|
+
|
|
692
|
+
if ( extensions !== undefined ) {
|
|
693
|
+
|
|
694
|
+
for ( const { name, behavior } of extensions.values() ) {
|
|
695
|
+
|
|
696
|
+
snippets.push( `#extension ${name} : ${behavior}` );
|
|
697
|
+
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
return snippets.join( '\n' );
|
|
657
703
|
|
|
658
704
|
}
|
|
659
705
|
|
|
@@ -733,6 +779,8 @@ ${vars}
|
|
|
733
779
|
|
|
734
780
|
return `#version 300 es
|
|
735
781
|
|
|
782
|
+
${ this.getSignature() }
|
|
783
|
+
|
|
736
784
|
// extensions
|
|
737
785
|
${shaderData.extensions}
|
|
738
786
|
|
|
@@ -48,6 +48,7 @@ class WebGLState {
|
|
|
48
48
|
this.maxTextures = this.gl.getParameter( this.gl.MAX_TEXTURE_IMAGE_UNITS );
|
|
49
49
|
this.currentTextureSlot = null;
|
|
50
50
|
this.currentBoundTextures = {};
|
|
51
|
+
this.currentBoundBufferBases = {};
|
|
51
52
|
|
|
52
53
|
if ( initialized === false ) {
|
|
53
54
|
|
|
@@ -716,6 +717,26 @@ class WebGLState {
|
|
|
716
717
|
|
|
717
718
|
}
|
|
718
719
|
|
|
720
|
+
bindBufferBase( target, index, buffer ) {
|
|
721
|
+
|
|
722
|
+
const { gl } = this;
|
|
723
|
+
|
|
724
|
+
const key = `${target}-${index}`;
|
|
725
|
+
|
|
726
|
+
if ( this.currentBoundBufferBases[ key ] !== buffer ) {
|
|
727
|
+
|
|
728
|
+
gl.bindBufferBase( target, index, buffer );
|
|
729
|
+
this.currentBoundBufferBases[ key ] = buffer;
|
|
730
|
+
|
|
731
|
+
return true;
|
|
732
|
+
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
return false;
|
|
736
|
+
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
|
|
719
740
|
unbindTexture() {
|
|
720
741
|
|
|
721
742
|
const { gl, currentTextureSlot, currentBoundTextures } = this;
|