@plastic-software/three 0.181.2 → 0.182.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/README.md +3 -4
- package/build/three.cjs +1192 -522
- package/build/three.core.js +345 -219
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +864 -328
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +15 -3
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3660 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3659 -1544
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +6 -6
- package/examples/jsm/controls/TrackballControls.js +6 -6
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/environments/RoomEnvironment.js +2 -0
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/inspector/Inspector.js +53 -9
- package/examples/jsm/inspector/RendererInspector.js +12 -2
- package/examples/jsm/inspector/tabs/Console.js +2 -2
- package/examples/jsm/inspector/tabs/Parameters.js +2 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Viewer.js +4 -4
- package/examples/jsm/inspector/ui/Profiler.js +1836 -31
- package/examples/jsm/inspector/ui/Style.js +948 -13
- package/examples/jsm/inspector/ui/Tab.js +188 -1
- package/examples/jsm/inspector/ui/Values.js +17 -1
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +0 -2
- package/examples/jsm/loaders/HDRLoader.js +0 -1
- package/examples/jsm/loaders/KTX2Loader.js +16 -0
- package/examples/jsm/loaders/LDrawLoader.js +2 -3
- package/examples/jsm/loaders/PCDLoader.js +1 -0
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/UltraHDRLoader.js +110 -137
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +2 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -1
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -1
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/objects/SkyMesh.js +13 -3
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +3 -1
- package/examples/jsm/physics/RapierPhysics.js +3 -1
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/Projector.js +268 -30
- package/examples/jsm/renderers/SVGRenderer.js +191 -58
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -0
- package/examples/jsm/tsl/display/BloomNode.js +11 -1
- package/examples/jsm/tsl/display/GTAONode.js +3 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +2 -1
- package/examples/jsm/tsl/display/SSGINode.js +7 -19
- package/examples/jsm/tsl/display/SSRNode.js +1 -1
- package/examples/jsm/tsl/display/SSSNode.js +4 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/TRAANode.js +265 -114
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/package.json +14 -12
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +14 -2
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/constants.js +61 -5
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Raycaster.js +2 -2
- package/src/extras/PMREMGenerator.js +3 -10
- package/src/extras/TextureUtils.js +5 -1
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/helpers/PointLightHelper.js +1 -1
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +0 -3
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/loaders/MaterialLoader.js +2 -1
- package/src/loaders/ObjectLoader.js +3 -1
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/materials/Material.js +2 -0
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +3 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +59 -3
- package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
- package/src/math/Matrix4.js +40 -40
- package/src/math/Sphere.js +1 -1
- package/src/math/Vector3.js +0 -2
- package/src/nodes/TSL.js +4 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/BufferAttributeNode.js +98 -12
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +20 -1
- package/src/nodes/accessors/InstanceNode.js +69 -29
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +2 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SkinningNode.js +15 -2
- package/src/nodes/accessors/StorageBufferNode.js +4 -2
- package/src/nodes/accessors/Tangent.js +1 -11
- package/src/nodes/accessors/Texture3DNode.js +26 -1
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionNode.js +1 -2
- package/src/nodes/core/ArrayNode.js +20 -1
- package/src/nodes/core/AssignNode.js +2 -2
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +103 -4
- package/src/nodes/core/NodeBuilder.js +56 -14
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +5 -5
- package/src/nodes/core/ParameterNode.js +1 -2
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +56 -8
- package/src/nodes/core/StructNode.js +1 -2
- package/src/nodes/core/StructTypeNode.js +11 -17
- package/src/nodes/core/UniformNode.js +19 -4
- package/src/nodes/core/VarNode.js +46 -21
- package/src/nodes/display/NormalMapNode.js +37 -2
- package/src/nodes/display/PassNode.js +77 -7
- package/src/nodes/display/ScreenNode.js +1 -0
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +102 -43
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -3
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/LightsNode.js +2 -2
- package/src/nodes/lighting/PointShadowNode.js +141 -140
- package/src/nodes/lighting/ShadowFilterNode.js +53 -37
- package/src/nodes/lighting/ShadowNode.js +53 -19
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/tsl/TSLCore.js +4 -4
- package/src/nodes/utils/ArrayElementNode.js +13 -0
- package/src/nodes/utils/EventNode.js +1 -2
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/ReflectorNode.js +1 -1
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/UVUtils.js +26 -0
- package/src/objects/BatchedMesh.js +5 -2
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/renderers/WebGLRenderer.js +145 -33
- package/src/renderers/common/Backend.js +8 -0
- package/src/renderers/common/Background.js +19 -9
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +7 -7
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/Geometries.js +12 -0
- package/src/renderers/common/RenderContexts.js +8 -1
- package/src/renderers/common/RenderObject.js +14 -1
- package/src/renderers/common/Renderer.js +53 -35
- package/src/renderers/common/Textures.js +1 -1
- package/src/renderers/common/UniformsGroup.js +1 -0
- package/src/renderers/common/XRManager.js +1 -0
- package/src/renderers/common/extras/PMREMGenerator.js +2 -8
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +90 -51
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +194 -186
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +3 -3
- package/src/renderers/webgl/WebGLCapabilities.js +3 -4
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +43 -107
- package/src/renderers/webgl/WebGLPrograms.js +35 -45
- package/src/renderers/webgl/WebGLShadowMap.js +188 -25
- package/src/renderers/webgl/WebGLState.js +20 -20
- package/src/renderers/webgl/WebGLTextures.js +89 -28
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +79 -13
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +59 -7
- package/src/renderers/webgl-fallback/utils/WebGLState.js +18 -3
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +61 -4
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +65 -23
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +354 -186
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +20 -7
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +40 -17
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +7 -5
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +1 -1
- package/src/utils.js +13 -1
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
|
@@ -24,9 +24,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24
24
|
try {
|
|
25
25
|
|
|
26
26
|
useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined'
|
|
27
|
-
// eslint-disable-next-line compat/compat
|
|
28
27
|
&& ( new OffscreenCanvas( 1, 1 ).getContext( '2d' ) ) !== null;
|
|
29
28
|
|
|
29
|
+
|
|
30
30
|
} catch ( err ) {
|
|
31
31
|
|
|
32
32
|
// Ignore any errors
|
|
@@ -38,7 +38,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
38
38
|
// Use OffscreenCanvas when available. Specially needed in web workers
|
|
39
39
|
|
|
40
40
|
return useOffscreenCanvas ?
|
|
41
|
-
// eslint-disable-next-line compat/compat
|
|
42
41
|
new OffscreenCanvas( width, height ) : createElementNS( 'canvas' );
|
|
43
42
|
|
|
44
43
|
}
|
|
@@ -583,7 +582,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
583
582
|
|
|
584
583
|
const textureProperties = properties.get( texture );
|
|
585
584
|
|
|
586
|
-
if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
585
|
+
if ( texture.isCubeDepthTexture !== true && texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
587
586
|
|
|
588
587
|
uploadCubeTexture( textureProperties, texture, slot );
|
|
589
588
|
return;
|
|
@@ -1575,7 +1574,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1575
1574
|
}
|
|
1576
1575
|
|
|
1577
1576
|
// Setup storage for internal depth/stencil buffers and bind to correct framebuffer
|
|
1578
|
-
function setupRenderBufferStorage( renderbuffer, renderTarget,
|
|
1577
|
+
function setupRenderBufferStorage( renderbuffer, renderTarget, useMultisample ) {
|
|
1579
1578
|
|
|
1580
1579
|
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
|
|
1581
1580
|
|
|
@@ -1588,15 +1587,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1588
1587
|
const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
1589
1588
|
|
|
1590
1589
|
// set up the attachment
|
|
1591
|
-
|
|
1592
|
-
const isUseMultisampledRTT = useMultisampledRTT( renderTarget );
|
|
1593
|
-
if ( isUseMultisampledRTT ) {
|
|
1590
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1594
1591
|
|
|
1595
|
-
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER,
|
|
1592
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1596
1593
|
|
|
1597
|
-
} else if (
|
|
1594
|
+
} else if ( useMultisample ) {
|
|
1598
1595
|
|
|
1599
|
-
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER,
|
|
1596
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1600
1597
|
|
|
1601
1598
|
} else {
|
|
1602
1599
|
|
|
@@ -1617,15 +1614,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1617
1614
|
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
1618
1615
|
const glType = utils.convert( texture.type );
|
|
1619
1616
|
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
1620
|
-
const samples = getRenderTargetSamples( renderTarget );
|
|
1621
1617
|
|
|
1622
|
-
if (
|
|
1618
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1623
1619
|
|
|
1624
|
-
|
|
1620
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1625
1621
|
|
|
1626
|
-
} else if (
|
|
1622
|
+
} else if ( useMultisample ) {
|
|
1627
1623
|
|
|
1628
|
-
|
|
1624
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1629
1625
|
|
|
1630
1626
|
} else {
|
|
1631
1627
|
|
|
@@ -1642,10 +1638,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1642
1638
|
}
|
|
1643
1639
|
|
|
1644
1640
|
// Setup resources for a Depth Texture for a FBO (needs an extension)
|
|
1645
|
-
function setupDepthTexture( framebuffer, renderTarget ) {
|
|
1641
|
+
function setupDepthTexture( framebuffer, renderTarget, cubeFace ) {
|
|
1646
1642
|
|
|
1647
|
-
const isCube = ( renderTarget
|
|
1648
|
-
if ( isCube ) throw new Error( 'Depth Texture with cube render targets is not supported' );
|
|
1643
|
+
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
1649
1644
|
|
|
1650
1645
|
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
1651
1646
|
|
|
@@ -1669,20 +1664,69 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1669
1664
|
|
|
1670
1665
|
}
|
|
1671
1666
|
|
|
1672
|
-
|
|
1667
|
+
if ( isCube ) {
|
|
1668
|
+
|
|
1669
|
+
// For cube depth textures, initialize and bind without uploading image data
|
|
1670
|
+
if ( textureProperties.__webglInit === undefined ) {
|
|
1671
|
+
|
|
1672
|
+
textureProperties.__webglInit = true;
|
|
1673
|
+
renderTarget.depthTexture.addEventListener( 'dispose', onTextureDispose );
|
|
1674
|
+
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
// Only create and allocate storage once
|
|
1678
|
+
if ( textureProperties.__webglTexture === undefined ) {
|
|
1679
|
+
|
|
1680
|
+
textureProperties.__webglTexture = _gl.createTexture();
|
|
1681
|
+
|
|
1682
|
+
state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
|
|
1683
|
+
setTextureParameters( _gl.TEXTURE_CUBE_MAP, renderTarget.depthTexture );
|
|
1684
|
+
|
|
1685
|
+
// Allocate storage for all 6 faces with correct depth texture format
|
|
1686
|
+
const glFormat = utils.convert( renderTarget.depthTexture.format );
|
|
1687
|
+
const glType = utils.convert( renderTarget.depthTexture.type );
|
|
1688
|
+
|
|
1689
|
+
// Use proper internal format for depth textures
|
|
1690
|
+
let glInternalFormat;
|
|
1691
|
+
if ( renderTarget.depthTexture.format === DepthFormat ) {
|
|
1692
|
+
|
|
1693
|
+
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
1694
|
+
|
|
1695
|
+
} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
|
|
1696
|
+
|
|
1697
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
1698
|
+
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
1702
|
+
|
|
1703
|
+
_gl.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
|
|
1704
|
+
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
} else {
|
|
1710
|
+
|
|
1711
|
+
setTexture2D( renderTarget.depthTexture, 0 );
|
|
1712
|
+
|
|
1713
|
+
}
|
|
1673
1714
|
|
|
1674
1715
|
const webglDepthTexture = textureProperties.__webglTexture;
|
|
1675
1716
|
const samples = getRenderTargetSamples( renderTarget );
|
|
1676
1717
|
|
|
1718
|
+
const glTextureType = isCube ? _gl.TEXTURE_CUBE_MAP_POSITIVE_X + cubeFace : _gl.TEXTURE_2D;
|
|
1719
|
+
const glAttachmentType = renderTarget.depthTexture.format === DepthStencilFormat ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
1720
|
+
|
|
1677
1721
|
if ( renderTarget.depthTexture.format === DepthFormat ) {
|
|
1678
1722
|
|
|
1679
1723
|
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1680
1724
|
|
|
1681
|
-
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER,
|
|
1725
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0, samples );
|
|
1682
1726
|
|
|
1683
1727
|
} else {
|
|
1684
1728
|
|
|
1685
|
-
_gl.framebufferTexture2D( _gl.FRAMEBUFFER,
|
|
1729
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0 );
|
|
1686
1730
|
|
|
1687
1731
|
}
|
|
1688
1732
|
|
|
@@ -1690,11 +1734,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1690
1734
|
|
|
1691
1735
|
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1692
1736
|
|
|
1693
|
-
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER,
|
|
1737
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0, samples );
|
|
1694
1738
|
|
|
1695
1739
|
} else {
|
|
1696
1740
|
|
|
1697
|
-
_gl.framebufferTexture2D( _gl.FRAMEBUFFER,
|
|
1741
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0 );
|
|
1698
1742
|
|
|
1699
1743
|
}
|
|
1700
1744
|
|
|
@@ -1745,17 +1789,28 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1745
1789
|
|
|
1746
1790
|
if ( renderTarget.depthTexture && ! renderTargetProperties.__autoAllocateDepthBuffer ) {
|
|
1747
1791
|
|
|
1748
|
-
if ( isCube )
|
|
1792
|
+
if ( isCube ) {
|
|
1749
1793
|
|
|
1750
|
-
|
|
1794
|
+
// For cube render targets with depth texture, setup each face
|
|
1795
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
1751
1796
|
|
|
1752
|
-
|
|
1797
|
+
setupDepthTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, i );
|
|
1753
1798
|
|
|
1754
|
-
|
|
1799
|
+
}
|
|
1755
1800
|
|
|
1756
1801
|
} else {
|
|
1757
1802
|
|
|
1758
|
-
|
|
1803
|
+
const mipmaps = renderTarget.texture.mipmaps;
|
|
1804
|
+
|
|
1805
|
+
if ( mipmaps && mipmaps.length > 0 ) {
|
|
1806
|
+
|
|
1807
|
+
setupDepthTexture( renderTargetProperties.__webglFramebuffer[ 0 ], renderTarget, 0 );
|
|
1808
|
+
|
|
1809
|
+
} else {
|
|
1810
|
+
|
|
1811
|
+
setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget, 0 );
|
|
1812
|
+
|
|
1813
|
+
}
|
|
1759
1814
|
|
|
1760
1815
|
}
|
|
1761
1816
|
|
|
@@ -2337,6 +2392,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2337
2392
|
this.setupFrameBufferTexture = setupFrameBufferTexture;
|
|
2338
2393
|
this.useMultisampledRTT = useMultisampledRTT;
|
|
2339
2394
|
|
|
2395
|
+
this.isReversedDepthBuffer = function () {
|
|
2396
|
+
|
|
2397
|
+
return state.buffers.depth.getReversed();
|
|
2398
|
+
|
|
2399
|
+
};
|
|
2400
|
+
|
|
2340
2401
|
}
|
|
2341
2402
|
|
|
2342
2403
|
export { WebGLTextures };
|
|
@@ -46,7 +46,7 @@ import { Texture } from '../../textures/Texture.js';
|
|
|
46
46
|
import { DataArrayTexture } from '../../textures/DataArrayTexture.js';
|
|
47
47
|
import { Data3DTexture } from '../../textures/Data3DTexture.js';
|
|
48
48
|
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
49
|
-
import { LessEqualCompare } from '../../constants.js';
|
|
49
|
+
import { LessEqualCompare, GreaterEqualCompare } from '../../constants.js';
|
|
50
50
|
|
|
51
51
|
const emptyTexture = /*@__PURE__*/ new Texture();
|
|
52
52
|
|
|
@@ -572,7 +572,7 @@ function setValueT1( gl, v, textures ) {
|
|
|
572
572
|
|
|
573
573
|
if ( this.type === gl.SAMPLER_2D_SHADOW ) {
|
|
574
574
|
|
|
575
|
-
emptyShadowTexture.compareFunction = LessEqualCompare;
|
|
575
|
+
emptyShadowTexture.compareFunction = textures.isReversedDepthBuffer() ? GreaterEqualCompare : LessEqualCompare;
|
|
576
576
|
emptyTexture2D = emptyShadowTexture;
|
|
577
577
|
|
|
578
578
|
} else {
|
|
@@ -822,9 +822,21 @@ function setValueT1Array( gl, v, textures ) {
|
|
|
822
822
|
|
|
823
823
|
}
|
|
824
824
|
|
|
825
|
+
let emptyTexture2D;
|
|
826
|
+
|
|
827
|
+
if ( this.type === gl.SAMPLER_2D_SHADOW ) {
|
|
828
|
+
|
|
829
|
+
emptyTexture2D = emptyShadowTexture;
|
|
830
|
+
|
|
831
|
+
} else {
|
|
832
|
+
|
|
833
|
+
emptyTexture2D = emptyTexture;
|
|
834
|
+
|
|
835
|
+
}
|
|
836
|
+
|
|
825
837
|
for ( let i = 0; i !== n; ++ i ) {
|
|
826
838
|
|
|
827
|
-
textures.setTexture2D( v[ i ] ||
|
|
839
|
+
textures.setTexture2D( v[ i ] || emptyTexture2D, units[ i ] );
|
|
828
840
|
|
|
829
841
|
}
|
|
830
842
|
|
|
@@ -1110,6 +1122,31 @@ class WebGLUniforms {
|
|
|
1110
1122
|
|
|
1111
1123
|
}
|
|
1112
1124
|
|
|
1125
|
+
// Sort uniforms to prioritize shadow samplers first (for optimal texture unit allocation)
|
|
1126
|
+
|
|
1127
|
+
const shadowSamplers = [];
|
|
1128
|
+
const otherUniforms = [];
|
|
1129
|
+
|
|
1130
|
+
for ( const u of this.seq ) {
|
|
1131
|
+
|
|
1132
|
+
if ( u.type === gl.SAMPLER_2D_SHADOW || u.type === gl.SAMPLER_CUBE_SHADOW || u.type === gl.SAMPLER_2D_ARRAY_SHADOW ) {
|
|
1133
|
+
|
|
1134
|
+
shadowSamplers.push( u );
|
|
1135
|
+
|
|
1136
|
+
} else {
|
|
1137
|
+
|
|
1138
|
+
otherUniforms.push( u );
|
|
1139
|
+
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
if ( shadowSamplers.length > 0 ) {
|
|
1145
|
+
|
|
1146
|
+
this.seq = shadowSamplers.concat( otherUniforms );
|
|
1147
|
+
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1113
1150
|
}
|
|
1114
1151
|
|
|
1115
1152
|
setValue( gl, name, value, textures ) {
|
|
@@ -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, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, NoColorSpace, SRGBTransfer, UnsignedInt5999Type, RGBFormat, UnsignedInt101111Type } from '../../constants.js';
|
|
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, R11_EAC_Format, SIGNED_R11_EAC_Format, RG11_EAC_Format, SIGNED_RG11_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, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, NoColorSpace, SRGBTransfer, UnsignedInt5999Type, RGBFormat, UnsignedInt101111Type } from '../../constants.js';
|
|
2
2
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
3
3
|
|
|
4
4
|
function WebGLUtils( gl, extensions ) {
|
|
@@ -102,7 +102,7 @@ function WebGLUtils( gl, extensions ) {
|
|
|
102
102
|
|
|
103
103
|
// ETC
|
|
104
104
|
|
|
105
|
-
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
105
|
+
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format || p === R11_EAC_Format || p === SIGNED_R11_EAC_Format || p === RG11_EAC_Format || p === SIGNED_RG11_EAC_Format ) {
|
|
106
106
|
|
|
107
107
|
extension = extensions.get( 'WEBGL_compressed_texture_etc' );
|
|
108
108
|
|
|
@@ -110,6 +110,10 @@ function WebGLUtils( gl, extensions ) {
|
|
|
110
110
|
|
|
111
111
|
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
112
112
|
if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
113
|
+
if ( p === R11_EAC_Format ) return extension.COMPRESSED_R11_EAC;
|
|
114
|
+
if ( p === SIGNED_R11_EAC_Format ) return extension.COMPRESSED_SIGNED_R11_EAC;
|
|
115
|
+
if ( p === RG11_EAC_Format ) return extension.COMPRESSED_RG11_EAC;
|
|
116
|
+
if ( p === SIGNED_RG11_EAC_Format ) return extension.COMPRESSED_SIGNED_RG11_EAC;
|
|
113
117
|
|
|
114
118
|
} else {
|
|
115
119
|
|
|
@@ -11,7 +11,7 @@ import WebGLCapabilities from './utils/WebGLCapabilities.js';
|
|
|
11
11
|
import { GLFeatureName } from './utils/WebGLConstants.js';
|
|
12
12
|
import { WebGLBufferRenderer } from './WebGLBufferRenderer.js';
|
|
13
13
|
|
|
14
|
-
import { warnOnce, warn, error } from '../../utils.js';
|
|
14
|
+
import { isTypedArray, warnOnce, warn, error } from '../../utils.js';
|
|
15
15
|
import { WebGLCoordinateSystem, TimestampQuery } from '../../constants.js';
|
|
16
16
|
import WebGLTimestampQueryPool from './utils/WebGLTimestampQueryPool.js';
|
|
17
17
|
|
|
@@ -268,6 +268,7 @@ class WebGLBackend extends Backend {
|
|
|
268
268
|
|
|
269
269
|
this.disjoint = this.extensions.get( 'EXT_disjoint_timer_query_webgl2' );
|
|
270
270
|
this.parallel = this.extensions.get( 'KHR_parallel_shader_compile' );
|
|
271
|
+
this.drawBuffersIndexedExt = this.extensions.get( 'OES_draw_buffers_indexed' );
|
|
271
272
|
|
|
272
273
|
}
|
|
273
274
|
|
|
@@ -814,7 +815,7 @@ class WebGLBackend extends Backend {
|
|
|
814
815
|
if ( this.discard === false ) {
|
|
815
816
|
|
|
816
817
|
// required here to handle async behaviour of render.compute()
|
|
817
|
-
|
|
818
|
+
state.enable( gl.RASTERIZER_DISCARD );
|
|
818
819
|
this.discard = true;
|
|
819
820
|
|
|
820
821
|
}
|
|
@@ -900,11 +901,11 @@ class WebGLBackend extends Backend {
|
|
|
900
901
|
*/
|
|
901
902
|
finishCompute( computeGroup ) {
|
|
902
903
|
|
|
903
|
-
const gl = this
|
|
904
|
+
const { state, gl } = this;
|
|
904
905
|
|
|
905
906
|
this.discard = false;
|
|
906
907
|
|
|
907
|
-
|
|
908
|
+
state.disable( gl.RASTERIZER_DISCARD );
|
|
908
909
|
|
|
909
910
|
this.prepareTimestampBuffer( TimestampQuery.COMPUTE, this.getTimestampUID( computeGroup ) );
|
|
910
911
|
|
|
@@ -957,6 +958,12 @@ class WebGLBackend extends Backend {
|
|
|
957
958
|
|
|
958
959
|
state.setMaterial( material, frontFaceCW, hardwareClippingPlanes );
|
|
959
960
|
|
|
961
|
+
if ( context.textures !== null && context.textures.length > 1 ) {
|
|
962
|
+
|
|
963
|
+
state.setMRTBlending( context.textures );
|
|
964
|
+
|
|
965
|
+
}
|
|
966
|
+
|
|
960
967
|
state.useProgram( programGPU );
|
|
961
968
|
|
|
962
969
|
// vertex state
|
|
@@ -1743,25 +1750,53 @@ class WebGLBackend extends Backend {
|
|
|
1743
1750
|
|
|
1744
1751
|
if ( binding.isUniformsGroup || binding.isUniformBuffer ) {
|
|
1745
1752
|
|
|
1746
|
-
const
|
|
1747
|
-
let { bufferGPU } = this.get(
|
|
1753
|
+
const array = binding.buffer;
|
|
1754
|
+
let { bufferGPU } = this.get( array );
|
|
1748
1755
|
|
|
1749
1756
|
if ( bufferGPU === undefined ) {
|
|
1750
1757
|
|
|
1751
1758
|
// create
|
|
1752
1759
|
|
|
1753
1760
|
bufferGPU = gl.createBuffer();
|
|
1761
|
+
|
|
1754
1762
|
gl.bindBuffer( gl.UNIFORM_BUFFER, bufferGPU );
|
|
1755
|
-
gl.bufferData( gl.UNIFORM_BUFFER,
|
|
1763
|
+
gl.bufferData( gl.UNIFORM_BUFFER, array.byteLength, gl.DYNAMIC_DRAW );
|
|
1756
1764
|
|
|
1757
|
-
this.set(
|
|
1765
|
+
this.set( array, { bufferGPU } );
|
|
1758
1766
|
|
|
1759
1767
|
} else {
|
|
1760
1768
|
|
|
1761
|
-
// update
|
|
1762
|
-
|
|
1763
1769
|
gl.bindBuffer( gl.UNIFORM_BUFFER, bufferGPU );
|
|
1764
|
-
|
|
1770
|
+
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
// update
|
|
1774
|
+
|
|
1775
|
+
const updateRanges = binding.updateRanges;
|
|
1776
|
+
|
|
1777
|
+
gl.bindBuffer( gl.UNIFORM_BUFFER, bufferGPU );
|
|
1778
|
+
|
|
1779
|
+
if ( updateRanges.length === 0 ) {
|
|
1780
|
+
|
|
1781
|
+
gl.bufferData( gl.UNIFORM_BUFFER, array, gl.DYNAMIC_DRAW );
|
|
1782
|
+
|
|
1783
|
+
} else {
|
|
1784
|
+
|
|
1785
|
+
const isTyped = isTypedArray( array );
|
|
1786
|
+
const byteOffsetFactor = isTyped ? 1 : array.BYTES_PER_ELEMENT;
|
|
1787
|
+
|
|
1788
|
+
for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
|
|
1789
|
+
|
|
1790
|
+
const range = updateRanges[ i ];
|
|
1791
|
+
|
|
1792
|
+
const dataOffset = range.start * byteOffsetFactor;
|
|
1793
|
+
const size = range.count * byteOffsetFactor;
|
|
1794
|
+
|
|
1795
|
+
const bufferOffset = dataOffset * ( isTyped ? array.BYTES_PER_ELEMENT : 1 ); // bufferOffset is always in bytes
|
|
1796
|
+
|
|
1797
|
+
gl.bufferSubData( gl.UNIFORM_BUFFER, bufferOffset, array, dataOffset, size );
|
|
1798
|
+
|
|
1799
|
+
}
|
|
1765
1800
|
|
|
1766
1801
|
}
|
|
1767
1802
|
|
|
@@ -1799,10 +1834,35 @@ class WebGLBackend extends Backend {
|
|
|
1799
1834
|
|
|
1800
1835
|
const bindingData = this.get( binding );
|
|
1801
1836
|
const bufferGPU = bindingData.bufferGPU;
|
|
1802
|
-
const
|
|
1837
|
+
const array = binding.buffer;
|
|
1838
|
+
|
|
1839
|
+
const updateRanges = binding.updateRanges;
|
|
1803
1840
|
|
|
1804
1841
|
gl.bindBuffer( gl.UNIFORM_BUFFER, bufferGPU );
|
|
1805
|
-
|
|
1842
|
+
|
|
1843
|
+
if ( updateRanges.length === 0 ) {
|
|
1844
|
+
|
|
1845
|
+
gl.bufferData( gl.UNIFORM_BUFFER, array, gl.DYNAMIC_DRAW );
|
|
1846
|
+
|
|
1847
|
+
} else {
|
|
1848
|
+
|
|
1849
|
+
const isTyped = isTypedArray( array );
|
|
1850
|
+
const byteOffsetFactor = isTyped ? 1 : array.BYTES_PER_ELEMENT;
|
|
1851
|
+
|
|
1852
|
+
for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
|
|
1853
|
+
|
|
1854
|
+
const range = updateRanges[ i ];
|
|
1855
|
+
|
|
1856
|
+
const dataOffset = range.start * byteOffsetFactor;
|
|
1857
|
+
const size = range.count * byteOffsetFactor;
|
|
1858
|
+
|
|
1859
|
+
const bufferOffset = dataOffset * ( isTyped ? array.BYTES_PER_ELEMENT : 1 ); // bufferOffset is always in bytes
|
|
1860
|
+
|
|
1861
|
+
gl.bufferSubData( gl.UNIFORM_BUFFER, bufferOffset, array, dataOffset, size );
|
|
1862
|
+
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
}
|
|
1806
1866
|
|
|
1807
1867
|
}
|
|
1808
1868
|
|
|
@@ -2091,6 +2151,12 @@ class WebGLBackend extends Backend {
|
|
|
2091
2151
|
|
|
2092
2152
|
gl.framebufferTextureLayer( gl.FRAMEBUFFER, depthStyle, textureData.textureGPU, 0, layer );
|
|
2093
2153
|
|
|
2154
|
+
} else if ( descriptor.depthTexture.isCubeTexture ) {
|
|
2155
|
+
|
|
2156
|
+
const cubeFace = this.renderer._activeCubeFace;
|
|
2157
|
+
|
|
2158
|
+
gl.framebufferTexture2D( gl.FRAMEBUFFER, depthStyle, gl.TEXTURE_CUBE_MAP_POSITIVE_X + cubeFace, textureData.textureGPU, 0 );
|
|
2159
|
+
|
|
2094
2160
|
} else {
|
|
2095
2161
|
|
|
2096
2162
|
gl.framebufferTexture2D( gl.FRAMEBUFFER, depthStyle, gl.TEXTURE_2D, textureData.textureGPU, 0 );
|
|
@@ -10,8 +10,8 @@ import { DataTexture } from '../../../textures/DataTexture.js';
|
|
|
10
10
|
import { error } from '../../../utils.js';
|
|
11
11
|
|
|
12
12
|
const glslPolyfills = {
|
|
13
|
-
bitcast_int_uint: new CodeNode( /* glsl */'uint
|
|
14
|
-
bitcast_uint_int: new CodeNode( /* glsl */'uint
|
|
13
|
+
bitcast_int_uint: new CodeNode( /* glsl */'uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }' ),
|
|
14
|
+
bitcast_uint_int: new CodeNode( /* glsl */'uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }' )
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const glslMethods = {
|
|
@@ -22,7 +22,13 @@ const glslMethods = {
|
|
|
22
22
|
bitcast_uint_float: 'uintBitsToFloat',
|
|
23
23
|
bitcast_float_uint: 'floatBitsToUint',
|
|
24
24
|
bitcast_uint_int: 'tsl_bitcast_uint_to_int',
|
|
25
|
-
bitcast_int_uint: 'tsl_bitcast_int_to_uint'
|
|
25
|
+
bitcast_int_uint: 'tsl_bitcast_int_to_uint',
|
|
26
|
+
floatpack_snorm_2x16: 'packSnorm2x16',
|
|
27
|
+
floatpack_unorm_2x16: 'packUnorm2x16',
|
|
28
|
+
floatpack_float16_2x16: 'packHalf2x16',
|
|
29
|
+
floatunpack_snorm_2x16: 'unpackSnorm2x16',
|
|
30
|
+
floatunpack_unorm_2x16: 'unpackUnorm2x16',
|
|
31
|
+
floatunpack_float16_2x16: 'unpackHalf2x16'
|
|
26
32
|
};
|
|
27
33
|
|
|
28
34
|
const precisionLib = {
|
|
@@ -184,6 +190,30 @@ class GLSLNodeBuilder extends NodeBuilder {
|
|
|
184
190
|
|
|
185
191
|
}
|
|
186
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Returns the float packing method name for a given numeric encoding.
|
|
195
|
+
*
|
|
196
|
+
* @param {string} encoding - The numeric encoding that describes how the float values are mapped to the integer range.
|
|
197
|
+
* @returns {string} The resolved GLSL float packing method name.
|
|
198
|
+
*/
|
|
199
|
+
getFloatPackingMethod( encoding ) {
|
|
200
|
+
|
|
201
|
+
return this.getMethod( `floatpack_${ encoding }_2x16` );
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Returns the float unpacking method name for a given numeric encoding.
|
|
207
|
+
*
|
|
208
|
+
* @param {string} encoding - The numeric encoding that describes how the integer values are mapped to the float range.
|
|
209
|
+
* @returns {string} The resolved GLSL float unpacking method name.
|
|
210
|
+
*/
|
|
211
|
+
getFloatUnpackingMethod( encoding ) {
|
|
212
|
+
|
|
213
|
+
return this.getMethod( `floatunpack_${ encoding }_2x16` );
|
|
214
|
+
|
|
215
|
+
}
|
|
216
|
+
|
|
187
217
|
/**
|
|
188
218
|
* Returns the native snippet for a ternary operation.
|
|
189
219
|
*
|
|
@@ -591,6 +621,13 @@ ${ flowData.code }
|
|
|
591
621
|
|
|
592
622
|
if ( shaderStage === 'fragment' ) {
|
|
593
623
|
|
|
624
|
+
// Cube shadow maps use vec4(direction, compareValue)
|
|
625
|
+
if ( texture.isCubeTexture ) {
|
|
626
|
+
|
|
627
|
+
return `texture( ${ textureProperty }, vec4( ${ uvSnippet }, ${ compareSnippet } ) )`;
|
|
628
|
+
|
|
629
|
+
}
|
|
630
|
+
|
|
594
631
|
if ( depthSnippet ) {
|
|
595
632
|
|
|
596
633
|
if ( offsetSnippet ) {
|
|
@@ -713,6 +750,10 @@ ${ flowData.code }
|
|
|
713
750
|
|
|
714
751
|
snippet = `samplerCube ${ uniform.name };`;
|
|
715
752
|
|
|
753
|
+
} else if ( uniform.type === 'cubeDepthTexture' ) {
|
|
754
|
+
|
|
755
|
+
snippet = `samplerCubeShadow ${ uniform.name };`;
|
|
756
|
+
|
|
716
757
|
} else if ( uniform.type === 'buffer' ) {
|
|
717
758
|
|
|
718
759
|
const bufferNode = uniform.node;
|
|
@@ -1519,7 +1560,7 @@ void main() {
|
|
|
1519
1560
|
uniformGPU = new NodeSampledTexture( uniformNode.name, uniformNode.node, group );
|
|
1520
1561
|
bindings.push( uniformGPU );
|
|
1521
1562
|
|
|
1522
|
-
} else if ( type === 'cubeTexture' ) {
|
|
1563
|
+
} else if ( type === 'cubeTexture' || type === 'cubeDepthTexture' ) {
|
|
1523
1564
|
|
|
1524
1565
|
uniformGPU = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node, group );
|
|
1525
1566
|
bindings.push( uniformGPU );
|
|
@@ -1531,11 +1572,22 @@ void main() {
|
|
|
1531
1572
|
|
|
1532
1573
|
} else if ( type === 'buffer' ) {
|
|
1533
1574
|
|
|
1534
|
-
node.name = `NodeBuffer_${ node.id }`;
|
|
1535
1575
|
uniformNode.name = `buffer${ node.id }`;
|
|
1536
1576
|
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1577
|
+
const sharedData = this.getSharedDataFromNode( node );
|
|
1578
|
+
|
|
1579
|
+
let buffer = sharedData.buffer;
|
|
1580
|
+
|
|
1581
|
+
if ( buffer === undefined ) {
|
|
1582
|
+
|
|
1583
|
+
node.name = `NodeBuffer_${ node.id }`;
|
|
1584
|
+
|
|
1585
|
+
buffer = new NodeUniformBuffer( node, group );
|
|
1586
|
+
buffer.name = node.name;
|
|
1587
|
+
|
|
1588
|
+
sharedData.buffer = buffer;
|
|
1589
|
+
|
|
1590
|
+
}
|
|
1539
1591
|
|
|
1540
1592
|
bindings.push( buffer );
|
|
1541
1593
|
|
|
@@ -85,7 +85,6 @@ class WebGLState {
|
|
|
85
85
|
this.currentBoundTextures = {};
|
|
86
86
|
this.currentBoundBufferBases = {};
|
|
87
87
|
|
|
88
|
-
|
|
89
88
|
this._init();
|
|
90
89
|
|
|
91
90
|
}
|
|
@@ -271,6 +270,22 @@ class WebGLState {
|
|
|
271
270
|
|
|
272
271
|
}
|
|
273
272
|
|
|
273
|
+
setMRTBlending( textures ) {
|
|
274
|
+
|
|
275
|
+
const gl = this.gl;
|
|
276
|
+
const drawBuffersIndexedExt = this.backend.drawBuffersIndexedExt;
|
|
277
|
+
|
|
278
|
+
if ( ! drawBuffersIndexedExt ) return;
|
|
279
|
+
|
|
280
|
+
for ( let i = 1; i < textures.length; i ++ ) {
|
|
281
|
+
|
|
282
|
+
// use opaque blending for additional render targets
|
|
283
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( i, gl.ONE, gl.ZERO, gl.ONE, gl.ZERO );
|
|
284
|
+
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
}
|
|
288
|
+
|
|
274
289
|
/**
|
|
275
290
|
* Defines the blending.
|
|
276
291
|
*
|
|
@@ -610,11 +625,11 @@ class WebGLState {
|
|
|
610
625
|
|
|
611
626
|
if ( boolean ) {
|
|
612
627
|
|
|
613
|
-
|
|
628
|
+
this.enable( gl.SCISSOR_TEST );
|
|
614
629
|
|
|
615
630
|
} else {
|
|
616
631
|
|
|
617
|
-
|
|
632
|
+
this.disable( gl.SCISSOR_TEST );
|
|
618
633
|
|
|
619
634
|
}
|
|
620
635
|
|
|
@@ -488,7 +488,7 @@ class WebGLTextureUtils {
|
|
|
488
488
|
backend.state.unbindTexture();
|
|
489
489
|
// debug
|
|
490
490
|
// const framebuffer = gl.createFramebuffer();
|
|
491
|
-
//
|
|
491
|
+
// backend.state.bindFramebuffer( gl.FRAMEBUFFER, framebuffer );
|
|
492
492
|
// gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, glTextureType, textureGPU, 0 );
|
|
493
493
|
|
|
494
494
|
// const readout = new Float32Array( width * height * 4 );
|
|
@@ -497,7 +497,7 @@ class WebGLTextureUtils {
|
|
|
497
497
|
// const altType = gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_TYPE );
|
|
498
498
|
|
|
499
499
|
// gl.readPixels( 0, 0, width, height, altFormat, altType, readout );
|
|
500
|
-
//
|
|
500
|
+
// backend.state.bindFramebuffer( gl.FRAMEBUFFER, null );
|
|
501
501
|
// log( readout );
|
|
502
502
|
|
|
503
503
|
}
|
|
@@ -1183,7 +1183,7 @@ class WebGLTextureUtils {
|
|
|
1183
1183
|
|
|
1184
1184
|
const fb = gl.createFramebuffer();
|
|
1185
1185
|
|
|
1186
|
-
|
|
1186
|
+
backend.state.bindFramebuffer( gl.READ_FRAMEBUFFER, fb );
|
|
1187
1187
|
|
|
1188
1188
|
const target = texture.isCubeTexture ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D;
|
|
1189
1189
|
|
|
@@ -1210,6 +1210,8 @@ class WebGLTextureUtils {
|
|
|
1210
1210
|
gl.getBufferSubData( gl.PIXEL_PACK_BUFFER, 0, dstBuffer );
|
|
1211
1211
|
gl.bindBuffer( gl.PIXEL_PACK_BUFFER, null );
|
|
1212
1212
|
|
|
1213
|
+
backend.state.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
|
|
1214
|
+
|
|
1213
1215
|
gl.deleteFramebuffer( fb );
|
|
1214
1216
|
|
|
1215
1217
|
return dstBuffer;
|