super-three 0.162.0 → 0.164.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 +847 -1226
- package/build/three.module.js +846 -1225
- package/build/three.module.min.js +2 -2
- package/examples/jsm/animation/CCDIKSolver.js +4 -2
- package/examples/jsm/controls/TransformControls.js +3 -3
- package/examples/jsm/exporters/GLTFExporter.js +66 -5
- package/examples/jsm/exporters/USDZExporter.js +22 -1
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/libs/draco/README.md +2 -2
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/lines/LineMaterial.js +0 -2
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/EXRLoader.js +351 -97
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +59 -0
- package/examples/jsm/loaders/KTX2Loader.js +3 -10
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
- package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
- package/examples/jsm/math/Octree.js +26 -20
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
- package/examples/jsm/nodes/Nodes.js +10 -4
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +16 -1
- package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
- package/examples/jsm/nodes/accessors/ClippingNode.js +3 -2
- package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
- package/examples/jsm/nodes/accessors/MaterialNode.js +107 -3
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/MorphNode.js +13 -3
- package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +9 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +51 -10
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionNode.js +0 -8
- package/examples/jsm/nodes/core/Node.js +63 -4
- package/examples/jsm/nodes/core/NodeBuilder.js +26 -25
- package/examples/jsm/nodes/core/NodeFrame.js +10 -10
- package/examples/jsm/nodes/core/NodeUtils.js +2 -2
- package/examples/jsm/nodes/core/OutputStructNode.js +2 -1
- package/examples/jsm/nodes/core/PropertyNode.js +10 -0
- package/examples/jsm/nodes/core/UniformNode.js +20 -0
- package/examples/jsm/nodes/display/BumpMapNode.js +7 -26
- package/examples/jsm/nodes/display/FrontFacingNode.js +13 -0
- package/examples/jsm/nodes/display/PassNode.js +17 -1
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
- package/examples/jsm/nodes/display/ViewportDepthNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportNode.js +4 -2
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
- package/examples/jsm/nodes/display/ViewportTextureNode.js +4 -1
- package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
- package/examples/jsm/nodes/fog/FogNode.js +13 -3
- package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +26 -7
- package/examples/jsm/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +1 -3
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
- package/examples/jsm/nodes/functions/PhongLightingModel.js +1 -1
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +164 -10
- package/examples/jsm/nodes/functions/ShadowMaskModel.js +31 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +19 -5
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +22 -70
- package/examples/jsm/nodes/lighting/IrradianceNode.js +24 -0
- package/examples/jsm/nodes/lighting/LightsNode.js +11 -1
- package/examples/jsm/nodes/lighting/PointLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/SpotLightNode.js +2 -1
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +10 -6
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -2
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +76 -5
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +11 -4
- package/examples/jsm/nodes/materials/NodeMaterial.js +55 -43
- package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +34 -0
- package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +3 -9
- package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
- package/examples/jsm/objects/QuadMesh.js +7 -23
- package/examples/jsm/physics/JoltPhysics.js +281 -0
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/RenderTransitionPass.js +193 -0
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAOPass.js +0 -3
- package/examples/jsm/renderers/common/Animation.js +3 -0
- package/examples/jsm/renderers/common/Background.js +8 -8
- package/examples/jsm/renderers/common/ClippingContext.js +1 -1
- package/examples/jsm/renderers/common/Info.js +11 -19
- package/examples/jsm/renderers/common/PostProcessing.js +12 -4
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderList.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +47 -5
- package/examples/jsm/renderers/common/RenderObjects.js +1 -1
- package/examples/jsm/renderers/common/Renderer.js +153 -21
- package/examples/jsm/renderers/common/Textures.js +1 -1
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +773 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +34 -63
- package/examples/jsm/renderers/webgl/WebGLBackend.js +146 -36
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +145 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +9 -3
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +1 -1
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +64 -7
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +6 -23
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +77 -60
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +21 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +29 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +92 -18
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/utils/GPUStatsPanel.js +10 -45
- package/examples/jsm/utils/SceneUtils.js +60 -1
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/examples/jsm/webxr/OculusHandModel.js +3 -2
- package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
- package/package.json +1 -1
- package/src/Three.js +0 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/constants.js +3 -3
- package/src/core/Object3D.js +10 -7
- package/src/core/RenderTarget.js +8 -0
- package/src/extras/PMREMGenerator.js +21 -11
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/loaders/ObjectLoader.js +2 -0
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshPhysicalMaterial.js +20 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/math/Spherical.js +4 -5
- package/src/objects/BatchedMesh.js +27 -3
- package/src/objects/InstancedMesh.js +10 -0
- package/src/objects/Line.js +66 -43
- package/src/renderers/WebGLRenderer.js +130 -158
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +17 -9
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
- package/src/renderers/shaders/ShaderChunk.js +0 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib.js +2 -1
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +6 -33
- package/src/renderers/webgl/WebGLBackground.js +18 -3
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +35 -21
- package/src/renderers/webgl/WebGLCapabilities.js +35 -13
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +4 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +35 -21
- package/src/renderers/webgl/WebGLLights.js +6 -32
- package/src/renderers/webgl/WebGLMaterials.js +8 -3
- package/src/renderers/webgl/WebGLMorphtargets.js +79 -217
- package/src/renderers/webgl/WebGLProgram.js +21 -52
- package/src/renderers/webgl/WebGLPrograms.js +24 -31
- package/src/renderers/webgl/WebGLRenderStates.js +13 -7
- package/src/renderers/webgl/WebGLShadowMap.js +25 -25
- package/src/renderers/webgl/WebGLState.js +15 -59
- package/src/renderers/webgl/WebGLTextures.js +138 -292
- package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
- package/src/renderers/webgl/WebGLUtils.js +9 -78
- package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
- package/src/renderers/webxr/WebXRManager.js +4 -6
- package/src/scenes/Scene.js +7 -1
- package/src/textures/Texture.js +11 -1
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -320
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +0 -26
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -794
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +0 -51
- package/src/renderers/WebGL1Renderer.js +0 -7
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat,
|
|
2
|
-
import * as MathUtils from '../../math/MathUtils.js';
|
|
3
|
-
import { ImageUtils } from '../../extras/ImageUtils.js';
|
|
1
|
+
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedIntType, UnsignedInt248Type, FloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, NoColorSpace, LinearSRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, SRGBTransfer, LinearTransfer } from '../../constants.js';
|
|
4
2
|
import { createElementNS } from '../../utils.js';
|
|
5
3
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
6
4
|
import { Vector2 } from '../../math/Vector2.js';
|
|
7
5
|
|
|
8
6
|
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
|
|
9
7
|
|
|
10
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
11
8
|
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
|
|
12
9
|
const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
|
|
13
10
|
const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
|
|
@@ -49,7 +46,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
49
46
|
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
function resizeImage( image,
|
|
49
|
+
function resizeImage( image, needsNewCanvas, maxSize ) {
|
|
53
50
|
|
|
54
51
|
let scale = 1;
|
|
55
52
|
|
|
@@ -65,7 +62,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
65
62
|
|
|
66
63
|
// only perform resize if necessary
|
|
67
64
|
|
|
68
|
-
if ( scale < 1
|
|
65
|
+
if ( scale < 1 ) {
|
|
69
66
|
|
|
70
67
|
// only perform resize for certain image types
|
|
71
68
|
|
|
@@ -74,10 +71,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
74
71
|
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ||
|
|
75
72
|
( typeof VideoFrame !== 'undefined' && image instanceof VideoFrame ) ) {
|
|
76
73
|
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
const width = floor( scale * dimensions.width );
|
|
80
|
-
const height = floor( scale * dimensions.height );
|
|
74
|
+
const width = Math.floor( scale * dimensions.width );
|
|
75
|
+
const height = Math.floor( scale * dimensions.height );
|
|
81
76
|
|
|
82
77
|
if ( _canvas === undefined ) _canvas = createCanvas( width, height );
|
|
83
78
|
|
|
@@ -113,27 +108,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
113
108
|
|
|
114
109
|
}
|
|
115
110
|
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
const dimensions = getDimensions( image );
|
|
119
|
-
|
|
120
|
-
return MathUtils.isPowerOfTwo( dimensions.width ) && MathUtils.isPowerOfTwo( dimensions.height );
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function textureNeedsPowerOfTwo( texture ) {
|
|
125
|
-
|
|
126
|
-
if ( isWebGL2 ) return false;
|
|
111
|
+
function textureNeedsGenerateMipmaps( texture ) {
|
|
127
112
|
|
|
128
|
-
return
|
|
129
|
-
( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function textureNeedsGenerateMipmaps( texture, supportsMips ) {
|
|
134
|
-
|
|
135
|
-
return texture.generateMipmaps && supportsMips &&
|
|
136
|
-
texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
|
|
113
|
+
return texture.generateMipmaps && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
|
|
137
114
|
|
|
138
115
|
}
|
|
139
116
|
|
|
@@ -145,8 +122,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
145
122
|
|
|
146
123
|
function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
|
|
147
124
|
|
|
148
|
-
if ( isWebGL2 === false ) return glFormat;
|
|
149
|
-
|
|
150
125
|
if ( internalFormatName !== null ) {
|
|
151
126
|
|
|
152
127
|
if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];
|
|
@@ -195,6 +170,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
195
170
|
|
|
196
171
|
}
|
|
197
172
|
|
|
173
|
+
if ( glFormat === _gl.RGB ) {
|
|
174
|
+
|
|
175
|
+
if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
|
|
176
|
+
|
|
177
|
+
}
|
|
178
|
+
|
|
198
179
|
if ( glFormat === _gl.RGBA ) {
|
|
199
180
|
|
|
200
181
|
const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
|
|
@@ -219,9 +200,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
219
200
|
|
|
220
201
|
}
|
|
221
202
|
|
|
222
|
-
function getMipLevels( texture, image
|
|
203
|
+
function getMipLevels( texture, image ) {
|
|
223
204
|
|
|
224
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
205
|
+
if ( textureNeedsGenerateMipmaps( texture ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
|
|
225
206
|
|
|
226
207
|
return Math.log2( Math.max( image.width, image.height ) ) + 1;
|
|
227
208
|
|
|
@@ -245,20 +226,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
245
226
|
|
|
246
227
|
}
|
|
247
228
|
|
|
248
|
-
// Fallback filters for non-power-of-2 textures
|
|
249
|
-
|
|
250
|
-
function filterFallback( f ) {
|
|
251
|
-
|
|
252
|
-
if ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) {
|
|
253
|
-
|
|
254
|
-
return _gl.NEAREST;
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return _gl.LINEAR;
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
|
|
262
229
|
//
|
|
263
230
|
|
|
264
231
|
function onTextureDispose( event ) {
|
|
@@ -576,7 +543,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
576
543
|
[ NotEqualCompare ]: _gl.NOTEQUAL
|
|
577
544
|
};
|
|
578
545
|
|
|
579
|
-
function setTextureParameters( textureType, texture
|
|
546
|
+
function setTextureParameters( textureType, texture ) {
|
|
580
547
|
|
|
581
548
|
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false &&
|
|
582
549
|
( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
|
|
@@ -586,48 +553,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
586
553
|
|
|
587
554
|
}
|
|
588
555
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
592
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
593
|
-
|
|
594
|
-
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
595
|
-
|
|
596
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
|
|
556
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
557
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
597
558
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
|
|
601
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
|
|
602
|
-
|
|
603
|
-
} else {
|
|
604
|
-
|
|
605
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
|
|
606
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
|
|
607
|
-
|
|
608
|
-
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
609
|
-
|
|
610
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE );
|
|
611
|
-
|
|
612
|
-
}
|
|
559
|
+
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
613
560
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );
|
|
617
|
-
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );
|
|
621
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );
|
|
622
|
-
|
|
623
|
-
if ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) {
|
|
624
|
-
|
|
625
|
-
console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' );
|
|
626
|
-
|
|
627
|
-
}
|
|
561
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
|
|
628
562
|
|
|
629
563
|
}
|
|
630
564
|
|
|
565
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
|
|
566
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
|
|
567
|
+
|
|
631
568
|
if ( texture.compareFunction ) {
|
|
632
569
|
|
|
633
570
|
_gl.texParameteri( textureType, _gl.TEXTURE_COMPARE_MODE, _gl.COMPARE_REF_TO_TEXTURE );
|
|
@@ -639,8 +576,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
639
576
|
|
|
640
577
|
if ( texture.magFilter === NearestFilter ) return;
|
|
641
578
|
if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
|
|
642
|
-
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension
|
|
643
|
-
if ( isWebGL2 === false && ( texture.type === HalfFloatType && extensions.has( 'OES_texture_half_float_linear' ) === false ) ) return; // verify extension for WebGL 1 only
|
|
579
|
+
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension
|
|
644
580
|
|
|
645
581
|
if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
|
|
646
582
|
|
|
@@ -798,97 +734,41 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
798
734
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
799
735
|
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
800
736
|
|
|
801
|
-
|
|
802
|
-
let image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
|
|
737
|
+
let image = resizeImage( texture.image, false, capabilities.maxTextureSize );
|
|
803
738
|
image = verifyColorSpace( texture, image );
|
|
804
739
|
|
|
805
|
-
const
|
|
806
|
-
glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
740
|
+
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
807
741
|
|
|
808
|
-
|
|
809
|
-
|
|
742
|
+
const glType = utils.convert( texture.type );
|
|
743
|
+
let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
|
|
810
744
|
|
|
811
|
-
setTextureParameters( textureType, texture
|
|
745
|
+
setTextureParameters( textureType, texture );
|
|
812
746
|
|
|
813
747
|
let mipmap;
|
|
814
748
|
const mipmaps = texture.mipmaps;
|
|
815
749
|
|
|
816
|
-
const useTexStorage = (
|
|
750
|
+
const useTexStorage = ( texture.isVideoTexture !== true );
|
|
817
751
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
818
752
|
const dataReady = source.dataReady;
|
|
819
|
-
const levels = getMipLevels( texture, image
|
|
753
|
+
const levels = getMipLevels( texture, image );
|
|
820
754
|
|
|
821
755
|
if ( texture.isDepthTexture ) {
|
|
822
756
|
|
|
823
757
|
// populate depth texture with dummy data
|
|
824
758
|
|
|
825
|
-
glInternalFormat = _gl.
|
|
826
|
-
|
|
827
|
-
if ( isWebGL2 ) {
|
|
759
|
+
glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
828
760
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
832
|
-
|
|
833
|
-
} else if ( texture.type === UnsignedIntType ) {
|
|
834
|
-
|
|
835
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
836
|
-
|
|
837
|
-
} else if ( texture.type === UnsignedInt248Type ) {
|
|
838
|
-
|
|
839
|
-
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
840
|
-
|
|
841
|
-
} else {
|
|
842
|
-
|
|
843
|
-
glInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D
|
|
844
|
-
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
} else {
|
|
848
|
-
|
|
849
|
-
if ( texture.type === FloatType ) {
|
|
850
|
-
|
|
851
|
-
console.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' );
|
|
852
|
-
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
// validation checks for WebGL 1
|
|
858
|
-
|
|
859
|
-
if ( texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
|
|
860
|
-
|
|
861
|
-
// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
|
|
862
|
-
// DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT
|
|
863
|
-
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
864
|
-
if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {
|
|
865
|
-
|
|
866
|
-
console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );
|
|
867
|
-
|
|
868
|
-
texture.type = UnsignedIntType;
|
|
869
|
-
glType = utils.convert( texture.type );
|
|
870
|
-
|
|
871
|
-
}
|
|
761
|
+
if ( texture.type === FloatType ) {
|
|
872
762
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
if ( texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
|
|
876
|
-
|
|
877
|
-
// Depth stencil textures need the DEPTH_STENCIL internal format
|
|
878
|
-
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
879
|
-
glInternalFormat = _gl.DEPTH_STENCIL;
|
|
763
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
880
764
|
|
|
881
|
-
|
|
882
|
-
// DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.
|
|
883
|
-
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
884
|
-
if ( texture.type !== UnsignedInt248Type ) {
|
|
765
|
+
} else if ( texture.type === UnsignedIntType ) {
|
|
885
766
|
|
|
886
|
-
|
|
767
|
+
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
887
768
|
|
|
888
|
-
|
|
889
|
-
glType = utils.convert( texture.type );
|
|
769
|
+
} else if ( texture.type === UnsignedInt248Type ) {
|
|
890
770
|
|
|
891
|
-
|
|
771
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
892
772
|
|
|
893
773
|
}
|
|
894
774
|
|
|
@@ -914,7 +794,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
914
794
|
// if there are no manual mipmaps
|
|
915
795
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
916
796
|
|
|
917
|
-
if ( mipmaps.length > 0
|
|
797
|
+
if ( mipmaps.length > 0 ) {
|
|
918
798
|
|
|
919
799
|
if ( useTexStorage && allocateMemory ) {
|
|
920
800
|
|
|
@@ -1161,7 +1041,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1161
1041
|
// if there are no manual mipmaps
|
|
1162
1042
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
1163
1043
|
|
|
1164
|
-
if ( mipmaps.length > 0
|
|
1044
|
+
if ( mipmaps.length > 0 ) {
|
|
1165
1045
|
|
|
1166
1046
|
if ( useTexStorage && allocateMemory ) {
|
|
1167
1047
|
|
|
@@ -1221,7 +1101,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1221
1101
|
|
|
1222
1102
|
}
|
|
1223
1103
|
|
|
1224
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1104
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
1225
1105
|
|
|
1226
1106
|
generateMipmap( textureType );
|
|
1227
1107
|
|
|
@@ -1271,7 +1151,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1271
1151
|
|
|
1272
1152
|
if ( ! isCompressed && ! isDataTexture ) {
|
|
1273
1153
|
|
|
1274
|
-
cubeImage[ i ] = resizeImage( texture.image[ i ],
|
|
1154
|
+
cubeImage[ i ] = resizeImage( texture.image[ i ], true, capabilities.maxCubemapSize );
|
|
1275
1155
|
|
|
1276
1156
|
} else {
|
|
1277
1157
|
|
|
@@ -1284,17 +1164,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1284
1164
|
}
|
|
1285
1165
|
|
|
1286
1166
|
const image = cubeImage[ 0 ],
|
|
1287
|
-
supportsMips = isPowerOfTwo( image ) || isWebGL2,
|
|
1288
1167
|
glFormat = utils.convert( texture.format, texture.colorSpace ),
|
|
1289
1168
|
glType = utils.convert( texture.type ),
|
|
1290
1169
|
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
1291
1170
|
|
|
1292
|
-
const useTexStorage = (
|
|
1171
|
+
const useTexStorage = ( texture.isVideoTexture !== true );
|
|
1293
1172
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
1294
1173
|
const dataReady = source.dataReady;
|
|
1295
|
-
let levels = getMipLevels( texture, image
|
|
1174
|
+
let levels = getMipLevels( texture, image );
|
|
1296
1175
|
|
|
1297
|
-
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture
|
|
1176
|
+
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
|
|
1298
1177
|
|
|
1299
1178
|
let mipmaps;
|
|
1300
1179
|
|
|
@@ -1459,7 +1338,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1459
1338
|
|
|
1460
1339
|
}
|
|
1461
1340
|
|
|
1462
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1341
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
1463
1342
|
|
|
1464
1343
|
// We assume images for cube map have the same size.
|
|
1465
1344
|
generateMipmap( _gl.TEXTURE_CUBE_MAP );
|
|
@@ -1601,7 +1480,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1601
1480
|
|
|
1602
1481
|
} else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
|
|
1603
1482
|
|
|
1604
|
-
let glInternalFormat =
|
|
1483
|
+
let glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
1605
1484
|
|
|
1606
1485
|
if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
|
|
1607
1486
|
|
|
@@ -1880,7 +1759,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1880
1759
|
|
|
1881
1760
|
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
1882
1761
|
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
1883
|
-
const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
|
|
1884
1762
|
|
|
1885
1763
|
if ( ! isMultipleRenderTargets ) {
|
|
1886
1764
|
|
|
@@ -1903,7 +1781,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1903
1781
|
|
|
1904
1782
|
for ( let i = 0; i < 6; i ++ ) {
|
|
1905
1783
|
|
|
1906
|
-
if (
|
|
1784
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
1907
1785
|
|
|
1908
1786
|
renderTargetProperties.__webglFramebuffer[ i ] = [];
|
|
1909
1787
|
|
|
@@ -1923,7 +1801,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1923
1801
|
|
|
1924
1802
|
} else {
|
|
1925
1803
|
|
|
1926
|
-
if (
|
|
1804
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
1927
1805
|
|
|
1928
1806
|
renderTargetProperties.__webglFramebuffer = [];
|
|
1929
1807
|
|
|
@@ -1941,31 +1819,23 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1941
1819
|
|
|
1942
1820
|
if ( isMultipleRenderTargets ) {
|
|
1943
1821
|
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
1822
|
+
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
1947
1823
|
|
|
1948
|
-
|
|
1824
|
+
const attachmentProperties = properties.get( textures[ i ] );
|
|
1949
1825
|
|
|
1950
|
-
|
|
1826
|
+
if ( attachmentProperties.__webglTexture === undefined ) {
|
|
1951
1827
|
|
|
1952
|
-
|
|
1828
|
+
attachmentProperties.__webglTexture = _gl.createTexture();
|
|
1953
1829
|
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
}
|
|
1830
|
+
info.memory.textures ++;
|
|
1957
1831
|
|
|
1958
1832
|
}
|
|
1959
1833
|
|
|
1960
|
-
} else {
|
|
1961
|
-
|
|
1962
|
-
console.warn( 'THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.' );
|
|
1963
|
-
|
|
1964
1834
|
}
|
|
1965
1835
|
|
|
1966
1836
|
}
|
|
1967
1837
|
|
|
1968
|
-
if ( (
|
|
1838
|
+
if ( ( renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
|
|
1969
1839
|
|
|
1970
1840
|
renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
|
|
1971
1841
|
renderTargetProperties.__webglColorRenderbuffer = [];
|
|
@@ -2009,11 +1879,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2009
1879
|
if ( isCube ) {
|
|
2010
1880
|
|
|
2011
1881
|
state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
|
|
2012
|
-
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture
|
|
1882
|
+
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
|
|
2013
1883
|
|
|
2014
1884
|
for ( let i = 0; i < 6; i ++ ) {
|
|
2015
1885
|
|
|
2016
|
-
if (
|
|
1886
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
2017
1887
|
|
|
2018
1888
|
for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
|
|
2019
1889
|
|
|
@@ -2029,7 +1899,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2029
1899
|
|
|
2030
1900
|
}
|
|
2031
1901
|
|
|
2032
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1902
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
2033
1903
|
|
|
2034
1904
|
generateMipmap( _gl.TEXTURE_CUBE_MAP );
|
|
2035
1905
|
|
|
@@ -2045,10 +1915,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2045
1915
|
const attachmentProperties = properties.get( attachment );
|
|
2046
1916
|
|
|
2047
1917
|
state.bindTexture( _gl.TEXTURE_2D, attachmentProperties.__webglTexture );
|
|
2048
|
-
setTextureParameters( _gl.TEXTURE_2D, attachment
|
|
1918
|
+
setTextureParameters( _gl.TEXTURE_2D, attachment );
|
|
2049
1919
|
setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, 0 );
|
|
2050
1920
|
|
|
2051
|
-
if ( textureNeedsGenerateMipmaps( attachment
|
|
1921
|
+
if ( textureNeedsGenerateMipmaps( attachment ) ) {
|
|
2052
1922
|
|
|
2053
1923
|
generateMipmap( _gl.TEXTURE_2D );
|
|
2054
1924
|
|
|
@@ -2064,15 +1934,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2064
1934
|
|
|
2065
1935
|
if ( renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
|
|
2066
1936
|
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
|
|
2070
|
-
|
|
2071
|
-
} else {
|
|
2072
|
-
|
|
2073
|
-
console.error( 'THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.' );
|
|
2074
|
-
|
|
2075
|
-
}
|
|
1937
|
+
glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
|
|
2076
1938
|
|
|
2077
1939
|
}
|
|
2078
1940
|
|
|
@@ -2083,9 +1945,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2083
1945
|
}
|
|
2084
1946
|
|
|
2085
1947
|
state.bindTexture( glTextureType, textureProperties.__webglTexture );
|
|
2086
|
-
setTextureParameters( glTextureType, texture
|
|
1948
|
+
setTextureParameters( glTextureType, texture );
|
|
2087
1949
|
|
|
2088
|
-
if (
|
|
1950
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
2089
1951
|
|
|
2090
1952
|
for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
|
|
2091
1953
|
|
|
@@ -2099,7 +1961,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2099
1961
|
|
|
2100
1962
|
}
|
|
2101
1963
|
|
|
2102
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1964
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
2103
1965
|
|
|
2104
1966
|
generateMipmap( glTextureType );
|
|
2105
1967
|
|
|
@@ -2121,15 +1983,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2121
1983
|
|
|
2122
1984
|
function updateRenderTargetMipmap( renderTarget ) {
|
|
2123
1985
|
|
|
2124
|
-
const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
|
|
2125
|
-
|
|
2126
1986
|
const textures = renderTarget.textures;
|
|
2127
1987
|
|
|
2128
1988
|
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
2129
1989
|
|
|
2130
1990
|
const texture = textures[ i ];
|
|
2131
1991
|
|
|
2132
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1992
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
2133
1993
|
|
|
2134
1994
|
const target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;
|
|
2135
1995
|
const webglTexture = properties.get( texture ).__webglTexture;
|
|
@@ -2144,109 +2004,120 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2144
2004
|
|
|
2145
2005
|
}
|
|
2146
2006
|
|
|
2007
|
+
const invalidationArrayRead = [];
|
|
2008
|
+
const invalidationArrayDraw = [];
|
|
2009
|
+
|
|
2147
2010
|
function updateMultisampleRenderTarget( renderTarget ) {
|
|
2148
2011
|
|
|
2149
|
-
if (
|
|
2012
|
+
if ( renderTarget.samples > 0 ) {
|
|
2150
2013
|
|
|
2151
|
-
|
|
2152
|
-
const width = renderTarget.width;
|
|
2153
|
-
const height = renderTarget.height;
|
|
2154
|
-
let mask = _gl.COLOR_BUFFER_BIT;
|
|
2155
|
-
const invalidationArray = [];
|
|
2156
|
-
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
2157
|
-
const renderTargetProperties = properties.get( renderTarget );
|
|
2158
|
-
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
2159
|
-
|
|
2160
|
-
// If MRT we need to remove FBO attachments
|
|
2161
|
-
if ( isMultipleRenderTargets ) {
|
|
2014
|
+
if ( useMultisampledRTT( renderTarget ) === false ) {
|
|
2162
2015
|
|
|
2163
|
-
|
|
2016
|
+
const textures = renderTarget.textures;
|
|
2017
|
+
const width = renderTarget.width;
|
|
2018
|
+
const height = renderTarget.height;
|
|
2019
|
+
let mask = _gl.COLOR_BUFFER_BIT;
|
|
2020
|
+
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
2021
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
2022
|
+
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
2023
|
+
|
|
2024
|
+
// If MRT we need to remove FBO attachments
|
|
2025
|
+
if ( isMultipleRenderTargets ) {
|
|
2026
|
+
|
|
2027
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
2028
|
+
|
|
2029
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
2030
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, null );
|
|
2164
2031
|
|
|
2165
|
-
|
|
2166
|
-
|
|
2032
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
2033
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0 );
|
|
2167
2034
|
|
|
2168
|
-
|
|
2169
|
-
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0 );
|
|
2035
|
+
}
|
|
2170
2036
|
|
|
2171
2037
|
}
|
|
2172
2038
|
|
|
2173
|
-
|
|
2039
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
2040
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
2174
2041
|
|
|
2175
|
-
|
|
2176
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
2042
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
2177
2043
|
|
|
2178
|
-
|
|
2044
|
+
if ( renderTarget.resolveDepthBuffer ) {
|
|
2179
2045
|
|
|
2180
|
-
|
|
2046
|
+
if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
|
|
2181
2047
|
|
|
2182
|
-
|
|
2048
|
+
// resolving stencil is slow with a D3D backend. disable it for all transmission render targets (see #27799)
|
|
2183
2049
|
|
|
2184
|
-
|
|
2050
|
+
if ( renderTarget.stencilBuffer && renderTarget.resolveStencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;
|
|
2185
2051
|
|
|
2186
|
-
|
|
2052
|
+
}
|
|
2187
2053
|
|
|
2188
|
-
|
|
2054
|
+
if ( isMultipleRenderTargets ) {
|
|
2189
2055
|
|
|
2190
|
-
|
|
2056
|
+
_gl.framebufferRenderbuffer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
2191
2057
|
|
|
2192
|
-
|
|
2193
|
-
|
|
2058
|
+
const webglTexture = properties.get( textures[ i ] ).__webglTexture;
|
|
2059
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
2194
2060
|
|
|
2195
|
-
|
|
2061
|
+
}
|
|
2196
2062
|
|
|
2197
|
-
|
|
2063
|
+
_gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST );
|
|
2198
2064
|
|
|
2199
|
-
|
|
2065
|
+
if ( supportsInvalidateFramebuffer === true ) {
|
|
2200
2066
|
|
|
2201
|
-
|
|
2067
|
+
invalidationArrayRead.length = 0;
|
|
2068
|
+
invalidationArrayDraw.length = 0;
|
|
2202
2069
|
|
|
2203
|
-
|
|
2070
|
+
invalidationArrayRead.push( _gl.COLOR_ATTACHMENT0 + i );
|
|
2204
2071
|
|
|
2205
|
-
|
|
2206
|
-
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
2072
|
+
if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false ) {
|
|
2207
2073
|
|
|
2208
|
-
|
|
2074
|
+
invalidationArrayRead.push( depthStyle );
|
|
2075
|
+
invalidationArrayDraw.push( depthStyle );
|
|
2209
2076
|
|
|
2210
|
-
|
|
2077
|
+
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, invalidationArrayDraw );
|
|
2211
2078
|
|
|
2212
|
-
|
|
2213
|
-
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
_gl.invalidateFramebuffer( _gl.READ_FRAMEBUFFER, invalidationArrayRead );
|
|
2082
|
+
|
|
2083
|
+
}
|
|
2214
2084
|
|
|
2215
2085
|
}
|
|
2216
2086
|
|
|
2217
|
-
|
|
2087
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
|
|
2088
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
2218
2089
|
|
|
2219
|
-
|
|
2090
|
+
// If MRT since pre-blit we removed the FBO we need to reconstruct the attachments
|
|
2091
|
+
if ( isMultipleRenderTargets ) {
|
|
2220
2092
|
|
|
2221
|
-
|
|
2093
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
2222
2094
|
|
|
2223
|
-
|
|
2095
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
2096
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
2224
2097
|
|
|
2098
|
+
const webglTexture = properties.get( textures[ i ] ).__webglTexture;
|
|
2225
2099
|
|
|
2226
|
-
|
|
2100
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
2101
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
2227
2102
|
|
|
2228
|
-
|
|
2229
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
2103
|
+
}
|
|
2230
2104
|
|
|
2231
|
-
|
|
2232
|
-
if ( isMultipleRenderTargets ) {
|
|
2105
|
+
}
|
|
2233
2106
|
|
|
2234
|
-
|
|
2107
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
2235
2108
|
|
|
2236
|
-
|
|
2237
|
-
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
2109
|
+
} else {
|
|
2238
2110
|
|
|
2239
|
-
|
|
2111
|
+
if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false && supportsInvalidateFramebuffer ) {
|
|
2240
2112
|
|
|
2241
|
-
|
|
2242
|
-
|
|
2113
|
+
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
2114
|
+
|
|
2115
|
+
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
2243
2116
|
|
|
2244
2117
|
}
|
|
2245
2118
|
|
|
2246
2119
|
}
|
|
2247
2120
|
|
|
2248
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
2249
|
-
|
|
2250
2121
|
}
|
|
2251
2122
|
|
|
2252
2123
|
}
|
|
@@ -2261,7 +2132,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2261
2132
|
|
|
2262
2133
|
const renderTargetProperties = properties.get( renderTarget );
|
|
2263
2134
|
|
|
2264
|
-
return
|
|
2135
|
+
return renderTarget.samples > 0 && extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTargetProperties.__useRenderToTexture !== false;
|
|
2265
2136
|
|
|
2266
2137
|
}
|
|
2267
2138
|
|
|
@@ -2286,7 +2157,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2286
2157
|
const format = texture.format;
|
|
2287
2158
|
const type = texture.type;
|
|
2288
2159
|
|
|
2289
|
-
if ( texture.isCompressedTexture === true || texture.isVideoTexture === true
|
|
2160
|
+
if ( texture.isCompressedTexture === true || texture.isVideoTexture === true ) return image;
|
|
2290
2161
|
|
|
2291
2162
|
if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
|
|
2292
2163
|
|
|
@@ -2294,36 +2165,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2294
2165
|
|
|
2295
2166
|
if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
|
|
2296
2167
|
|
|
2297
|
-
if
|
|
2298
|
-
|
|
2299
|
-
// in WebGL 1, try to use EXT_sRGB extension and unsized formats
|
|
2300
|
-
|
|
2301
|
-
if ( extensions.has( 'EXT_sRGB' ) === true && format === RGBAFormat ) {
|
|
2302
|
-
|
|
2303
|
-
texture.format = _SRGBAFormat;
|
|
2304
|
-
|
|
2305
|
-
// it's not possible to generate mips in WebGL 1 with this extension
|
|
2306
|
-
|
|
2307
|
-
texture.minFilter = LinearFilter;
|
|
2308
|
-
texture.generateMipmaps = false;
|
|
2309
|
-
|
|
2310
|
-
} else {
|
|
2311
|
-
|
|
2312
|
-
// slow fallback (CPU decode)
|
|
2313
|
-
|
|
2314
|
-
image = ImageUtils.sRGBToLinear( image );
|
|
2168
|
+
// in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
|
|
2315
2169
|
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
} else {
|
|
2170
|
+
if ( format !== RGBAFormat || type !== UnsignedByteType ) {
|
|
2319
2171
|
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
if ( format !== RGBAFormat || type !== UnsignedByteType ) {
|
|
2323
|
-
|
|
2324
|
-
console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
|
|
2325
|
-
|
|
2326
|
-
}
|
|
2172
|
+
console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
|
|
2327
2173
|
|
|
2328
2174
|
}
|
|
2329
2175
|
|