super-three 0.157.1 → 0.160.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 +6 -4
- package/build/three.cjs +3100 -1537
- package/build/three.js +3100 -1537
- package/build/three.min.js +1 -1
- package/build/three.module.js +3093 -1538
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +291 -0
- package/examples/jsm/controls/FlyControls.js +26 -0
- package/examples/jsm/controls/OrbitControls.js +62 -41
- package/examples/jsm/controls/TransformControls.js +27 -11
- package/examples/jsm/csm/CSMShader.js +53 -48
- package/examples/jsm/exporters/GLTFExporter.js +151 -3
- package/examples/jsm/exporters/USDZExporter.js +27 -19
- package/examples/jsm/geometries/InstancedPointsGeometry.js +174 -0
- package/examples/jsm/geometries/SDFGeometryGenerator.js +144 -0
- package/examples/jsm/helpers/TextureHelper.js +237 -0
- package/examples/jsm/interactive/HTMLMesh.js +9 -2
- package/examples/jsm/libs/lottie_canvas.module.js +6 -1
- package/examples/jsm/libs/opentype.module.js +13 -75
- package/examples/jsm/libs/surfaceNet.js +201 -0
- package/examples/jsm/lines/LineMaterial.js +16 -33
- package/examples/jsm/loaders/ColladaLoader.js +0 -6
- package/examples/jsm/loaders/DRACOLoader.js +4 -3
- package/examples/jsm/loaders/FBXLoader.js +294 -124
- package/examples/jsm/loaders/GLTFLoader.js +83 -6
- package/examples/jsm/loaders/LUTImageLoader.js +162 -0
- package/examples/jsm/loaders/MaterialXLoader.js +73 -54
- package/examples/jsm/loaders/NRRDLoader.js +0 -13
- package/examples/jsm/loaders/SVGLoader.js +4 -4
- package/examples/jsm/loaders/USDZLoader.js +3 -17
- package/examples/jsm/loaders/lwo/IFFParser.js +89 -93
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/math/Capsule.js +0 -55
- package/examples/jsm/math/Octree.js +85 -7
- package/examples/jsm/misc/Timer.js +119 -0
- package/examples/jsm/misc/TubePainter.js +3 -6
- package/examples/jsm/modifiers/CurveModifier.js +20 -2
- package/examples/jsm/modifiers/SimplifyModifier.js +103 -11
- package/examples/jsm/modifiers/TessellateModifier.js +3 -3
- package/examples/jsm/nodes/Nodes.js +16 -12
- package/examples/jsm/nodes/accessors/CameraNode.js +18 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +5 -73
- package/examples/jsm/nodes/accessors/InstanceNode.js +3 -3
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +68 -31
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +11 -2
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -2
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +12 -3
- package/examples/jsm/nodes/accessors/MorphNode.js +191 -16
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/ReferenceNode.js +25 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +13 -3
- package/examples/jsm/nodes/accessors/TextureNode.js +123 -37
- package/examples/jsm/nodes/code/CodeNode.js +3 -3
- package/examples/jsm/nodes/code/FunctionNode.js +1 -1
- package/examples/jsm/nodes/core/AssignNode.js +72 -0
- package/examples/jsm/nodes/core/AttributeNode.js +7 -1
- package/examples/jsm/nodes/core/CacheNode.js +4 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/LightingModel.js +3 -1
- package/examples/jsm/nodes/core/Node.js +13 -15
- package/examples/jsm/nodes/core/NodeBuilder.js +209 -42
- package/examples/jsm/nodes/core/NodeFrame.js +10 -8
- package/examples/jsm/nodes/core/NodeUniform.js +12 -0
- package/examples/jsm/nodes/core/NodeUtils.js +7 -9
- package/examples/jsm/nodes/core/OutputStructNode.js +4 -4
- package/examples/jsm/nodes/core/ParameterNode.js +33 -0
- package/examples/jsm/nodes/core/PropertyNode.js +15 -6
- package/examples/jsm/nodes/core/StackNode.js +7 -17
- package/examples/jsm/nodes/core/StructTypeNode.js +4 -4
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformGroup.js +13 -0
- package/examples/jsm/nodes/core/UniformGroupNode.js +36 -0
- package/examples/jsm/nodes/core/UniformNode.js +17 -0
- package/examples/jsm/nodes/core/VarNode.js +7 -34
- package/examples/jsm/nodes/core/VaryingNode.js +3 -7
- package/examples/jsm/nodes/display/BumpMapNode.js +35 -13
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +6 -10
- package/examples/jsm/nodes/display/GaussianBlurNode.js +170 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -1
- package/examples/jsm/nodes/display/PassNode.js +182 -0
- package/examples/jsm/nodes/display/ViewportDepthNode.js +31 -3
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportNode.js +17 -10
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +20 -6
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -7
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +8 -3
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +8 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +8 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +93 -43
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +55 -6
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -18
- package/examples/jsm/nodes/lighting/LightingContextNode.js +21 -57
- package/examples/jsm/nodes/lighting/LightsNode.js +80 -20
- package/examples/jsm/nodes/lighting/PointLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/SpotLightNode.js +1 -1
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +162 -0
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +76 -77
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +5 -5
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +47 -20
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/NodeMaterial.js +82 -60
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +10 -10
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +128 -54
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +1430 -618
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +24 -14
- package/examples/jsm/nodes/math/MathNode.js +2 -0
- package/examples/jsm/nodes/math/OperatorNode.js +24 -27
- package/examples/jsm/nodes/shadernode/ShaderNode.js +158 -10
- package/examples/jsm/nodes/utils/ArrayElementNode.js +2 -0
- package/examples/jsm/nodes/utils/DiscardNode.js +3 -2
- package/examples/jsm/nodes/utils/FunctionOverloadingNode.js +95 -0
- package/examples/jsm/nodes/utils/JoinNode.js +11 -1
- package/examples/jsm/nodes/utils/LoopNode.js +36 -24
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +10 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +3 -3
- package/examples/jsm/objects/InstancedPoints.js +21 -0
- package/examples/jsm/objects/Lensflare.js +20 -0
- package/examples/jsm/objects/QuadMesh.js +60 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -0
- package/examples/jsm/objects/Refractor.js +3 -0
- package/examples/jsm/objects/Sky.js +5 -3
- package/examples/jsm/objects/Water.js +5 -2
- package/examples/jsm/objects/Water2.js +3 -0
- package/examples/jsm/physics/AmmoPhysics.js +21 -0
- package/examples/jsm/physics/RapierPhysics.js +21 -0
- package/examples/jsm/postprocessing/BokehPass.js +3 -2
- package/examples/jsm/postprocessing/GTAOPass.js +572 -0
- package/examples/jsm/postprocessing/LUTPass.js +2 -1
- package/examples/jsm/postprocessing/OutputPass.js +3 -0
- package/examples/jsm/postprocessing/Pass.js +14 -3
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SMAAPass.js +0 -2
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +3 -9
- package/examples/jsm/renderers/SVGRenderer.js +9 -6
- package/examples/jsm/renderers/common/Animation.js +10 -21
- package/examples/jsm/renderers/common/Backend.js +19 -3
- package/examples/jsm/renderers/common/Background.js +20 -22
- package/examples/jsm/renderers/common/Bindings.js +31 -22
- package/examples/jsm/renderers/common/ChainMap.js +3 -3
- package/examples/jsm/renderers/common/Color4.js +37 -0
- package/examples/jsm/renderers/common/Geometries.js +4 -4
- package/examples/jsm/renderers/common/Info.js +12 -2
- package/examples/jsm/renderers/common/Pipelines.js +3 -51
- package/examples/jsm/renderers/common/PostProcessing.js +25 -0
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderContexts.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +21 -2
- package/examples/jsm/renderers/common/RenderObjects.js +5 -3
- package/examples/jsm/renderers/common/Renderer.js +137 -37
- package/examples/jsm/renderers/common/StorageTexture.js +1 -0
- package/examples/jsm/renderers/common/Textures.js +8 -37
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +10 -2
- package/examples/jsm/renderers/common/nodes/NodeUniformsGroup.js +44 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +121 -19
- package/examples/jsm/renderers/webgl/WebGLBackend.js +366 -67
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +183 -38
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +92 -5
- package/examples/jsm/renderers/webgl/utils/WebGLCapabilities.js +36 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +11 -1
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +14 -2
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +71 -2
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +42 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +33 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +4 -14
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +188 -137
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +1 -1
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +241 -90
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -10
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +11 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +2 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +88 -6
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +2 -0
- package/examples/jsm/shaders/AfterimageShader.js +2 -0
- package/examples/jsm/shaders/BasicShader.js +2 -0
- package/examples/jsm/shaders/BlendShader.js +2 -0
- package/examples/jsm/shaders/BokehShader.js +2 -0
- package/examples/jsm/shaders/BokehShader2.js +4 -0
- package/examples/jsm/shaders/BrightnessContrastShader.js +2 -0
- package/examples/jsm/shaders/ColorCorrectionShader.js +2 -0
- package/examples/jsm/shaders/DOFMipMapShader.js +2 -0
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +5 -0
- package/examples/jsm/shaders/FXAAShader.js +135 -133
- package/examples/jsm/shaders/FilmShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +2 -0
- package/examples/jsm/shaders/FreiChenShader.js +2 -0
- package/examples/jsm/shaders/GTAOShader.js +424 -0
- package/examples/jsm/shaders/GodRaysShader.js +8 -0
- package/examples/jsm/shaders/HalftoneShader.js +2 -0
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/HueSaturationShader.js +2 -0
- package/examples/jsm/shaders/KaleidoShader.js +2 -0
- package/examples/jsm/shaders/LuminosityHighPassShader.js +2 -0
- package/examples/jsm/shaders/LuminosityShader.js +2 -0
- package/examples/jsm/shaders/MMDToonShader.js +2 -0
- package/examples/jsm/shaders/MirrorShader.js +2 -0
- package/examples/jsm/shaders/NormalMapShader.js +2 -0
- package/examples/jsm/shaders/OutputShader.js +8 -5
- package/examples/jsm/shaders/PoissonDenoiseShader.js +226 -0
- package/examples/jsm/shaders/SAOShader.js +7 -3
- package/examples/jsm/shaders/SMAAShader.js +6 -0
- package/examples/jsm/shaders/SSAOShader.js +8 -3
- package/examples/jsm/shaders/SSRShader.js +6 -0
- package/examples/jsm/shaders/SobelOperatorShader.js +2 -0
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +2 -0
- package/examples/jsm/shaders/TechnicolorShader.js +2 -0
- package/examples/jsm/shaders/TriangleBlurShader.js +2 -0
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -0
- package/examples/jsm/shaders/VelocityShader.js +2 -0
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +2 -0
- package/examples/jsm/transpiler/AST.js +270 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +941 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +49 -0
- package/examples/jsm/transpiler/TSLEncoder.js +715 -0
- package/examples/jsm/transpiler/Transpiler.js +18 -0
- package/examples/jsm/utils/SortUtils.js +158 -0
- package/examples/jsm/utils/TextureUtils.js +33 -21
- package/examples/jsm/webxr/ARButton.js +14 -0
- package/examples/jsm/webxr/VRButton.js +24 -9
- package/examples/jsm/webxr/XRButton.js +27 -11
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +8 -6
- package/src/Three.js +1 -0
- package/src/constants.js +8 -1
- package/src/core/BufferAttribute.js +21 -2
- package/src/core/InterleavedBuffer.js +21 -1
- package/src/core/Object3D.js +60 -12
- package/src/core/UniformsGroup.js +7 -1
- package/src/extras/PMREMGenerator.js +7 -1
- package/src/extras/curves/LineCurve3.js +4 -0
- package/src/loaders/AudioLoader.js +1 -1
- package/src/loaders/BufferGeometryLoader.js +0 -7
- package/src/loaders/ImageBitmapLoader.js +25 -1
- package/src/loaders/MaterialLoader.js +10 -2
- package/src/loaders/ObjectLoader.js +49 -0
- package/src/materials/Material.js +27 -13
- package/src/materials/ShaderMaterial.js +2 -1
- package/src/math/Box3.js +35 -18
- package/src/math/ColorManagement.js +0 -16
- package/src/math/Quaternion.js +5 -4
- package/src/math/Sphere.js +2 -0
- package/src/math/Triangle.js +17 -5
- package/src/math/Vector3.js +11 -12
- package/src/objects/BatchedMesh.js +1020 -0
- package/src/objects/Skeleton.js +1 -3
- package/src/objects/SkinnedMesh.js +6 -7
- package/src/renderers/WebGL3DRenderTarget.js +2 -2
- package/src/renderers/WebGLArrayRenderTarget.js +2 -2
- package/src/renderers/WebGLRenderer.js +165 -43
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -2
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +0 -5
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +31 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +9 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +8 -6
- package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +9 -17
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +84 -0
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk.js +4 -0
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +39 -5
- package/src/renderers/webgl/WebGLBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
- package/src/renderers/webgl/WebGLExtensions.js +1 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLLights.js +11 -2
- package/src/renderers/webgl/WebGLProgram.js +100 -51
- package/src/renderers/webgl/WebGLPrograms.js +8 -0
- package/src/renderers/webgl/WebGLShadowMap.js +35 -0
- package/src/renderers/webgl/WebGLState.js +25 -4
- package/src/renderers/webgl/WebGLTextures.js +7 -11
- package/src/renderers/webgl/WebGLUniforms.js +11 -1
- package/src/renderers/webgl/WebGLUniformsGroups.js +72 -93
- package/src/renderers/webxr/WebXRManager.js +16 -0
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +0 -76
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +0 -29
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { WebGLUniforms } from './WebGLUniforms.js';
|
|
2
2
|
import { WebGLShader } from './WebGLShader.js';
|
|
3
3
|
import { ShaderChunk } from '../shaders/ShaderChunk.js';
|
|
4
|
-
import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, ACESFilmicToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GLSL3, LinearSRGBColorSpace, SRGBColorSpace, LinearDisplayP3ColorSpace, DisplayP3ColorSpace, P3Primaries, Rec709Primaries } from '../../constants.js';
|
|
4
|
+
import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, AgXToneMapping, ACESFilmicToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GLSL3, LinearSRGBColorSpace, SRGBColorSpace, LinearDisplayP3ColorSpace, DisplayP3ColorSpace, P3Primaries, Rec709Primaries } from '../../constants.js';
|
|
5
5
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
6
6
|
|
|
7
|
+
// From https://www.khronos.org/registry/webgl/extensions/KHR_parallel_shader_compile/
|
|
8
|
+
const COMPLETION_STATUS_KHR = 0x91B1;
|
|
9
|
+
|
|
7
10
|
let programIdCount = 0;
|
|
8
11
|
|
|
9
12
|
function handleSource( string, errorLine ) {
|
|
@@ -117,6 +120,10 @@ function getToneMappingFunction( functionName, toneMapping ) {
|
|
|
117
120
|
toneMappingName = 'ACESFilmic';
|
|
118
121
|
break;
|
|
119
122
|
|
|
123
|
+
case AgXToneMapping:
|
|
124
|
+
toneMappingName = 'AgX';
|
|
125
|
+
break;
|
|
126
|
+
|
|
120
127
|
case CustomToneMapping:
|
|
121
128
|
toneMappingName = 'Custom';
|
|
122
129
|
break;
|
|
@@ -144,6 +151,16 @@ function generateExtensions( parameters ) {
|
|
|
144
151
|
|
|
145
152
|
}
|
|
146
153
|
|
|
154
|
+
function generateVertexExtensions( parameters ) {
|
|
155
|
+
|
|
156
|
+
const chunks = [
|
|
157
|
+
parameters.extensionClipCullDistance ? '#extension GL_ANGLE_clip_cull_distance : require' : ''
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
return chunks.filter( filterEmptyLine ).join( '\n' );
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
147
164
|
function generateDefines( defines ) {
|
|
148
165
|
|
|
149
166
|
const chunks = [];
|
|
@@ -448,6 +465,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
448
465
|
|
|
449
466
|
const customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters );
|
|
450
467
|
|
|
468
|
+
const customVertexExtensions = generateVertexExtensions( parameters );
|
|
469
|
+
|
|
451
470
|
const customDefines = generateDefines( defines );
|
|
452
471
|
|
|
453
472
|
const program = gl.createProgram();
|
|
@@ -502,6 +521,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
502
521
|
|
|
503
522
|
customDefines,
|
|
504
523
|
|
|
524
|
+
parameters.extensionClipCullDistance ? '#define USE_CLIP_DISTANCE' : '',
|
|
525
|
+
parameters.batching ? '#define USE_BATCHING' : '',
|
|
505
526
|
parameters.instancing ? '#define USE_INSTANCING' : '',
|
|
506
527
|
parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '',
|
|
507
528
|
|
|
@@ -841,6 +862,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
841
862
|
versionString = '#version 300 es\n';
|
|
842
863
|
|
|
843
864
|
prefixVertex = [
|
|
865
|
+
customVertexExtensions,
|
|
844
866
|
'precision mediump sampler2DArray;',
|
|
845
867
|
'#define attribute in',
|
|
846
868
|
'#define varying out',
|
|
@@ -848,6 +870,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
848
870
|
].join( '\n' ) + '\n' + prefixVertex;
|
|
849
871
|
|
|
850
872
|
prefixFragment = [
|
|
873
|
+
'precision mediump sampler2DArray;',
|
|
851
874
|
'#define varying in',
|
|
852
875
|
( parameters.glslVersion === GLSL3 ) ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;',
|
|
853
876
|
( parameters.glslVersion === GLSL3 ) ? '' : '#define gl_FragColor pc_fragColor',
|
|
@@ -939,87 +962,94 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
939
962
|
|
|
940
963
|
gl.linkProgram( program );
|
|
941
964
|
|
|
942
|
-
|
|
943
|
-
if ( renderer.debug.checkShaderErrors ) {
|
|
965
|
+
function onFirstUse( self ) {
|
|
944
966
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
const fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();
|
|
967
|
+
// check for link errors
|
|
968
|
+
if ( renderer.debug.checkShaderErrors ) {
|
|
948
969
|
|
|
949
|
-
|
|
950
|
-
|
|
970
|
+
const programLog = gl.getProgramInfoLog( program ).trim();
|
|
971
|
+
const vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();
|
|
972
|
+
const fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();
|
|
951
973
|
|
|
952
|
-
|
|
974
|
+
let runnable = true;
|
|
975
|
+
let haveDiagnostics = true;
|
|
953
976
|
|
|
954
|
-
|
|
977
|
+
if ( gl.getProgramParameter( program, gl.LINK_STATUS ) === false ) {
|
|
955
978
|
|
|
956
|
-
|
|
979
|
+
runnable = false;
|
|
957
980
|
|
|
958
|
-
renderer.debug.onShaderError
|
|
981
|
+
if ( typeof renderer.debug.onShaderError === 'function' ) {
|
|
959
982
|
|
|
960
|
-
|
|
983
|
+
renderer.debug.onShaderError( gl, program, glVertexShader, glFragmentShader );
|
|
961
984
|
|
|
962
|
-
|
|
985
|
+
} else {
|
|
963
986
|
|
|
964
|
-
|
|
965
|
-
const fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' );
|
|
987
|
+
// default error reporting
|
|
966
988
|
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
'VALIDATE_STATUS ' + gl.getProgramParameter( program, gl.VALIDATE_STATUS ) + '\n\n' +
|
|
970
|
-
'Program Info Log: ' + programLog + '\n' +
|
|
971
|
-
vertexErrors + '\n' +
|
|
972
|
-
fragmentErrors
|
|
973
|
-
);
|
|
989
|
+
const vertexErrors = getShaderErrors( gl, glVertexShader, 'vertex' );
|
|
990
|
+
const fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' );
|
|
974
991
|
|
|
975
|
-
|
|
992
|
+
console.error(
|
|
993
|
+
'THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' +
|
|
994
|
+
'VALIDATE_STATUS ' + gl.getProgramParameter( program, gl.VALIDATE_STATUS ) + '\n\n' +
|
|
995
|
+
'Program Info Log: ' + programLog + '\n' +
|
|
996
|
+
vertexErrors + '\n' +
|
|
997
|
+
fragmentErrors
|
|
998
|
+
);
|
|
999
|
+
|
|
1000
|
+
}
|
|
976
1001
|
|
|
977
|
-
|
|
1002
|
+
} else if ( programLog !== '' ) {
|
|
978
1003
|
|
|
979
|
-
|
|
1004
|
+
console.warn( 'THREE.WebGLProgram: Program Info Log:', programLog );
|
|
980
1005
|
|
|
981
|
-
|
|
1006
|
+
} else if ( vertexLog === '' || fragmentLog === '' ) {
|
|
982
1007
|
|
|
983
|
-
|
|
1008
|
+
haveDiagnostics = false;
|
|
984
1009
|
|
|
985
|
-
|
|
1010
|
+
}
|
|
986
1011
|
|
|
987
|
-
|
|
1012
|
+
if ( haveDiagnostics ) {
|
|
988
1013
|
|
|
989
|
-
|
|
1014
|
+
self.diagnostics = {
|
|
990
1015
|
|
|
991
|
-
|
|
1016
|
+
runnable: runnable,
|
|
992
1017
|
|
|
993
|
-
|
|
1018
|
+
programLog: programLog,
|
|
994
1019
|
|
|
995
|
-
|
|
1020
|
+
vertexShader: {
|
|
996
1021
|
|
|
997
|
-
|
|
998
|
-
|
|
1022
|
+
log: vertexLog,
|
|
1023
|
+
prefix: prefixVertex
|
|
999
1024
|
|
|
1000
|
-
|
|
1025
|
+
},
|
|
1001
1026
|
|
|
1002
|
-
|
|
1027
|
+
fragmentShader: {
|
|
1003
1028
|
|
|
1004
|
-
|
|
1005
|
-
|
|
1029
|
+
log: fragmentLog,
|
|
1030
|
+
prefix: prefixFragment
|
|
1006
1031
|
|
|
1007
|
-
|
|
1032
|
+
}
|
|
1008
1033
|
|
|
1009
|
-
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
}
|
|
1010
1037
|
|
|
1011
1038
|
}
|
|
1012
1039
|
|
|
1013
|
-
|
|
1040
|
+
// Clean up
|
|
1014
1041
|
|
|
1015
|
-
|
|
1042
|
+
// Crashes in iOS9 and iOS10. #18402
|
|
1043
|
+
// gl.detachShader( program, glVertexShader );
|
|
1044
|
+
// gl.detachShader( program, glFragmentShader );
|
|
1016
1045
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
// gl.detachShader( program, glFragmentShader );
|
|
1046
|
+
gl.deleteShader( glVertexShader );
|
|
1047
|
+
gl.deleteShader( glFragmentShader );
|
|
1020
1048
|
|
|
1021
|
-
|
|
1022
|
-
|
|
1049
|
+
cachedUniforms = new WebGLUniforms( gl, program );
|
|
1050
|
+
cachedAttributes = fetchAttributeLocations( gl, program );
|
|
1051
|
+
|
|
1052
|
+
}
|
|
1023
1053
|
|
|
1024
1054
|
// set up caching for uniform locations
|
|
1025
1055
|
|
|
@@ -1029,7 +1059,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
1029
1059
|
|
|
1030
1060
|
if ( cachedUniforms === undefined ) {
|
|
1031
1061
|
|
|
1032
|
-
|
|
1062
|
+
// Populates cachedUniforms and cachedAttributes
|
|
1063
|
+
onFirstUse( this );
|
|
1033
1064
|
|
|
1034
1065
|
}
|
|
1035
1066
|
|
|
@@ -1045,7 +1076,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
1045
1076
|
|
|
1046
1077
|
if ( cachedAttributes === undefined ) {
|
|
1047
1078
|
|
|
1048
|
-
|
|
1079
|
+
// Populates cachedAttributes and cachedUniforms
|
|
1080
|
+
onFirstUse( this );
|
|
1049
1081
|
|
|
1050
1082
|
}
|
|
1051
1083
|
|
|
@@ -1053,6 +1085,23 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
1053
1085
|
|
|
1054
1086
|
};
|
|
1055
1087
|
|
|
1088
|
+
// indicate when the program is ready to be used. if the KHR_parallel_shader_compile extension isn't supported,
|
|
1089
|
+
// flag the program as ready immediately. It may cause a stall when it's first used.
|
|
1090
|
+
|
|
1091
|
+
let programReady = ( parameters.rendererExtensionParallelShaderCompile === false );
|
|
1092
|
+
|
|
1093
|
+
this.isReady = function () {
|
|
1094
|
+
|
|
1095
|
+
if ( programReady === false ) {
|
|
1096
|
+
|
|
1097
|
+
programReady = gl.getProgramParameter( program, COMPLETION_STATUS_KHR );
|
|
1098
|
+
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
return programReady;
|
|
1102
|
+
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1056
1105
|
// free resource
|
|
1057
1106
|
|
|
1058
1107
|
this.destroy = function () {
|
|
@@ -110,6 +110,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
110
110
|
const numMultiviewViews = currentRenderTarget && currentRenderTarget.isWebGLMultiviewRenderTarget ? currentRenderTarget.numViews : 0;
|
|
111
111
|
|
|
112
112
|
const IS_INSTANCEDMESH = object.isInstancedMesh === true;
|
|
113
|
+
const IS_BATCHEDMESH = object.isBatchedMesh === true;
|
|
113
114
|
|
|
114
115
|
const HAS_MAP = !! material.map;
|
|
115
116
|
const HAS_MATCAP = !! material.matcap;
|
|
@@ -195,6 +196,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
195
196
|
|
|
196
197
|
precision: precision,
|
|
197
198
|
|
|
199
|
+
batching: IS_BATCHEDMESH,
|
|
198
200
|
instancing: IS_INSTANCEDMESH,
|
|
199
201
|
instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
|
|
200
202
|
|
|
@@ -357,10 +359,12 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
357
359
|
extensionFragDepth: HAS_EXTENSIONS && material.extensions.fragDepth === true,
|
|
358
360
|
extensionDrawBuffers: HAS_EXTENSIONS && material.extensions.drawBuffers === true,
|
|
359
361
|
extensionShaderTextureLOD: HAS_EXTENSIONS && material.extensions.shaderTextureLOD === true,
|
|
362
|
+
extensionClipCullDistance: HAS_EXTENSIONS && material.extensions.clipCullDistance && extensions.has( 'WEBGL_clip_cull_distance' ),
|
|
360
363
|
|
|
361
364
|
rendererExtensionFragDepth: IS_WEBGL2 || extensions.has( 'EXT_frag_depth' ),
|
|
362
365
|
rendererExtensionDrawBuffers: IS_WEBGL2 || extensions.has( 'WEBGL_draw_buffers' ),
|
|
363
366
|
rendererExtensionShaderTextureLod: IS_WEBGL2 || extensions.has( 'EXT_shader_texture_lod' ),
|
|
367
|
+
rendererExtensionParallelShaderCompile: extensions.has( 'KHR_parallel_shader_compile' ),
|
|
364
368
|
|
|
365
369
|
customProgramCacheKey: material.customProgramCacheKey()
|
|
366
370
|
|
|
@@ -503,6 +507,10 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
503
507
|
_programLayers.enable( 16 );
|
|
504
508
|
if ( parameters.anisotropy )
|
|
505
509
|
_programLayers.enable( 17 );
|
|
510
|
+
if ( parameters.alphaHash )
|
|
511
|
+
_programLayers.enable( 18 );
|
|
512
|
+
if ( parameters.batching )
|
|
513
|
+
_programLayers.enable( 19 );
|
|
506
514
|
|
|
507
515
|
array.push( _programLayers.mask );
|
|
508
516
|
_programLayers.disableAll();
|
|
@@ -279,6 +279,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
279
279
|
|
|
280
280
|
cachedMaterial = result.clone();
|
|
281
281
|
materialsForVariant[ keyB ] = cachedMaterial;
|
|
282
|
+
material.addEventListener( 'dispose', onMaterialDispose );
|
|
282
283
|
|
|
283
284
|
}
|
|
284
285
|
|
|
@@ -355,8 +356,12 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
355
356
|
|
|
356
357
|
const depthMaterial = getDepthMaterial( object, groupMaterial, light, type );
|
|
357
358
|
|
|
359
|
+
object.onBeforeShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
|
|
360
|
+
|
|
358
361
|
_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );
|
|
359
362
|
|
|
363
|
+
object.onAfterShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
|
|
364
|
+
|
|
360
365
|
}
|
|
361
366
|
|
|
362
367
|
}
|
|
@@ -365,8 +370,12 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
365
370
|
|
|
366
371
|
const depthMaterial = getDepthMaterial( object, material, light, type );
|
|
367
372
|
|
|
373
|
+
object.onBeforeShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
|
|
374
|
+
|
|
368
375
|
_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );
|
|
369
376
|
|
|
377
|
+
object.onAfterShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
|
|
378
|
+
|
|
370
379
|
}
|
|
371
380
|
|
|
372
381
|
}
|
|
@@ -383,6 +392,32 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
383
392
|
|
|
384
393
|
}
|
|
385
394
|
|
|
395
|
+
function onMaterialDispose( event ) {
|
|
396
|
+
|
|
397
|
+
const material = event.target;
|
|
398
|
+
|
|
399
|
+
material.removeEventListener( 'dispose', onMaterialDispose );
|
|
400
|
+
|
|
401
|
+
// make sure to remove the unique distance/depth materials used for shadow map rendering
|
|
402
|
+
|
|
403
|
+
for ( const id in _materialCache ) {
|
|
404
|
+
|
|
405
|
+
const cache = _materialCache[ id ];
|
|
406
|
+
|
|
407
|
+
const uuid = event.target.uuid;
|
|
408
|
+
|
|
409
|
+
if ( uuid in cache ) {
|
|
410
|
+
|
|
411
|
+
const shadowMaterial = cache[ uuid ];
|
|
412
|
+
shadowMaterial.dispose();
|
|
413
|
+
delete cache[ uuid ];
|
|
414
|
+
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
}
|
|
420
|
+
|
|
386
421
|
}
|
|
387
422
|
|
|
388
423
|
|
|
@@ -1,4 +1,5 @@
|
|
|
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 } from '../../constants.js';
|
|
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
|
+
import { Color } from '../../math/Color.js';
|
|
2
3
|
import { Vector4 } from '../../math/Vector4.js';
|
|
3
4
|
|
|
4
5
|
function WebGLState( gl, extensions, capabilities ) {
|
|
@@ -325,6 +326,8 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
325
326
|
let currentBlendEquationAlpha = null;
|
|
326
327
|
let currentBlendSrcAlpha = null;
|
|
327
328
|
let currentBlendDstAlpha = null;
|
|
329
|
+
let currentBlendColor = new Color( 0, 0, 0 );
|
|
330
|
+
let currentBlendAlpha = 0;
|
|
328
331
|
let currentPremultipledAlpha = false;
|
|
329
332
|
|
|
330
333
|
let currentFlipSided = null;
|
|
@@ -600,10 +603,14 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
600
603
|
[ OneMinusSrcColorFactor ]: gl.ONE_MINUS_SRC_COLOR,
|
|
601
604
|
[ OneMinusSrcAlphaFactor ]: gl.ONE_MINUS_SRC_ALPHA,
|
|
602
605
|
[ OneMinusDstColorFactor ]: gl.ONE_MINUS_DST_COLOR,
|
|
603
|
-
[ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA
|
|
606
|
+
[ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA,
|
|
607
|
+
[ ConstantColorFactor ]: gl.CONSTANT_COLOR,
|
|
608
|
+
[ OneMinusConstantColorFactor ]: gl.ONE_MINUS_CONSTANT_COLOR,
|
|
609
|
+
[ ConstantAlphaFactor ]: gl.CONSTANT_ALPHA,
|
|
610
|
+
[ OneMinusConstantAlphaFactor ]: gl.ONE_MINUS_CONSTANT_ALPHA
|
|
604
611
|
};
|
|
605
612
|
|
|
606
|
-
function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) {
|
|
613
|
+
function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, blendColor, blendAlpha, premultipliedAlpha ) {
|
|
607
614
|
|
|
608
615
|
if ( blending === NoBlending ) {
|
|
609
616
|
|
|
@@ -696,6 +703,8 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
696
703
|
currentBlendDst = null;
|
|
697
704
|
currentBlendSrcAlpha = null;
|
|
698
705
|
currentBlendDstAlpha = null;
|
|
706
|
+
currentBlendColor.set( 0, 0, 0 );
|
|
707
|
+
currentBlendAlpha = 0;
|
|
699
708
|
|
|
700
709
|
currentBlending = blending;
|
|
701
710
|
currentPremultipledAlpha = premultipliedAlpha;
|
|
@@ -732,6 +741,15 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
732
741
|
|
|
733
742
|
}
|
|
734
743
|
|
|
744
|
+
if ( blendColor.equals( currentBlendColor ) === false || blendAlpha !== currentBlendAlpha ) {
|
|
745
|
+
|
|
746
|
+
gl.blendColor( blendColor.r, blendColor.g, blendColor.b, blendAlpha );
|
|
747
|
+
|
|
748
|
+
currentBlendColor.copy( blendColor );
|
|
749
|
+
currentBlendAlpha = blendAlpha;
|
|
750
|
+
|
|
751
|
+
}
|
|
752
|
+
|
|
735
753
|
currentBlending = blending;
|
|
736
754
|
currentPremultipledAlpha = false;
|
|
737
755
|
|
|
@@ -750,7 +768,7 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
750
768
|
|
|
751
769
|
( material.blending === NormalBlending && material.transparent === false )
|
|
752
770
|
? setBlending( NoBlending )
|
|
753
|
-
: setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha );
|
|
771
|
+
: setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.blendColor, material.blendAlpha, material.premultipliedAlpha );
|
|
754
772
|
|
|
755
773
|
depthBuffer.setFunc( material.depthFunc );
|
|
756
774
|
depthBuffer.setTest( material.depthTest );
|
|
@@ -1174,6 +1192,7 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
1174
1192
|
gl.blendEquation( gl.FUNC_ADD );
|
|
1175
1193
|
gl.blendFunc( gl.ONE, gl.ZERO );
|
|
1176
1194
|
gl.blendFuncSeparate( gl.ONE, gl.ZERO, gl.ONE, gl.ZERO );
|
|
1195
|
+
gl.blendColor( 0, 0, 0, 0 );
|
|
1177
1196
|
|
|
1178
1197
|
gl.colorMask( true, true, true, true );
|
|
1179
1198
|
gl.clearColor( 0, 0, 0, 0 );
|
|
@@ -1231,6 +1250,8 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
1231
1250
|
currentBlendEquationAlpha = null;
|
|
1232
1251
|
currentBlendSrcAlpha = null;
|
|
1233
1252
|
currentBlendDstAlpha = null;
|
|
1253
|
+
currentBlendColor = new Color( 0, 0, 0 );
|
|
1254
|
+
currentBlendAlpha = 0;
|
|
1234
1255
|
currentPremultipledAlpha = false;
|
|
1235
1256
|
|
|
1236
1257
|
currentFlipSided = null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, SRGBTransfer, LinearTransfer } from '../../constants.js';
|
|
1
|
+
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, RGB_ETC1_Format, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, SRGBTransfer, LinearTransfer } from '../../constants.js';
|
|
2
2
|
import * as MathUtils from '../../math/MathUtils.js';
|
|
3
3
|
import { ImageUtils } from '../../extras/ImageUtils.js';
|
|
4
4
|
import { createElementNS } from '../../utils.js';
|
|
@@ -7,10 +7,6 @@ import { ColorManagement } from '../../math/ColorManagement.js';
|
|
|
7
7
|
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
|
|
8
8
|
|
|
9
9
|
const isWebGL2 = capabilities.isWebGL2;
|
|
10
|
-
const maxTextures = capabilities.maxTextures;
|
|
11
|
-
const maxCubemapSize = capabilities.maxCubemapSize;
|
|
12
|
-
const maxTextureSize = capabilities.maxTextureSize;
|
|
13
|
-
const maxSamples = capabilities.maxSamples;
|
|
14
10
|
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
|
|
15
11
|
const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
|
|
16
12
|
const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
|
|
@@ -433,9 +429,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
433
429
|
|
|
434
430
|
const textureUnit = textureUnits;
|
|
435
431
|
|
|
436
|
-
if ( textureUnit >= maxTextures ) {
|
|
432
|
+
if ( textureUnit >= capabilities.maxTextures ) {
|
|
437
433
|
|
|
438
|
-
console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures );
|
|
434
|
+
console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
|
|
439
435
|
|
|
440
436
|
}
|
|
441
437
|
|
|
@@ -792,7 +788,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
792
788
|
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
793
789
|
|
|
794
790
|
const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false;
|
|
795
|
-
let image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );
|
|
791
|
+
let image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
|
|
796
792
|
image = verifyColorSpace( texture, image );
|
|
797
793
|
|
|
798
794
|
const supportsMips = isPowerOfTwo( image ) || isWebGL2,
|
|
@@ -806,7 +802,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
806
802
|
let mipmap;
|
|
807
803
|
const mipmaps = texture.mipmaps;
|
|
808
804
|
|
|
809
|
-
const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
|
|
805
|
+
const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
|
|
810
806
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
811
807
|
const levels = getMipLevels( texture, image, supportsMips );
|
|
812
808
|
|
|
@@ -1219,7 +1215,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1219
1215
|
|
|
1220
1216
|
if ( ! isCompressed && ! isDataTexture ) {
|
|
1221
1217
|
|
|
1222
|
-
cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize );
|
|
1218
|
+
cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize );
|
|
1223
1219
|
|
|
1224
1220
|
} else {
|
|
1225
1221
|
|
|
@@ -2178,7 +2174,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2178
2174
|
|
|
2179
2175
|
function getRenderTargetSamples( renderTarget ) {
|
|
2180
2176
|
|
|
2181
|
-
return Math.min( maxSamples, renderTarget.samples );
|
|
2177
|
+
return Math.min( capabilities.maxSamples, renderTarget.samples );
|
|
2182
2178
|
|
|
2183
2179
|
}
|
|
2184
2180
|
|
|
@@ -45,8 +45,14 @@ import { CubeTexture } from '../../textures/CubeTexture.js';
|
|
|
45
45
|
import { Texture } from '../../textures/Texture.js';
|
|
46
46
|
import { DataArrayTexture } from '../../textures/DataArrayTexture.js';
|
|
47
47
|
import { Data3DTexture } from '../../textures/Data3DTexture.js';
|
|
48
|
+
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
49
|
+
import { LessEqualCompare } from '../../constants.js';
|
|
48
50
|
|
|
49
51
|
const emptyTexture = /*@__PURE__*/ new Texture();
|
|
52
|
+
|
|
53
|
+
const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 );
|
|
54
|
+
emptyShadowTexture.compareFunction = LessEqualCompare;
|
|
55
|
+
|
|
50
56
|
const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
|
|
51
57
|
const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
|
|
52
58
|
const emptyCubeTexture = /*@__PURE__*/ new CubeTexture();
|
|
@@ -563,7 +569,9 @@ function setValueT1( gl, v, textures ) {
|
|
|
563
569
|
|
|
564
570
|
}
|
|
565
571
|
|
|
566
|
-
|
|
572
|
+
const emptyTexture2D = ( this.type === gl.SAMPLER_2D_SHADOW ) ? emptyShadowTexture : emptyTexture;
|
|
573
|
+
|
|
574
|
+
textures.setTexture2D( v || emptyTexture2D, unit );
|
|
567
575
|
|
|
568
576
|
}
|
|
569
577
|
|
|
@@ -947,6 +955,7 @@ class SingleUniform {
|
|
|
947
955
|
this.id = id;
|
|
948
956
|
this.addr = addr;
|
|
949
957
|
this.cache = [];
|
|
958
|
+
this.type = activeInfo.type;
|
|
950
959
|
this.setValue = getSingularSetter( activeInfo.type );
|
|
951
960
|
|
|
952
961
|
// this.path = activeInfo.name; // DEBUG
|
|
@@ -962,6 +971,7 @@ class PureArrayUniform {
|
|
|
962
971
|
this.id = id;
|
|
963
972
|
this.addr = addr;
|
|
964
973
|
this.cache = [];
|
|
974
|
+
this.type = activeInfo.type;
|
|
965
975
|
this.size = activeInfo.size;
|
|
966
976
|
this.setValue = getPureArraySetter( activeInfo.type );
|
|
967
977
|
|