@plastic-software/three 0.183.3 → 0.184.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +783 -290
- package/build/three.core.js +372 -110
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +436 -184
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +7 -1
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +2979 -1281
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2942 -1281
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +11 -0
- package/examples/jsm/animation/CCDIKSolver.js +5 -1
- package/examples/jsm/controls/ArcballControls.js +4 -1
- package/examples/jsm/controls/DragControls.js +2 -2
- package/examples/jsm/controls/FirstPersonControls.js +58 -54
- package/examples/jsm/controls/FlyControls.js +4 -0
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/TrackballControls.js +2 -2
- package/examples/jsm/controls/TransformControls.js +34 -2
- package/examples/jsm/csm/CSMShadowNode.js +6 -2
- package/examples/jsm/exporters/GLTFExporter.js +21 -5
- package/examples/jsm/geometries/TextGeometry.js +18 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
- package/examples/jsm/inspector/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +169 -114
- package/examples/jsm/inspector/RendererInspector.js +2 -2
- package/examples/jsm/inspector/extensions/extensions.json +6 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Memory.js +128 -0
- package/examples/jsm/inspector/tabs/Parameters.js +34 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Settings.js +264 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
- package/examples/jsm/inspector/tabs/Viewer.js +105 -3
- package/examples/jsm/inspector/ui/Graph.js +2 -2
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +273 -176
- package/examples/jsm/inspector/ui/Style.js +64 -10
- package/examples/jsm/inspector/ui/Tab.js +39 -7
- package/examples/jsm/inspector/ui/Values.js +39 -2
- package/examples/jsm/inspector/ui/utils.js +13 -0
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +8 -8
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +651 -0
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +682 -43
- package/examples/jsm/loaders/FBXLoader.js +233 -33
- package/examples/jsm/loaders/GLTFLoader.js +24 -7
- package/examples/jsm/loaders/HDRLoader.js +1 -1
- package/examples/jsm/loaders/KTX2Loader.js +8 -2
- package/examples/jsm/loaders/LDrawLoader.js +39 -47
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/VTKLoader.js +5 -1
- package/examples/jsm/loaders/collada/ColladaComposer.js +101 -7
- package/examples/jsm/loaders/collada/ColladaParser.js +19 -4
- package/examples/jsm/loaders/usd/USDAParser.js +6 -0
- package/examples/jsm/loaders/usd/USDCParser.js +26 -0
- package/examples/jsm/loaders/usd/USDComposer.js +656 -103
- package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +42 -4
- package/examples/jsm/modifiers/TessellateModifier.js +1 -1
- package/examples/jsm/objects/Reflector.js +73 -25
- package/examples/jsm/objects/Sky.js +14 -2
- package/examples/jsm/objects/SkyMesh.js +23 -6
- package/examples/jsm/renderers/Projector.js +18 -38
- package/examples/jsm/renderers/SVGRenderer.js +6 -25
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +10 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +11 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +10 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
- package/examples/jsm/tsl/display/FSR1Node.js +477 -0
- package/examples/jsm/tsl/display/GTAONode.js +2 -1
- package/examples/jsm/tsl/display/GaussianBlurNode.js +10 -0
- package/examples/jsm/tsl/display/GodraysNode.js +2 -11
- package/examples/jsm/tsl/display/OutlineNode.js +66 -16
- package/examples/jsm/tsl/display/SSGINode.js +0 -4
- package/examples/jsm/tsl/display/SharpenNode.js +283 -0
- package/examples/jsm/tsl/display/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +48 -7
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +13 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -3
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/SkeletonUtils.js +14 -8
- package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
- package/package.json +4 -4
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +6 -0
- package/src/Three.WebGPU.Nodes.js +3 -0
- package/src/Three.WebGPU.js +6 -0
- package/src/animation/AnimationAction.js +11 -1
- package/src/audio/AudioContext.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +13 -1
- package/src/core/Clock.js +1 -1
- package/src/core/Object3D.js +1 -5
- package/src/core/RenderTarget.js +1 -0
- package/src/extras/PMREMGenerator.js +1 -1
- package/src/extras/curves/CatmullRomCurve3.js +3 -2
- package/src/loaders/AudioLoader.js +11 -1
- package/src/loaders/DataTextureLoader.js +6 -4
- package/src/loaders/FileLoader.js +1 -2
- package/src/loaders/ImageBitmapLoader.js +4 -6
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +25 -4
- package/src/loaders/nodes/NodeObjectLoader.js +18 -0
- package/src/materials/MeshToonMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +27 -0
- package/src/materials/nodes/NodeMaterial.js +0 -27
- package/src/materials/nodes/manager/NodeMaterialObserver.js +188 -89
- package/src/math/Line3.js +3 -0
- package/src/math/Matrix2.js +13 -9
- package/src/math/Matrix3.js +13 -9
- package/src/math/Matrix4.js +13 -9
- package/src/math/Plane.js +4 -3
- package/src/math/Triangle.js +1 -1
- package/src/math/Vector2.js +11 -7
- package/src/math/Vector3.js +12 -8
- package/src/math/Vector4.js +13 -9
- package/src/nodes/Nodes.js +0 -1
- package/src/nodes/TSL.js +1 -1
- package/src/nodes/accessors/BufferAttributeNode.js +9 -3
- package/src/nodes/accessors/CubeTextureNode.js +7 -1
- package/src/nodes/accessors/MaterialProperties.js +2 -5
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/SceneProperties.js +2 -8
- package/src/nodes/accessors/StorageBufferNode.js +10 -4
- package/src/nodes/accessors/StorageTextureNode.js +4 -9
- package/src/nodes/accessors/TextureNode.js +10 -2
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/code/FunctionCallNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +1 -1
- package/src/nodes/core/ArrayNode.js +1 -1
- package/src/nodes/core/AssignNode.js +1 -1
- package/src/nodes/core/AttributeNode.js +1 -1
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/ContextNode.js +1 -1
- package/src/nodes/core/IndexNode.js +2 -1
- package/src/nodes/core/InputNode.js +1 -1
- package/src/nodes/core/InspectorNode.js +1 -1
- package/src/nodes/core/IsolateNode.js +1 -1
- package/src/nodes/core/Node.js +83 -12
- package/src/nodes/core/NodeBuilder.js +117 -16
- package/src/nodes/core/NodeUtils.js +1 -1
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/ParameterNode.js +1 -1
- package/src/nodes/core/StackNode.js +1 -1
- package/src/nodes/core/StructNode.js +1 -1
- package/src/nodes/core/StructTypeNode.js +1 -1
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformGroupNode.js +36 -6
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -1
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +27 -7
- package/src/nodes/display/RenderOutputNode.js +4 -4
- package/src/nodes/display/ScreenNode.js +1 -1
- package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
- package/src/nodes/display/ViewportTextureNode.js +18 -7
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/geometry/RangeNode.js +1 -1
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/BarrierNode.js +9 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +69 -44
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/lighting/LightsNode.js +6 -27
- package/src/nodes/lighting/ShadowNode.js +24 -2
- package/src/nodes/math/BitcastNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +1 -1
- package/src/nodes/math/MathNode.js +73 -1
- package/src/nodes/math/OperatorNode.js +1 -1
- package/src/nodes/math/PackFloatNode.js +1 -1
- package/src/nodes/math/UnpackFloatNode.js +1 -1
- package/src/nodes/tsl/TSLBase.js +1 -1
- package/src/nodes/tsl/TSLCore.js +21 -3
- package/src/nodes/utils/ArrayElementNode.js +1 -1
- package/src/nodes/utils/ConvertNode.js +1 -1
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +30 -0
- package/src/nodes/utils/FlipNode.js +1 -1
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/JoinNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SetNode.js +1 -1
- package/src/nodes/utils/SplitNode.js +1 -1
- package/src/objects/BatchedMesh.js +17 -2
- package/src/objects/InstancedMesh.js +19 -3
- package/src/objects/SkinnedMesh.js +26 -9
- package/src/renderers/WebGLRenderer.js +148 -49
- package/src/renderers/common/Animation.js +3 -3
- package/src/renderers/common/Attributes.js +15 -1
- package/src/renderers/common/Backend.js +0 -8
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/BindGroup.js +1 -8
- package/src/renderers/common/Bindings.js +2 -2
- package/src/renderers/common/ComputePipeline.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/Info.js +333 -4
- package/src/renderers/common/InspectorBase.js +6 -1
- package/src/renderers/common/Pipelines.js +36 -3
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +3 -1
- package/src/renderers/common/RenderBundles.js +5 -2
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/RenderObjects.js +3 -3
- package/src/renderers/common/RenderPipeline.js +35 -6
- package/src/renderers/common/Renderer.js +232 -53
- package/src/renderers/common/Textures.js +72 -3
- package/src/renderers/common/UniformsGroup.js +1 -1
- package/src/renderers/common/XRManager.js +34 -27
- package/src/renderers/common/extras/PMREMGenerator.js +23 -15
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeManager.js +230 -99
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +2 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -3
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib.js +0 -1
- package/src/renderers/shaders/UniformsLib.js +7 -2
- package/src/renderers/shaders/UniformsUtils.js +27 -5
- package/src/renderers/webgl/WebGLAnimation.js +2 -1
- package/src/renderers/webgl/WebGLBackground.js +13 -13
- package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLCapabilities.js +6 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLMaterials.js +12 -13
- package/src/renderers/webgl/WebGLOutput.js +4 -1
- package/src/renderers/webgl/WebGLProgram.js +5 -0
- package/src/renderers/webgl/WebGLPrograms.js +24 -3
- package/src/renderers/webgl/WebGLRenderStates.js +13 -2
- package/src/renderers/webgl/WebGLState.js +43 -0
- package/src/renderers/webgl/WebGLTextures.js +129 -26
- package/src/renderers/webgl/WebGLUniformsGroups.js +19 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +106 -65
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +29 -51
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +42 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +63 -50
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +160 -146
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +55 -33
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +103 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +8 -0
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +91 -17
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -2
- package/src/renderers/webxr/WebXRController.js +12 -0
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +13 -2
- package/src/utils.js +23 -1
- package/src/nodes/utils/RemapNode.js +0 -125
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BackSide, DoubleSide, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, NormalBlending,
|
|
1
|
+
import { BackSide, DoubleSide, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, NormalBlending, SRGBTransfer, UVMapping, RGFormat, RG11_EAC_Format, RED_GREEN_RGTC2_Format } from '../../constants.js';
|
|
2
2
|
import { Layers } from '../../core/Layers.js';
|
|
3
3
|
import { WebGLProgram } from './WebGLProgram.js';
|
|
4
4
|
import { WebGLShaderCache } from './WebGLShaderCache.js';
|
|
@@ -7,6 +7,12 @@ import { UniformsUtils } from '../shaders/UniformsUtils.js';
|
|
|
7
7
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
8
8
|
import { warn } from '../../utils.js';
|
|
9
9
|
|
|
10
|
+
function isPackedRGFormat( format ) {
|
|
11
|
+
|
|
12
|
+
return format === RGFormat || format === RG11_EAC_Format || format === RED_GREEN_RGTC2_Format;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
function WebGLPrograms( renderer, environments, extensions, capabilities, bindingStates, clipping ) {
|
|
11
17
|
|
|
12
18
|
const _programLayers = new Layers();
|
|
@@ -47,7 +53,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
47
53
|
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
function getParameters( material, lights, shadows, scene, object ) {
|
|
56
|
+
function getParameters( material, lights, shadows, scene, object, lightProbeGrids ) {
|
|
51
57
|
|
|
52
58
|
const fog = scene.fog;
|
|
53
59
|
const geometry = object.geometry;
|
|
@@ -162,6 +168,8 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
162
168
|
|
|
163
169
|
const HAS_ALPHAHASH = !! material.alphaHash;
|
|
164
170
|
|
|
171
|
+
const HAS_OCTAHEDRAL_NORMALS = object.geometry.attributes.normalOctahedral !== undefined;
|
|
172
|
+
|
|
165
173
|
const HAS_EXTENSIONS = !! material.extensions;
|
|
166
174
|
|
|
167
175
|
let toneMapping = NoToneMapping;
|
|
@@ -197,11 +205,12 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
197
205
|
batching: IS_BATCHEDMESH,
|
|
198
206
|
batchingMatrix: IS_BATCHEDMESH && object._matricesTexture !== null,
|
|
199
207
|
batchingColor: IS_BATCHEDMESH && object._colorsTexture !== null,
|
|
208
|
+
normalOctahedral: HAS_OCTAHEDRAL_NORMALS,
|
|
200
209
|
instancing: IS_INSTANCEDMESH,
|
|
201
210
|
instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
|
|
202
211
|
instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
|
|
203
212
|
|
|
204
|
-
outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace :
|
|
213
|
+
outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace ),
|
|
205
214
|
alphaToCoverage: !! material.alphaToCoverage,
|
|
206
215
|
|
|
207
216
|
map: HAS_MAP,
|
|
@@ -218,6 +227,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
218
227
|
|
|
219
228
|
normalMapObjectSpace: HAS_NORMALMAP && material.normalMapType === ObjectSpaceNormalMap,
|
|
220
229
|
normalMapTangentSpace: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap,
|
|
230
|
+
packedNormalMap: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap && isPackedRGFormat( material.normalMap.format ),
|
|
221
231
|
|
|
222
232
|
metalnessMap: HAS_METALNESSMAP,
|
|
223
233
|
roughnessMap: HAS_ROUGHNESSMAP,
|
|
@@ -302,6 +312,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
302
312
|
//
|
|
303
313
|
|
|
304
314
|
vertexTangents: !! geometry.attributes.tangent && ( HAS_NORMALMAP || HAS_ANISOTROPY ),
|
|
315
|
+
vertexNormals: !! geometry.attributes.normal,
|
|
305
316
|
vertexColors: material.vertexColors,
|
|
306
317
|
vertexAlphas: material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4,
|
|
307
318
|
|
|
@@ -344,6 +355,8 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
344
355
|
|
|
345
356
|
numLightProbes: lights.numLightProbes,
|
|
346
357
|
|
|
358
|
+
numLightProbeGrids: lightProbeGrids.length,
|
|
359
|
+
|
|
347
360
|
numClippingPlanes: clipping.numPlanes,
|
|
348
361
|
numClipIntersection: clipping.numIntersection,
|
|
349
362
|
|
|
@@ -538,6 +551,12 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
538
551
|
_programLayers.enable( 21 );
|
|
539
552
|
if ( parameters.batchingMatrix )
|
|
540
553
|
_programLayers.enable( 22 );
|
|
554
|
+
if ( parameters.normalOctahedral )
|
|
555
|
+
_programLayers.enable( 23 );
|
|
556
|
+
if ( parameters.packedNormalMap )
|
|
557
|
+
_programLayers.enable( 24 );
|
|
558
|
+
if ( parameters.vertexNormals )
|
|
559
|
+
_programLayers.enable( 25 );
|
|
541
560
|
|
|
542
561
|
array.push( _programLayers.mask );
|
|
543
562
|
_programLayers.disableAll();
|
|
@@ -586,6 +605,8 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
586
605
|
_programLayers.enable( 20 );
|
|
587
606
|
if ( parameters.alphaToCoverage )
|
|
588
607
|
_programLayers.enable( 21 );
|
|
608
|
+
if ( parameters.numLightProbeGrids > 0 )
|
|
609
|
+
_programLayers.enable( 22 );
|
|
589
610
|
|
|
590
611
|
array.push( _programLayers.mask );
|
|
591
612
|
|
|
@@ -6,6 +6,7 @@ function WebGLRenderState( extensions ) {
|
|
|
6
6
|
|
|
7
7
|
const lightsArray = [];
|
|
8
8
|
const shadowsArray = [];
|
|
9
|
+
const lightProbeGridArray = [];
|
|
9
10
|
|
|
10
11
|
function init( camera ) {
|
|
11
12
|
|
|
@@ -13,6 +14,7 @@ function WebGLRenderState( extensions ) {
|
|
|
13
14
|
|
|
14
15
|
lightsArray.length = 0;
|
|
15
16
|
shadowsArray.length = 0;
|
|
17
|
+
lightProbeGridArray.length = 0;
|
|
16
18
|
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -28,6 +30,12 @@ function WebGLRenderState( extensions ) {
|
|
|
28
30
|
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
function pushLightProbeGrid( volume ) {
|
|
34
|
+
|
|
35
|
+
lightProbeGridArray.push( volume );
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
function setupLights() {
|
|
32
40
|
|
|
33
41
|
lights.setup( lightsArray );
|
|
@@ -43,12 +51,14 @@ function WebGLRenderState( extensions ) {
|
|
|
43
51
|
const state = {
|
|
44
52
|
lightsArray: lightsArray,
|
|
45
53
|
shadowsArray: shadowsArray,
|
|
54
|
+
lightProbeGridArray: lightProbeGridArray,
|
|
46
55
|
|
|
47
56
|
camera: null,
|
|
48
57
|
|
|
49
58
|
lights: lights,
|
|
50
59
|
|
|
51
|
-
transmissionRenderTarget: {}
|
|
60
|
+
transmissionRenderTarget: {},
|
|
61
|
+
textureUnits: 0
|
|
52
62
|
};
|
|
53
63
|
|
|
54
64
|
return {
|
|
@@ -58,7 +68,8 @@ function WebGLRenderState( extensions ) {
|
|
|
58
68
|
setupLightsView: setupLightsView,
|
|
59
69
|
|
|
60
70
|
pushLight: pushLight,
|
|
61
|
-
pushShadow: pushShadow
|
|
71
|
+
pushShadow: pushShadow,
|
|
72
|
+
pushLightProbeGrid: pushLightProbeGrid
|
|
62
73
|
};
|
|
63
74
|
|
|
64
75
|
}
|
|
@@ -353,6 +353,7 @@ function WebGLState( gl, extensions ) {
|
|
|
353
353
|
const uboProgramMap = new WeakMap();
|
|
354
354
|
|
|
355
355
|
let enabledCapabilities = {};
|
|
356
|
+
let parameters = {};
|
|
356
357
|
|
|
357
358
|
let currentBoundFramebuffers = {};
|
|
358
359
|
let currentDrawbuffers = new WeakMap();
|
|
@@ -1112,6 +1113,31 @@ function WebGLState( gl, extensions ) {
|
|
|
1112
1113
|
|
|
1113
1114
|
}
|
|
1114
1115
|
|
|
1116
|
+
function getParameter( name ) {
|
|
1117
|
+
|
|
1118
|
+
if ( parameters[ name ] !== undefined ) {
|
|
1119
|
+
|
|
1120
|
+
return parameters[ name ];
|
|
1121
|
+
|
|
1122
|
+
} else {
|
|
1123
|
+
|
|
1124
|
+
return gl.getParameter( name );
|
|
1125
|
+
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
function pixelStorei( name, value ) {
|
|
1131
|
+
|
|
1132
|
+
if ( parameters[ name ] !== value ) {
|
|
1133
|
+
|
|
1134
|
+
gl.pixelStorei( name, value );
|
|
1135
|
+
parameters[ name ] = value;
|
|
1136
|
+
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1115
1141
|
//
|
|
1116
1142
|
|
|
1117
1143
|
function scissor( scissor ) {
|
|
@@ -1228,9 +1254,24 @@ function WebGLState( gl, extensions ) {
|
|
|
1228
1254
|
gl.scissor( 0, 0, gl.canvas.width, gl.canvas.height );
|
|
1229
1255
|
gl.viewport( 0, 0, gl.canvas.width, gl.canvas.height );
|
|
1230
1256
|
|
|
1257
|
+
gl.pixelStorei( gl.PACK_ALIGNMENT, 4 );
|
|
1258
|
+
gl.pixelStorei( gl.UNPACK_ALIGNMENT, 4 );
|
|
1259
|
+
gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, false );
|
|
1260
|
+
gl.pixelStorei( gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false );
|
|
1261
|
+
gl.pixelStorei( gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.BROWSER_DEFAULT_WEBGL );
|
|
1262
|
+
gl.pixelStorei( gl.PACK_ROW_LENGTH, 0 );
|
|
1263
|
+
gl.pixelStorei( gl.PACK_SKIP_PIXELS, 0 );
|
|
1264
|
+
gl.pixelStorei( gl.PACK_SKIP_ROWS, 0 );
|
|
1265
|
+
gl.pixelStorei( gl.UNPACK_ROW_LENGTH, 0 );
|
|
1266
|
+
gl.pixelStorei( gl.UNPACK_IMAGE_HEIGHT, 0 );
|
|
1267
|
+
gl.pixelStorei( gl.UNPACK_SKIP_PIXELS, 0 );
|
|
1268
|
+
gl.pixelStorei( gl.UNPACK_SKIP_ROWS, 0 );
|
|
1269
|
+
gl.pixelStorei( gl.UNPACK_SKIP_IMAGES, 0 );
|
|
1270
|
+
|
|
1231
1271
|
// reset internals
|
|
1232
1272
|
|
|
1233
1273
|
enabledCapabilities = {};
|
|
1274
|
+
parameters = {};
|
|
1234
1275
|
|
|
1235
1276
|
currentTextureSlot = null;
|
|
1236
1277
|
currentBoundTextures = {};
|
|
@@ -1304,6 +1345,8 @@ function WebGLState( gl, extensions ) {
|
|
|
1304
1345
|
compressedTexImage3D: compressedTexImage3D,
|
|
1305
1346
|
texImage2D: texImage2D,
|
|
1306
1347
|
texImage3D: texImage3D,
|
|
1348
|
+
pixelStorei: pixelStorei,
|
|
1349
|
+
getParameter: getParameter,
|
|
1307
1350
|
|
|
1308
1351
|
updateUBOMapping: updateUBOMapping,
|
|
1309
1352
|
uniformBlockBinding: uniformBlockBinding,
|
|
@@ -11,6 +11,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
11
11
|
|
|
12
12
|
const _imageDimensions = new Vector2();
|
|
13
13
|
const _videoTextures = new WeakMap();
|
|
14
|
+
const _htmlTextures = new Set();
|
|
14
15
|
let _canvas;
|
|
15
16
|
|
|
16
17
|
const _sources = new WeakMap(); // maps WebglTexture objects to instances of Source
|
|
@@ -125,7 +126,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
125
126
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
|
|
129
|
+
function getInternalFormat( internalFormatName, glFormat, glType, normalized, colorSpace, forceLinearTransfer = false ) {
|
|
129
130
|
|
|
130
131
|
if ( internalFormatName !== null ) {
|
|
131
132
|
|
|
@@ -135,6 +136,20 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
135
136
|
|
|
136
137
|
}
|
|
137
138
|
|
|
139
|
+
let ext_texture_norm16;
|
|
140
|
+
|
|
141
|
+
if ( normalized ) {
|
|
142
|
+
|
|
143
|
+
ext_texture_norm16 = extensions.get( 'EXT_texture_norm16' );
|
|
144
|
+
|
|
145
|
+
if ( ! ext_texture_norm16 ) {
|
|
146
|
+
|
|
147
|
+
warn( 'WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension' );
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
138
153
|
let internalFormat = glFormat;
|
|
139
154
|
|
|
140
155
|
if ( glFormat === _gl.RED ) {
|
|
@@ -142,6 +157,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
142
157
|
if ( glType === _gl.FLOAT ) internalFormat = _gl.R32F;
|
|
143
158
|
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.R16F;
|
|
144
159
|
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.R8;
|
|
160
|
+
if ( glType === _gl.UNSIGNED_SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.R16_EXT;
|
|
161
|
+
if ( glType === _gl.SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.R16_SNORM_EXT;
|
|
145
162
|
|
|
146
163
|
}
|
|
147
164
|
|
|
@@ -161,6 +178,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
161
178
|
if ( glType === _gl.FLOAT ) internalFormat = _gl.RG32F;
|
|
162
179
|
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RG16F;
|
|
163
180
|
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RG8;
|
|
181
|
+
if ( glType === _gl.UNSIGNED_SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RG16_EXT;
|
|
182
|
+
if ( glType === _gl.SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RG16_SNORM_EXT;
|
|
164
183
|
|
|
165
184
|
}
|
|
166
185
|
|
|
@@ -199,6 +218,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
199
218
|
|
|
200
219
|
if ( glFormat === _gl.RGB ) {
|
|
201
220
|
|
|
221
|
+
if ( glType === _gl.UNSIGNED_SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RGB16_EXT;
|
|
222
|
+
if ( glType === _gl.SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RGB16_SNORM_EXT;
|
|
202
223
|
if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
|
|
203
224
|
if ( glType === _gl.UNSIGNED_INT_10F_11F_11F_REV ) internalFormat = _gl.R11F_G11F_B10F;
|
|
204
225
|
|
|
@@ -211,6 +232,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
211
232
|
if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
|
|
212
233
|
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
|
|
213
234
|
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( transfer === SRGBTransfer ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
|
|
235
|
+
if ( glType === _gl.UNSIGNED_SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RGBA16_EXT;
|
|
236
|
+
if ( glType === _gl.SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RGBA16_SNORM_EXT;
|
|
214
237
|
if ( glType === _gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = _gl.RGBA4;
|
|
215
238
|
if ( glType === _gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = _gl.RGB5_A1;
|
|
216
239
|
|
|
@@ -312,6 +335,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
312
335
|
|
|
313
336
|
}
|
|
314
337
|
|
|
338
|
+
if ( texture.isHTMLTexture ) {
|
|
339
|
+
|
|
340
|
+
_htmlTextures.delete( texture );
|
|
341
|
+
|
|
342
|
+
}
|
|
343
|
+
|
|
315
344
|
}
|
|
316
345
|
|
|
317
346
|
function onRenderTargetDispose( event ) {
|
|
@@ -468,6 +497,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
468
497
|
|
|
469
498
|
}
|
|
470
499
|
|
|
500
|
+
function getTextureUnits() {
|
|
501
|
+
|
|
502
|
+
return textureUnits;
|
|
503
|
+
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function setTextureUnits( value ) {
|
|
507
|
+
|
|
508
|
+
textureUnits = value;
|
|
509
|
+
|
|
510
|
+
}
|
|
511
|
+
|
|
471
512
|
function allocateTextureUnit() {
|
|
472
513
|
|
|
473
514
|
const textureUnit = textureUnits;
|
|
@@ -819,11 +860,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
819
860
|
// Trim the array to only contain the merged ranges.
|
|
820
861
|
updateRanges.length = mergeIndex + 1;
|
|
821
862
|
|
|
822
|
-
const currentUnpackRowLen =
|
|
823
|
-
const currentUnpackSkipPixels =
|
|
824
|
-
const currentUnpackSkipRows =
|
|
863
|
+
const currentUnpackRowLen = state.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
864
|
+
const currentUnpackSkipPixels = state.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
865
|
+
const currentUnpackSkipRows = state.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
825
866
|
|
|
826
|
-
|
|
867
|
+
state.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
827
868
|
|
|
828
869
|
for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
|
|
829
870
|
|
|
@@ -839,8 +880,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
839
880
|
const width = pixelCount;
|
|
840
881
|
const height = 1;
|
|
841
882
|
|
|
842
|
-
|
|
843
|
-
|
|
883
|
+
state.pixelStorei( _gl.UNPACK_SKIP_PIXELS, x );
|
|
884
|
+
state.pixelStorei( _gl.UNPACK_SKIP_ROWS, y );
|
|
844
885
|
|
|
845
886
|
state.texSubImage2D( _gl.TEXTURE_2D, 0, x, y, width, height, glFormat, glType, image.data );
|
|
846
887
|
|
|
@@ -848,9 +889,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
848
889
|
|
|
849
890
|
texture.clearUpdateRanges();
|
|
850
891
|
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
892
|
+
state.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
893
|
+
state.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
894
|
+
state.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
854
895
|
|
|
855
896
|
}
|
|
856
897
|
|
|
@@ -874,14 +915,21 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
874
915
|
|
|
875
916
|
state.activeTexture( _gl.TEXTURE0 + slot );
|
|
876
917
|
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
|
|
918
|
+
const isImageBitmap = ( typeof ImageBitmap !== 'undefined' && texture.image instanceof ImageBitmap );
|
|
919
|
+
|
|
920
|
+
if ( isImageBitmap === false ) {
|
|
921
|
+
|
|
922
|
+
const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
|
|
923
|
+
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
|
|
924
|
+
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
|
|
925
|
+
|
|
926
|
+
state.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
927
|
+
state.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
928
|
+
state.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
929
|
+
|
|
930
|
+
}
|
|
880
931
|
|
|
881
|
-
|
|
882
|
-
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
883
|
-
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
884
|
-
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
932
|
+
state.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
885
933
|
|
|
886
934
|
let image = resizeImage( texture.image, false, capabilities.maxTextureSize );
|
|
887
935
|
image = verifyColorSpace( texture, image );
|
|
@@ -889,7 +937,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
889
937
|
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
890
938
|
|
|
891
939
|
const glType = utils.convert( texture.type );
|
|
892
|
-
let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
|
|
940
|
+
let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace, texture.isVideoTexture );
|
|
893
941
|
|
|
894
942
|
setTextureParameters( textureType, texture );
|
|
895
943
|
|
|
@@ -1206,6 +1254,59 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1206
1254
|
|
|
1207
1255
|
}
|
|
1208
1256
|
|
|
1257
|
+
} else if ( texture.isHTMLTexture ) {
|
|
1258
|
+
|
|
1259
|
+
if ( 'texElementImage2D' in _gl ) {
|
|
1260
|
+
|
|
1261
|
+
const canvas = _gl.canvas;
|
|
1262
|
+
|
|
1263
|
+
// Ensure the canvas supports HTML-in-Canvas and the element is a child.
|
|
1264
|
+
if ( ! canvas.hasAttribute( 'layoutsubtree' ) ) {
|
|
1265
|
+
|
|
1266
|
+
canvas.setAttribute( 'layoutsubtree', 'true' );
|
|
1267
|
+
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
if ( image.parentNode !== canvas ) {
|
|
1271
|
+
|
|
1272
|
+
canvas.appendChild( image );
|
|
1273
|
+
|
|
1274
|
+
// Register and set up a shared paint callback for all HTMLTextures.
|
|
1275
|
+
_htmlTextures.add( texture );
|
|
1276
|
+
|
|
1277
|
+
canvas.onpaint = ( event ) => {
|
|
1278
|
+
|
|
1279
|
+
const changed = event.changedElements;
|
|
1280
|
+
|
|
1281
|
+
for ( const t of _htmlTextures ) {
|
|
1282
|
+
|
|
1283
|
+
if ( changed.includes( t.image ) ) {
|
|
1284
|
+
|
|
1285
|
+
t.needsUpdate = true;
|
|
1286
|
+
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
};
|
|
1292
|
+
|
|
1293
|
+
canvas.requestPaint();
|
|
1294
|
+
return;
|
|
1295
|
+
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
const level = 0;
|
|
1299
|
+
const internalFormat = _gl.RGBA;
|
|
1300
|
+
const srcFormat = _gl.RGBA;
|
|
1301
|
+
const srcType = _gl.UNSIGNED_BYTE;
|
|
1302
|
+
|
|
1303
|
+
_gl.texElementImage2D( _gl.TEXTURE_2D, level, internalFormat, srcFormat, srcType, image );
|
|
1304
|
+
_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.LINEAR );
|
|
1305
|
+
_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
|
|
1306
|
+
_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
|
|
1307
|
+
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1209
1310
|
} else {
|
|
1210
1311
|
|
|
1211
1312
|
// regular Texture (image, video, canvas)
|
|
@@ -1309,10 +1410,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1309
1410
|
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
|
|
1310
1411
|
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
|
|
1311
1412
|
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1413
|
+
state.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
1414
|
+
state.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
1415
|
+
state.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
1416
|
+
state.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
1316
1417
|
|
|
1317
1418
|
const isCompressed = ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture );
|
|
1318
1419
|
const isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );
|
|
@@ -1338,7 +1439,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1338
1439
|
const image = cubeImage[ 0 ],
|
|
1339
1440
|
glFormat = utils.convert( texture.format, texture.colorSpace ),
|
|
1340
1441
|
glType = utils.convert( texture.type ),
|
|
1341
|
-
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
1442
|
+
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace );
|
|
1342
1443
|
|
|
1343
1444
|
const useTexStorage = ( texture.isVideoTexture !== true );
|
|
1344
1445
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
@@ -1534,7 +1635,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1534
1635
|
|
|
1535
1636
|
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
1536
1637
|
const glType = utils.convert( texture.type );
|
|
1537
|
-
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
1638
|
+
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace );
|
|
1538
1639
|
const renderTargetProperties = properties.get( renderTarget );
|
|
1539
1640
|
const textureProperties = properties.get( texture );
|
|
1540
1641
|
|
|
@@ -1613,7 +1714,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1613
1714
|
|
|
1614
1715
|
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
1615
1716
|
const glType = utils.convert( texture.type );
|
|
1616
|
-
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
1717
|
+
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace );
|
|
1617
1718
|
|
|
1618
1719
|
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1619
1720
|
|
|
@@ -2003,7 +2104,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2003
2104
|
|
|
2004
2105
|
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
2005
2106
|
const glType = utils.convert( texture.type );
|
|
2006
|
-
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, renderTarget.isXRRenderTarget === true );
|
|
2107
|
+
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace, renderTarget.isXRRenderTarget === true );
|
|
2007
2108
|
const samples = getRenderTargetSamples( renderTarget );
|
|
2008
2109
|
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
2009
2110
|
|
|
@@ -2379,6 +2480,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2379
2480
|
|
|
2380
2481
|
this.allocateTextureUnit = allocateTextureUnit;
|
|
2381
2482
|
this.resetTextureUnits = resetTextureUnits;
|
|
2483
|
+
this.getTextureUnits = getTextureUnits;
|
|
2484
|
+
this.setTextureUnits = setTextureUnits;
|
|
2382
2485
|
|
|
2383
2486
|
this.setTexture2D = setTexture2D;
|
|
2384
2487
|
this.setTexture2DArray = setTexture2DArray;
|
|
@@ -141,6 +141,11 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
141
141
|
uniform.__data[ 10 ] = value.elements[ 8 ];
|
|
142
142
|
uniform.__data[ 11 ] = 0;
|
|
143
143
|
|
|
144
|
+
} else if ( ArrayBuffer.isView( value ) ) {
|
|
145
|
+
|
|
146
|
+
// copy the buffer data using "set"
|
|
147
|
+
uniform.__data.set( new value.constructor( value.buffer, value.byteOffset, uniform.__data.length ) );
|
|
148
|
+
|
|
144
149
|
} else {
|
|
145
150
|
|
|
146
151
|
value.toArray( uniform.__data, arrayOffset );
|
|
@@ -176,6 +181,10 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
176
181
|
|
|
177
182
|
cache[ indexString ] = value;
|
|
178
183
|
|
|
184
|
+
} else if ( ArrayBuffer.isView( value ) ) {
|
|
185
|
+
|
|
186
|
+
cache[ indexString ] = value.slice();
|
|
187
|
+
|
|
179
188
|
} else {
|
|
180
189
|
|
|
181
190
|
cache[ indexString ] = value.clone();
|
|
@@ -199,6 +208,11 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
199
208
|
|
|
200
209
|
}
|
|
201
210
|
|
|
211
|
+
} else if ( ArrayBuffer.isView( value ) ) {
|
|
212
|
+
|
|
213
|
+
// always update the array buffers
|
|
214
|
+
return true;
|
|
215
|
+
|
|
202
216
|
} else {
|
|
203
217
|
|
|
204
218
|
if ( cachedObject.equals( value ) === false ) {
|
|
@@ -339,6 +353,11 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
339
353
|
|
|
340
354
|
warn( 'WebGLRenderer: Texture samplers can not be part of an uniforms group.' );
|
|
341
355
|
|
|
356
|
+
} else if ( ArrayBuffer.isView( value ) ) {
|
|
357
|
+
|
|
358
|
+
info.boundary = 16;
|
|
359
|
+
info.storage = value.byteLength;
|
|
360
|
+
|
|
342
361
|
} else {
|
|
343
362
|
|
|
344
363
|
warn( 'WebGLRenderer: Unsupported uniform value type.', value );
|