@plastic-software/three 0.182.0 → 0.183.1
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/LICENSE +1 -1
- package/build/three.cjs +11521 -10878
- package/build/three.core.js +11732 -11340
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +510 -263
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +7 -11
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +3072 -2607
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +3071 -2607
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -3
- package/examples/jsm/animation/CCDIKSolver.js +2 -2
- package/examples/jsm/controls/ArcballControls.js +3 -3
- package/examples/jsm/controls/OrbitControls.js +103 -0
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +1 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +131 -4
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Inspector.js +21 -5
- package/examples/jsm/inspector/tabs/Console.js +39 -5
- package/examples/jsm/inspector/tabs/Parameters.js +16 -0
- package/examples/jsm/inspector/ui/Style.js +25 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
- package/examples/jsm/lines/LineMaterial.js +6 -0
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +122 -171
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +5 -5
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +3 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +182 -30
- package/examples/jsm/loaders/VRMLLoader.js +77 -0
- package/examples/jsm/loaders/VTKLoader.js +37 -24
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/usd/USDAParser.js +447 -366
- package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Sky.js +76 -4
- package/examples/jsm/objects/SkyMesh.js +114 -7
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/JoltPhysics.js +7 -5
- package/examples/jsm/physics/RapierPhysics.js +6 -4
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/SVGRenderer.js +2 -2
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +456 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/examples/jsm/tsl/display/BloomNode.js +5 -5
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +2 -2
- package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +3 -3
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +5 -5
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -7
- package/examples/jsm/tsl/display/SSSNode.js +2 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TRAANode.js +9 -12
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/math/Bayer.js +40 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/package.json +11 -19
- package/src/Three.Core.js +1 -1
- package/src/Three.TSL.js +5 -9
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/KeyframeTrack.js +46 -7
- package/src/animation/PropertyMixer.js +4 -4
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +30 -1
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +56 -4
- package/src/core/RenderTarget.js +3 -4
- package/src/extras/PMREMGenerator.js +4 -8
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +0 -24
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/LightShadow.js +15 -3
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/ImageBitmapLoader.js +8 -3
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/ObjectLoader.js +18 -1
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/nodes/Line2NodeMaterial.js +5 -5
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -0
- package/src/materials/nodes/NodeMaterial.js +15 -24
- package/src/materials/nodes/manager/NodeMaterialObserver.js +9 -3
- package/src/math/Line3.js +3 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix4.js +35 -26
- package/src/math/Quaternion.js +3 -29
- package/src/math/Vector3.js +3 -3
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +87 -68
- package/src/nodes/TSL.js +2 -5
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/InstanceNode.js +105 -40
- package/src/nodes/accessors/Normal.js +9 -9
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +12 -24
- package/src/nodes/accessors/StorageBufferNode.js +0 -19
- package/src/nodes/accessors/StorageTextureNode.js +37 -1
- package/src/nodes/accessors/Tangent.js +3 -3
- package/src/nodes/accessors/Texture3DNode.js +6 -34
- package/src/nodes/accessors/TextureNode.js +58 -22
- package/src/nodes/accessors/UniformArrayNode.js +2 -0
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +29 -3
- package/src/nodes/core/NodeBuilder.js +115 -40
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +2 -1
- package/src/nodes/core/StackNode.js +9 -8
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +15 -0
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformNode.js +2 -1
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -18
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +21 -2
- package/src/nodes/display/RenderOutputNode.js +3 -3
- package/src/nodes/display/ScreenNode.js +2 -1
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportTextureNode.js +21 -4
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/PhysicalLightingModel.js +25 -3
- package/src/nodes/geometry/RangeNode.js +4 -2
- package/src/nodes/gpgpu/ComputeNode.js +5 -4
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/PointShadowNode.js +24 -12
- package/src/nodes/lighting/ShadowFilterNode.js +15 -43
- package/src/nodes/lighting/ShadowNode.js +54 -32
- package/src/nodes/math/ConditionalNode.js +2 -2
- package/src/nodes/math/MathNode.js +3 -40
- package/src/nodes/math/OperatorNode.js +2 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLCore.js +13 -10
- package/src/nodes/utils/DebugNode.js +11 -11
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +2 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +4 -2
- package/src/objects/BatchedMesh.js +22 -12
- package/src/objects/InstancedMesh.js +11 -0
- package/src/renderers/WebGLRenderer.js +34 -60
- package/src/renderers/common/Backend.js +21 -0
- package/src/renderers/common/Background.js +7 -4
- package/src/renderers/common/BindGroup.js +1 -9
- package/src/renderers/common/Bindings.js +20 -5
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +50 -6
- package/src/renderers/common/Geometries.js +17 -3
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +4 -4
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/RenderBundles.js +2 -1
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -56
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +2 -3
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +18 -2
- package/src/renderers/common/RenderPipeline.js +203 -17
- package/src/renderers/common/Renderer.js +207 -40
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +16 -0
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +60 -0
- package/src/renderers/common/XRManager.js +2 -2
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +23 -1
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +55 -24
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +4 -2
- package/src/renderers/shaders/UniformsLib.js +0 -3
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +2 -2
- package/src/renderers/webgl/WebGLPrograms.js +10 -4
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +5 -4
- package/src/renderers/webgl/WebGLState.js +12 -17
- package/src/renderers/webgl-fallback/WebGLBackend.js +71 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +98 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +168 -7
- package/src/renderers/webgpu/WebGPUBackend.js +58 -9
- package/src/renderers/webgpu/WebGPURenderer.js +1 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +257 -45
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +8 -19
- package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -31
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +25 -25
- package/src/renderers/webgpu/utils/WebGPUUtils.js +10 -6
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +246 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -433
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -96,10 +96,10 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
|
|
|
96
96
|
|
|
97
97
|
if ( lights.length === 0 ) return;
|
|
98
98
|
|
|
99
|
-
if (
|
|
99
|
+
if ( this.type === PCFSoftShadowMap ) {
|
|
100
100
|
|
|
101
101
|
warn( 'WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead.' );
|
|
102
|
-
|
|
102
|
+
this.type = PCFShadowMap;
|
|
103
103
|
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -197,6 +197,9 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
|
|
|
197
197
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
const reversedDepthBuffer = renderer.state.buffers.depth.getReversed();
|
|
201
|
+
shadow.camera._reversedDepth = reversedDepthBuffer;
|
|
202
|
+
|
|
200
203
|
if ( shadow.map === null || typeChanged === true ) {
|
|
201
204
|
|
|
202
205
|
if ( shadow.map !== null ) {
|
|
@@ -255,8 +258,6 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
|
|
|
255
258
|
shadow.map.depthTexture.name = light.name + '.shadowMap';
|
|
256
259
|
shadow.map.depthTexture.format = DepthFormat;
|
|
257
260
|
|
|
258
|
-
const reversedDepthBuffer = renderer.state.buffers.depth.getReversed();
|
|
259
|
-
|
|
260
261
|
if ( this.type === PCFShadowMap ) {
|
|
261
262
|
|
|
262
263
|
shadow.map.depthTexture.compareFunction = reversedDepthBuffer ? GreaterEqualCompare : LessEqualCompare;
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor, ConstantColorFactor, OneMinusConstantColorFactor, ConstantAlphaFactor, OneMinusConstantAlphaFactor } from '../../constants.js';
|
|
2
2
|
import { Color } from '../../math/Color.js';
|
|
3
3
|
import { Vector4 } from '../../math/Vector4.js';
|
|
4
|
-
import { error } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
const reversedFuncs = {
|
|
7
|
-
[ NeverDepth ]: AlwaysDepth,
|
|
8
|
-
[ LessDepth ]: GreaterDepth,
|
|
9
|
-
[ EqualDepth ]: NotEqualDepth,
|
|
10
|
-
[ LessEqualDepth ]: GreaterEqualDepth,
|
|
11
|
-
|
|
12
|
-
[ AlwaysDepth ]: NeverDepth,
|
|
13
|
-
[ GreaterDepth ]: LessDepth,
|
|
14
|
-
[ NotEqualDepth ]: EqualDepth,
|
|
15
|
-
[ GreaterEqualDepth ]: LessEqualDepth,
|
|
16
|
-
};
|
|
4
|
+
import { error, ReversedDepthFuncs } from '../../utils.js';
|
|
17
5
|
|
|
18
6
|
function WebGLState( gl, extensions ) {
|
|
19
7
|
|
|
@@ -146,7 +134,7 @@ function WebGLState( gl, extensions ) {
|
|
|
146
134
|
|
|
147
135
|
setFunc: function ( depthFunc ) {
|
|
148
136
|
|
|
149
|
-
if ( currentReversed ) depthFunc =
|
|
137
|
+
if ( currentReversed ) depthFunc = ReversedDepthFuncs[ depthFunc ];
|
|
150
138
|
|
|
151
139
|
if ( currentDepthFunc !== depthFunc ) {
|
|
152
140
|
|
|
@@ -214,6 +202,8 @@ function WebGLState( gl, extensions ) {
|
|
|
214
202
|
|
|
215
203
|
if ( currentDepthClear !== depth ) {
|
|
216
204
|
|
|
205
|
+
currentDepthClear = depth;
|
|
206
|
+
|
|
217
207
|
if ( currentReversed ) {
|
|
218
208
|
|
|
219
209
|
depth = 1 - depth;
|
|
@@ -221,7 +211,6 @@ function WebGLState( gl, extensions ) {
|
|
|
221
211
|
}
|
|
222
212
|
|
|
223
213
|
gl.clearDepth( depth );
|
|
224
|
-
currentDepthClear = depth;
|
|
225
214
|
|
|
226
215
|
}
|
|
227
216
|
|
|
@@ -875,11 +864,17 @@ function WebGLState( gl, extensions ) {
|
|
|
875
864
|
|
|
876
865
|
if ( currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units ) {
|
|
877
866
|
|
|
878
|
-
gl.polygonOffset( factor, units );
|
|
879
|
-
|
|
880
867
|
currentPolygonOffsetFactor = factor;
|
|
881
868
|
currentPolygonOffsetUnits = units;
|
|
882
869
|
|
|
870
|
+
if ( depthBuffer.getReversed() ) {
|
|
871
|
+
|
|
872
|
+
factor = - factor;
|
|
873
|
+
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
gl.polygonOffset( factor, units );
|
|
877
|
+
|
|
883
878
|
}
|
|
884
879
|
|
|
885
880
|
} else {
|
|
@@ -12,7 +12,7 @@ import { GLFeatureName } from './utils/WebGLConstants.js';
|
|
|
12
12
|
import { WebGLBufferRenderer } from './WebGLBufferRenderer.js';
|
|
13
13
|
|
|
14
14
|
import { isTypedArray, warnOnce, warn, error } from '../../utils.js';
|
|
15
|
-
import { WebGLCoordinateSystem, TimestampQuery } from '../../constants.js';
|
|
15
|
+
import { WebGLCoordinateSystem, TimestampQuery, Compatibility } from '../../constants.js';
|
|
16
16
|
import WebGLTimestampQueryPool from './utils/WebGLTimestampQueryPool.js';
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -28,6 +28,7 @@ class WebGLBackend extends Backend {
|
|
|
28
28
|
*
|
|
29
29
|
* @typedef {Object} WebGLBackend~Options
|
|
30
30
|
* @property {boolean} [logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
|
|
31
|
+
* @property {boolean} [reversedDepthBuffer=false] - Whether reversed depth buffer is enabled or not.
|
|
31
32
|
* @property {boolean} [alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
|
|
32
33
|
* @property {boolean} [depth=true] - Whether the default framebuffer should have a depth buffer or not.
|
|
33
34
|
* @property {boolean} [stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
|
|
@@ -184,7 +185,6 @@ class WebGLBackend extends Backend {
|
|
|
184
185
|
*/
|
|
185
186
|
this._knownBindings = new WeakSet();
|
|
186
187
|
|
|
187
|
-
|
|
188
188
|
/**
|
|
189
189
|
* Whether the device supports framebuffers invalidation or not.
|
|
190
190
|
*
|
|
@@ -265,11 +265,18 @@ class WebGLBackend extends Backend {
|
|
|
265
265
|
this.extensions.get( 'WEBGL_render_shared_exponent' );
|
|
266
266
|
this.extensions.get( 'WEBGL_multi_draw' );
|
|
267
267
|
this.extensions.get( 'OVR_multiview2' );
|
|
268
|
+
this.extensions.get( 'EXT_clip_control' );
|
|
268
269
|
|
|
269
270
|
this.disjoint = this.extensions.get( 'EXT_disjoint_timer_query_webgl2' );
|
|
270
271
|
this.parallel = this.extensions.get( 'KHR_parallel_shader_compile' );
|
|
271
272
|
this.drawBuffersIndexedExt = this.extensions.get( 'OES_draw_buffers_indexed' );
|
|
272
273
|
|
|
274
|
+
if ( parameters.reversedDepthBuffer === true && this.extensions.has( 'EXT_clip_control' ) ) {
|
|
275
|
+
|
|
276
|
+
this.state.setReversedDepth( true );
|
|
277
|
+
|
|
278
|
+
}
|
|
279
|
+
|
|
273
280
|
}
|
|
274
281
|
|
|
275
282
|
/**
|
|
@@ -446,9 +453,12 @@ class WebGLBackend extends Backend {
|
|
|
446
453
|
|
|
447
454
|
if ( renderContext.scissor ) {
|
|
448
455
|
|
|
449
|
-
|
|
456
|
+
this.updateScissor( renderContext );
|
|
457
|
+
|
|
458
|
+
} else {
|
|
450
459
|
|
|
451
|
-
|
|
460
|
+
const { width, height } = this.getDrawingBufferSize();
|
|
461
|
+
state.scissor( 0, 0, width, height );
|
|
452
462
|
|
|
453
463
|
}
|
|
454
464
|
|
|
@@ -545,6 +555,17 @@ class WebGLBackend extends Backend {
|
|
|
545
555
|
|
|
546
556
|
}
|
|
547
557
|
|
|
558
|
+
if ( previousContext.scissor ) {
|
|
559
|
+
|
|
560
|
+
this.updateScissor( previousContext );
|
|
561
|
+
|
|
562
|
+
} else {
|
|
563
|
+
|
|
564
|
+
const { width, height } = this.getDrawingBufferSize();
|
|
565
|
+
state.scissor( 0, 0, width, height );
|
|
566
|
+
|
|
567
|
+
}
|
|
568
|
+
|
|
548
569
|
}
|
|
549
570
|
|
|
550
571
|
this.prepareTimestampBuffer( TimestampQuery.RENDER, this.getTimestampUID( renderContext ) );
|
|
@@ -646,6 +667,20 @@ class WebGLBackend extends Backend {
|
|
|
646
667
|
|
|
647
668
|
}
|
|
648
669
|
|
|
670
|
+
/**
|
|
671
|
+
* Updates the scissor with the values from the given render context.
|
|
672
|
+
*
|
|
673
|
+
* @param {RenderContext} renderContext - The render context.
|
|
674
|
+
*/
|
|
675
|
+
updateScissor( renderContext ) {
|
|
676
|
+
|
|
677
|
+
const { state } = this;
|
|
678
|
+
const { x, y, width, height } = renderContext.scissorValue;
|
|
679
|
+
|
|
680
|
+
state.scissor( x, renderContext.height - height - y, width, height );
|
|
681
|
+
|
|
682
|
+
}
|
|
683
|
+
|
|
649
684
|
/**
|
|
650
685
|
* Defines the scissor test.
|
|
651
686
|
*
|
|
@@ -958,9 +993,9 @@ class WebGLBackend extends Backend {
|
|
|
958
993
|
|
|
959
994
|
state.setMaterial( material, frontFaceCW, hardwareClippingPlanes );
|
|
960
995
|
|
|
961
|
-
if ( context.
|
|
996
|
+
if ( context.mrt !== null && context.textures !== null ) {
|
|
962
997
|
|
|
963
|
-
state.setMRTBlending( context.textures );
|
|
998
|
+
state.setMRTBlending( context.textures, context.mrt, material );
|
|
964
999
|
|
|
965
1000
|
}
|
|
966
1001
|
|
|
@@ -1997,6 +2032,35 @@ class WebGLBackend extends Backend {
|
|
|
1997
2032
|
|
|
1998
2033
|
}
|
|
1999
2034
|
|
|
2035
|
+
/**
|
|
2036
|
+
* Checks if the given compatibility is supported by the backend.
|
|
2037
|
+
*
|
|
2038
|
+
* @param {string} name - The compatibility name.
|
|
2039
|
+
* @return {boolean} Whether the compatibility is supported or not.
|
|
2040
|
+
*/
|
|
2041
|
+
hasCompatibility( name ) {
|
|
2042
|
+
|
|
2043
|
+
if ( name === Compatibility.TEXTURE_COMPARE ) return true;
|
|
2044
|
+
|
|
2045
|
+
return super.hasCompatibility( name );
|
|
2046
|
+
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
/**
|
|
2050
|
+
* Initializes the render target defined in the given render context.
|
|
2051
|
+
*
|
|
2052
|
+
* @param {RenderContext} renderContext - The render context.
|
|
2053
|
+
*/
|
|
2054
|
+
initRenderTarget( renderContext ) {
|
|
2055
|
+
|
|
2056
|
+
const { gl, state } = this;
|
|
2057
|
+
|
|
2058
|
+
this._setFramebuffer( renderContext );
|
|
2059
|
+
|
|
2060
|
+
state.bindFramebuffer( gl.FRAMEBUFFER, null );
|
|
2061
|
+
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2000
2064
|
/**
|
|
2001
2065
|
* Configures the active framebuffer from the given render context.
|
|
2002
2066
|
*
|
|
@@ -2015,7 +2079,7 @@ class WebGLBackend extends Backend {
|
|
|
2015
2079
|
const renderTargetContextData = this.get( renderTarget );
|
|
2016
2080
|
const { samples, depthBuffer, stencilBuffer } = renderTarget;
|
|
2017
2081
|
|
|
2018
|
-
const isCube = renderTarget.
|
|
2082
|
+
const isCube = renderTarget.isCubeRenderTarget === true;
|
|
2019
2083
|
const isRenderTarget3D = renderTarget.isRenderTarget3D === true;
|
|
2020
2084
|
const isRenderTargetArray = renderTarget.depth > 1;
|
|
2021
2085
|
const isXRRenderTarget = renderTarget.isXRRenderTarget === true;
|
|
@@ -69,9 +69,9 @@ precision highp isampler3D;
|
|
|
69
69
|
precision highp isamplerCube;
|
|
70
70
|
precision highp isampler2DArray;
|
|
71
71
|
|
|
72
|
-
precision
|
|
73
|
-
precision
|
|
74
|
-
precision
|
|
72
|
+
precision highp sampler2DShadow;
|
|
73
|
+
precision highp sampler2DArrayShadow;
|
|
74
|
+
precision highp samplerCubeShadow;
|
|
75
75
|
`;
|
|
76
76
|
|
|
77
77
|
/**
|
|
@@ -360,7 +360,7 @@ ${ flowData.code }
|
|
|
360
360
|
|
|
361
361
|
if ( node.isNodeUniform && node.node.isTextureNode !== true && node.node.isBufferNode !== true ) {
|
|
362
362
|
|
|
363
|
-
return
|
|
363
|
+
return node.name;
|
|
364
364
|
|
|
365
365
|
}
|
|
366
366
|
|
|
@@ -545,10 +545,13 @@ ${ flowData.code }
|
|
|
545
545
|
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
546
546
|
* @param {string} uvSnippet - A GLSL snippet that represents texture coordinates used for sampling.
|
|
547
547
|
* @param {string} levelSnippet - A GLSL snippet that represents the mip level, with level 0 containing a full size version of the texture.
|
|
548
|
+
* @param {?string} depthSnippet - A GLSL snippet that represents 0-based texture array index to sample.
|
|
548
549
|
* @param {?string} offsetSnippet - A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
549
550
|
* @return {string} The GLSL snippet.
|
|
550
551
|
*/
|
|
551
|
-
generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, offsetSnippet ) {
|
|
552
|
+
generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet, offsetSnippet ) {
|
|
553
|
+
|
|
554
|
+
if ( depthSnippet ) uvSnippet = `vec3( ${ uvSnippet }, ${ depthSnippet } )`;
|
|
552
555
|
|
|
553
556
|
if ( offsetSnippet ) {
|
|
554
557
|
|
|
@@ -567,10 +570,13 @@ ${ flowData.code }
|
|
|
567
570
|
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
568
571
|
* @param {string} uvSnippet - A GLSL snippet that represents texture coordinates used for sampling.
|
|
569
572
|
* @param {string} biasSnippet - A GLSL snippet that represents the bias to apply to the mip level before sampling.
|
|
573
|
+
* @param {?string} depthSnippet - A GLSL snippet that represents 0-based texture array index to sample.
|
|
570
574
|
* @param {?string} offsetSnippet - A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
571
575
|
* @return {string} The GLSL snippet.
|
|
572
576
|
*/
|
|
573
|
-
generateTextureBias( texture, textureProperty, uvSnippet, biasSnippet, offsetSnippet ) {
|
|
577
|
+
generateTextureBias( texture, textureProperty, uvSnippet, biasSnippet, depthSnippet, offsetSnippet ) {
|
|
578
|
+
|
|
579
|
+
if ( depthSnippet ) uvSnippet = `vec3( ${ uvSnippet }, ${ depthSnippet } )`;
|
|
574
580
|
|
|
575
581
|
if ( offsetSnippet ) {
|
|
576
582
|
|
|
@@ -589,10 +595,13 @@ ${ flowData.code }
|
|
|
589
595
|
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
590
596
|
* @param {string} uvSnippet - A GLSL snippet that represents texture coordinates used for sampling.
|
|
591
597
|
* @param {Array<string>} gradSnippet - An array holding both gradient GLSL snippets.
|
|
598
|
+
* @param {?string} depthSnippet - A GLSL snippet that represents 0-based texture array index to sample.
|
|
592
599
|
* @param {?string} offsetSnippet - A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
593
600
|
* @return {string} The GLSL snippet.
|
|
594
601
|
*/
|
|
595
|
-
generateTextureGrad( texture, textureProperty, uvSnippet, gradSnippet, offsetSnippet ) {
|
|
602
|
+
generateTextureGrad( texture, textureProperty, uvSnippet, gradSnippet, depthSnippet, offsetSnippet ) {
|
|
603
|
+
|
|
604
|
+
if ( depthSnippet ) uvSnippet = `vec3( ${ uvSnippet }, ${ depthSnippet } )`;
|
|
596
605
|
|
|
597
606
|
if ( offsetSnippet ) {
|
|
598
607
|
|
|
@@ -752,7 +761,17 @@ ${ flowData.code }
|
|
|
752
761
|
|
|
753
762
|
} else if ( uniform.type === 'cubeDepthTexture' ) {
|
|
754
763
|
|
|
755
|
-
|
|
764
|
+
const texture = uniform.node.value;
|
|
765
|
+
|
|
766
|
+
if ( texture.compareFunction ) {
|
|
767
|
+
|
|
768
|
+
snippet = `samplerCubeShadow ${ uniform.name };`;
|
|
769
|
+
|
|
770
|
+
} else {
|
|
771
|
+
|
|
772
|
+
snippet = `samplerCube ${ uniform.name };`;
|
|
773
|
+
|
|
774
|
+
}
|
|
756
775
|
|
|
757
776
|
} else if ( uniform.type === 'buffer' ) {
|
|
758
777
|
|
|
@@ -765,32 +784,56 @@ ${ flowData.code }
|
|
|
765
784
|
|
|
766
785
|
} else {
|
|
767
786
|
|
|
768
|
-
const
|
|
787
|
+
const groupName = uniform.groupNode.name;
|
|
769
788
|
|
|
770
|
-
|
|
789
|
+
// Check if this group has already been processed
|
|
790
|
+
if ( uniformGroups[ groupName ] === undefined ) {
|
|
771
791
|
|
|
772
|
-
|
|
792
|
+
// Get the shared uniform group that contains uniforms from all stages
|
|
793
|
+
const sharedUniformGroup = this.uniformGroups[ groupName ];
|
|
773
794
|
|
|
774
|
-
|
|
795
|
+
if ( sharedUniformGroup !== undefined ) {
|
|
796
|
+
|
|
797
|
+
// Generate snippets for ALL uniforms in this shared group
|
|
798
|
+
const snippets = [];
|
|
775
799
|
|
|
776
|
-
|
|
800
|
+
for ( const sharedUniform of sharedUniformGroup.uniforms ) {
|
|
777
801
|
|
|
778
|
-
|
|
802
|
+
const type = sharedUniform.getType();
|
|
803
|
+
const vectorType = this.getVectorType( type );
|
|
804
|
+
const precision = sharedUniform.nodeUniform.node.precision;
|
|
805
|
+
|
|
806
|
+
let uniformSnippet = `${ vectorType } ${ sharedUniform.name };`;
|
|
807
|
+
|
|
808
|
+
if ( precision !== null ) {
|
|
809
|
+
|
|
810
|
+
uniformSnippet = precisionLib[ precision ] + ' ' + uniformSnippet;
|
|
811
|
+
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
snippets.push( '\t' + uniformSnippet );
|
|
815
|
+
|
|
816
|
+
}
|
|
779
817
|
|
|
780
|
-
|
|
818
|
+
uniformGroups[ groupName ] = snippets;
|
|
819
|
+
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
group = true;
|
|
781
825
|
|
|
782
826
|
}
|
|
783
827
|
|
|
784
|
-
if ( group ) {
|
|
828
|
+
if ( ! group ) {
|
|
785
829
|
|
|
786
|
-
|
|
830
|
+
const precision = uniform.node.precision;
|
|
787
831
|
|
|
788
|
-
|
|
789
|
-
const groupSnippets = uniformGroups[ groupName ] || ( uniformGroups[ groupName ] = [] );
|
|
832
|
+
if ( precision !== null ) {
|
|
790
833
|
|
|
791
|
-
|
|
834
|
+
snippet = precisionLib[ precision ] + ' ' + snippet;
|
|
792
835
|
|
|
793
|
-
|
|
836
|
+
}
|
|
794
837
|
|
|
795
838
|
snippet = 'uniform ' + snippet;
|
|
796
839
|
|
|
@@ -806,7 +849,7 @@ ${ flowData.code }
|
|
|
806
849
|
|
|
807
850
|
const groupSnippets = uniformGroups[ name ];
|
|
808
851
|
|
|
809
|
-
output += this._getGLSLUniformStruct(
|
|
852
|
+
output += this._getGLSLUniformStruct( name, groupSnippets.join( '\n' ) ) + '\n';
|
|
810
853
|
|
|
811
854
|
}
|
|
812
855
|
|
|
@@ -1273,6 +1316,18 @@ ${ flowData.code }
|
|
|
1273
1316
|
|
|
1274
1317
|
}
|
|
1275
1318
|
|
|
1319
|
+
/**
|
|
1320
|
+
* Returns the maximum number of bytes available for uniform buffers.
|
|
1321
|
+
*
|
|
1322
|
+
* @return {number} The maximum number of bytes available for uniform buffers.
|
|
1323
|
+
*/
|
|
1324
|
+
getUniformBufferLimit() {
|
|
1325
|
+
|
|
1326
|
+
const gl = this.renderer.backend.gl;
|
|
1327
|
+
return gl.getParameter( gl.MAX_UNIFORM_BLOCK_SIZE );
|
|
1328
|
+
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1276
1331
|
/**
|
|
1277
1332
|
* Enables hardware clipping.
|
|
1278
1333
|
*
|
|
@@ -1595,24 +1650,38 @@ void main() {
|
|
|
1595
1650
|
|
|
1596
1651
|
} else {
|
|
1597
1652
|
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
let uniformsGroup = uniformsStage[ groupName ];
|
|
1653
|
+
let uniformsGroup = this.uniformGroups[ groupName ];
|
|
1601
1654
|
|
|
1602
1655
|
if ( uniformsGroup === undefined ) {
|
|
1603
1656
|
|
|
1604
|
-
uniformsGroup = new NodeUniformsGroup(
|
|
1605
|
-
//uniformsGroup.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
1657
|
+
uniformsGroup = new NodeUniformsGroup( groupName, group );
|
|
1606
1658
|
|
|
1607
|
-
|
|
1659
|
+
this.uniformGroups[ groupName ] = uniformsGroup;
|
|
1608
1660
|
|
|
1609
1661
|
bindings.push( uniformsGroup );
|
|
1610
1662
|
|
|
1663
|
+
} else {
|
|
1664
|
+
|
|
1665
|
+
// Add to bindings for this stage if not already present
|
|
1666
|
+
if ( bindings.indexOf( uniformsGroup ) === - 1 ) {
|
|
1667
|
+
|
|
1668
|
+
bindings.push( uniformsGroup );
|
|
1669
|
+
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1611
1672
|
}
|
|
1612
1673
|
|
|
1613
1674
|
uniformGPU = this.getNodeUniform( uniformNode, type );
|
|
1614
1675
|
|
|
1615
|
-
|
|
1676
|
+
// Only add uniform if not already present in the group (check by name to avoid duplicates across stages)
|
|
1677
|
+
const uniformName = uniformGPU.name;
|
|
1678
|
+
const alreadyExists = uniformsGroup.uniforms.some( u => u.name === uniformName );
|
|
1679
|
+
|
|
1680
|
+
if ( ! alreadyExists ) {
|
|
1681
|
+
|
|
1682
|
+
uniformsGroup.addUniform( uniformGPU );
|
|
1683
|
+
|
|
1684
|
+
}
|
|
1616
1685
|
|
|
1617
1686
|
}
|
|
1618
1687
|
|
|
@@ -4,10 +4,11 @@ import {
|
|
|
4
4
|
AdditiveBlending, SubtractiveBlending, MultiplyBlending, SubtractEquation, ReverseSubtractEquation,
|
|
5
5
|
ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor,
|
|
6
6
|
OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor,
|
|
7
|
-
NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth
|
|
7
|
+
NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth,
|
|
8
|
+
MaterialBlending
|
|
8
9
|
} from '../../../constants.js';
|
|
9
10
|
import { Vector4 } from '../../../math/Vector4.js';
|
|
10
|
-
import { error } from '../../../utils.js';
|
|
11
|
+
import { error, ReversedDepthFuncs, warnOnce } from '../../../utils.js';
|
|
11
12
|
|
|
12
13
|
let equationToGL, factorToGL;
|
|
13
14
|
|
|
@@ -62,6 +63,7 @@ class WebGLState {
|
|
|
62
63
|
this.currentPolygonOffsetFactor = null;
|
|
63
64
|
this.currentPolygonOffsetUnits = null;
|
|
64
65
|
this.currentColorMask = null;
|
|
66
|
+
this.currentDepthReversed = false;
|
|
65
67
|
this.currentDepthFunc = null;
|
|
66
68
|
this.currentDepthMask = null;
|
|
67
69
|
this.currentStencilFunc = null;
|
|
@@ -270,17 +272,146 @@ class WebGLState {
|
|
|
270
272
|
|
|
271
273
|
}
|
|
272
274
|
|
|
273
|
-
setMRTBlending( textures ) {
|
|
275
|
+
setMRTBlending( textures, mrt, material ) {
|
|
274
276
|
|
|
275
277
|
const gl = this.gl;
|
|
276
278
|
const drawBuffersIndexedExt = this.backend.drawBuffersIndexedExt;
|
|
277
279
|
|
|
278
|
-
if ( ! drawBuffersIndexedExt )
|
|
280
|
+
if ( ! drawBuffersIndexedExt ) {
|
|
279
281
|
|
|
280
|
-
|
|
282
|
+
warnOnce( 'WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.' );
|
|
281
283
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
return;
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
289
|
+
|
|
290
|
+
const texture = textures[ i ];
|
|
291
|
+
|
|
292
|
+
let blending = null;
|
|
293
|
+
|
|
294
|
+
if ( mrt !== null ) {
|
|
295
|
+
|
|
296
|
+
const blendMode = mrt.getBlendMode( texture.name );
|
|
297
|
+
|
|
298
|
+
if ( blendMode.blending === MaterialBlending ) {
|
|
299
|
+
|
|
300
|
+
// use material blending
|
|
301
|
+
blending = material;
|
|
302
|
+
|
|
303
|
+
} else if ( blendMode.blending !== NoBlending ) {
|
|
304
|
+
|
|
305
|
+
blending = blendMode;
|
|
306
|
+
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
} else {
|
|
310
|
+
|
|
311
|
+
// use material blending
|
|
312
|
+
blending = material;
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if ( blending !== null ) {
|
|
317
|
+
|
|
318
|
+
this._setMRTBlendingIndex( i, blending );
|
|
319
|
+
|
|
320
|
+
} else {
|
|
321
|
+
|
|
322
|
+
// use opaque blending (no blending)
|
|
323
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( i, gl.ONE, gl.ZERO, gl.ONE, gl.ZERO );
|
|
324
|
+
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Applies blending configuration for a specific draw buffer index.
|
|
333
|
+
*
|
|
334
|
+
* @private
|
|
335
|
+
* @param {number} index - The draw buffer index.
|
|
336
|
+
* @param {Object} blending - The blending configuration (material or BlendMode).
|
|
337
|
+
*/
|
|
338
|
+
_setMRTBlendingIndex( index, blending ) {
|
|
339
|
+
|
|
340
|
+
const { gl } = this;
|
|
341
|
+
const drawBuffersIndexedExt = this.backend.drawBuffersIndexedExt;
|
|
342
|
+
|
|
343
|
+
const blendingType = blending.blending;
|
|
344
|
+
const blendSrc = blending.blendSrc;
|
|
345
|
+
const blendDst = blending.blendDst;
|
|
346
|
+
const blendEquation = blending.blendEquation;
|
|
347
|
+
const premultipliedAlpha = blending.premultipliedAlpha;
|
|
348
|
+
|
|
349
|
+
if ( blendingType === CustomBlending ) {
|
|
350
|
+
|
|
351
|
+
const blendSrcAlpha = blending.blendSrcAlpha !== null ? blending.blendSrcAlpha : blendSrc;
|
|
352
|
+
const blendDstAlpha = blending.blendDstAlpha !== null ? blending.blendDstAlpha : blendDst;
|
|
353
|
+
const blendEquationAlpha = blending.blendEquationAlpha !== null ? blending.blendEquationAlpha : blendEquation;
|
|
354
|
+
|
|
355
|
+
drawBuffersIndexedExt.blendEquationSeparateiOES( index, equationToGL[ blendEquation ], equationToGL[ blendEquationAlpha ] );
|
|
356
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, factorToGL[ blendSrc ], factorToGL[ blendDst ], factorToGL[ blendSrcAlpha ], factorToGL[ blendDstAlpha ] );
|
|
357
|
+
|
|
358
|
+
} else {
|
|
359
|
+
|
|
360
|
+
drawBuffersIndexedExt.blendEquationSeparateiOES( index, gl.FUNC_ADD, gl.FUNC_ADD );
|
|
361
|
+
|
|
362
|
+
if ( premultipliedAlpha ) {
|
|
363
|
+
|
|
364
|
+
switch ( blendingType ) {
|
|
365
|
+
|
|
366
|
+
case NormalBlending:
|
|
367
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
368
|
+
break;
|
|
369
|
+
|
|
370
|
+
case AdditiveBlending:
|
|
371
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.ONE, gl.ONE, gl.ONE, gl.ONE );
|
|
372
|
+
break;
|
|
373
|
+
|
|
374
|
+
case SubtractiveBlending:
|
|
375
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
|
|
376
|
+
break;
|
|
377
|
+
|
|
378
|
+
case MultiplyBlending:
|
|
379
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ZERO, gl.ONE );
|
|
380
|
+
break;
|
|
381
|
+
|
|
382
|
+
default:
|
|
383
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
384
|
+
break;
|
|
385
|
+
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
} else {
|
|
389
|
+
|
|
390
|
+
switch ( blendingType ) {
|
|
391
|
+
|
|
392
|
+
case NormalBlending:
|
|
393
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
394
|
+
break;
|
|
395
|
+
|
|
396
|
+
case AdditiveBlending:
|
|
397
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.SRC_ALPHA, gl.ONE, gl.ONE, gl.ONE );
|
|
398
|
+
break;
|
|
399
|
+
|
|
400
|
+
case SubtractiveBlending:
|
|
401
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
|
|
402
|
+
break;
|
|
403
|
+
|
|
404
|
+
case MultiplyBlending:
|
|
405
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ZERO, gl.ONE );
|
|
406
|
+
break;
|
|
407
|
+
|
|
408
|
+
default:
|
|
409
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
410
|
+
break;
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
}
|
|
284
415
|
|
|
285
416
|
}
|
|
286
417
|
|
|
@@ -478,6 +609,34 @@ class WebGLState {
|
|
|
478
609
|
|
|
479
610
|
}
|
|
480
611
|
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Configures the WebGL state to use a reversed depth buffer.
|
|
615
|
+
*
|
|
616
|
+
* @param {boolean} reversed - Whether the depth buffer is reversed or not.
|
|
617
|
+
*/
|
|
618
|
+
setReversedDepth( reversed ) {
|
|
619
|
+
|
|
620
|
+
if ( this.currentDepthReversed !== reversed ) {
|
|
621
|
+
|
|
622
|
+
const ext = this.backend.extensions.get( 'EXT_clip_control' );
|
|
623
|
+
|
|
624
|
+
if ( reversed ) {
|
|
625
|
+
|
|
626
|
+
ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.ZERO_TO_ONE_EXT );
|
|
627
|
+
|
|
628
|
+
} else {
|
|
629
|
+
|
|
630
|
+
ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.NEGATIVE_ONE_TO_ONE_EXT );
|
|
631
|
+
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
this.currentDepthReversed = reversed;
|
|
635
|
+
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
}
|
|
639
|
+
|
|
481
640
|
/**
|
|
482
641
|
* Specifies whether depth values can be written when rendering
|
|
483
642
|
* into a framebuffer or not.
|
|
@@ -508,6 +667,8 @@ class WebGLState {
|
|
|
508
667
|
*/
|
|
509
668
|
setDepthFunc( depthFunc ) {
|
|
510
669
|
|
|
670
|
+
if ( this.currentDepthReversed ) depthFunc = ReversedDepthFuncs[ depthFunc ];
|
|
671
|
+
|
|
511
672
|
if ( this.currentDepthFunc !== depthFunc ) {
|
|
512
673
|
|
|
513
674
|
const { gl } = this;
|