55 */
66'use strict';
77
8- const REVISION = '151 ';
8+ const REVISION = '152dev ';
99const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
1010const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
1111const CullFaceNone = 0;
@@ -11930,7 +11930,7 @@ function getUnlitUniformColorSpace( renderer ) {
1193011930 if ( renderer.getRenderTarget() === null ) {
1193111931
1193211932 // https://github.com/mrdoob/three.js/pull/23937#issuecomment-1111067398
11933- return renderer.outputEncoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace ;
11933+ return renderer.outputColorSpace ;
1193411934
1193511935 }
1193611936
@@ -13503,7 +13503,7 @@ var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_
1350313503
1350413504var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif";
1350513505
13506- var map_fragment = "#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor ;\n#endif";
13506+ var map_fragment = "#ifdef USE_MAP\n\tdiffuseColor * = texture2D( map, vMapUv );\n#endif";
1350713507
1350813508var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif";
1350913509
@@ -13597,7 +13597,7 @@ var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defin
1359713597
1359813598const vertex$h = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}";
1359913599
13600- const fragment$h = "uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}";
13600+ const fragment$h = "uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}";
1360113601
1360213602const vertex$g = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}";
1360313603
@@ -18750,16 +18750,16 @@ function handleSource( string, errorLine ) {
1875018750
1875118751}
1875218752
18753- function getEncodingComponents( encoding ) {
18753+ function getEncodingComponents( colorSpace ) {
1875418754
18755- switch ( encoding ) {
18755+ switch ( colorSpace ) {
1875618756
18757- case LinearEncoding :
18757+ case LinearSRGBColorSpace :
1875818758 return [ 'Linear', '( value )' ];
18759- case sRGBEncoding :
18759+ case SRGBColorSpace :
1876018760 return [ 'sRGB', '( value )' ];
1876118761 default:
18762- console.warn( 'THREE.WebGLProgram: Unsupported encoding :', encoding );
18762+ console.warn( 'THREE.WebGLProgram: Unsupported color space :', colorSpace );
1876318763 return [ 'Linear', '( value )' ];
1876418764
1876518765 }
@@ -18790,9 +18790,9 @@ function getShaderErrors( gl, shader, type ) {
1879018790
1879118791}
1879218792
18793- function getTexelEncodingFunction( functionName, encoding ) {
18793+ function getTexelEncodingFunction( functionName, colorSpace ) {
1879418794
18795- const components = getEncodingComponents( encoding );
18795+ const components = getEncodingComponents( colorSpace );
1879618796 return 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[ 0 ] + components[ 1 ] + '; }';
1879718797
1879818798}
@@ -19411,8 +19411,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
1941119411 parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '',
1941219412 parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '',
1941319413
19414- parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
19415-
1941619414 parameters.vertexTangents ? '#define USE_TANGENT' : '',
1941719415 parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '',
1941819416 parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',
@@ -19449,7 +19447,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
1944919447 parameters.opaque ? '#define OPAQUE' : '',
1945019448
1945119449 ShaderChunk[ 'encodings_pars_fragment' ], // this code is required here because it is used by the various encoding/decoding function defined below
19452- getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputEncoding ),
19450+ getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputColorSpace ),
1945319451
1945419452 parameters.useDepthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '',
1945519453
@@ -19961,7 +19959,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
1996119959 instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
1996219960
1996319961 supportsVertexTextures: SUPPORTS_VERTEX_TEXTURES,
19964- outputEncoding : ( currentRenderTarget === null ) ? renderer.outputEncoding : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.encoding : LinearEncoding ),
19962+ outputColorSpace : ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? ( currentRenderTarget.texture.encoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace ) : LinearSRGBColorSpace ),
1996519963
1996619964 map: HAS_MAP,
1996719965 matcap: HAS_MATCAP,
@@ -19978,8 +19976,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
1997819976 normalMapObjectSpace: HAS_NORMALMAP && material.normalMapType === ObjectSpaceNormalMap,
1997919977 normalMapTangentSpace: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap,
1998019978
19981- decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( material.map.encoding === sRGBEncoding ),
19982-
1998319979 metalnessMap: HAS_METALNESSMAP,
1998419980 roughnessMap: HAS_ROUGHNESSMAP,
1998519981
@@ -20151,7 +20147,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
2015120147
2015220148 getProgramCacheKeyParameters( array, parameters );
2015320149 getProgramCacheKeyBooleans( array, parameters );
20154- array.push( renderer.outputEncoding );
20150+ array.push( renderer.outputColorSpace );
2015520151
2015620152 }
2015720153
@@ -20164,7 +20160,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
2016420160 function getProgramCacheKeyParameters( array, parameters ) {
2016520161
2016620162 array.push( parameters.precision );
20167- array.push( parameters.outputEncoding );
20163+ array.push( parameters.outputColorSpace );
2016820164 array.push( parameters.envMapMode );
2016920165 array.push( parameters.envMapCubeUVHeight );
2017020166 array.push( parameters.mapUv );
@@ -20284,12 +20280,10 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
2028420280 _programLayers.enable( 15 );
2028520281 if ( parameters.sheen )
2028620282 _programLayers.enable( 16 );
20287- if ( parameters.decodeVideoTexture )
20288- _programLayers.enable( 17 );
2028920283 if ( parameters.opaque )
20290- _programLayers.enable( 18 );
20284+ _programLayers.enable( 17 );
2029120285 if ( parameters.pointsUvs )
20292- _programLayers.enable( 19 );
20286+ _programLayers.enable( 18 );
2029320287
2029420288 array.push( _programLayers.mask );
2029520289
@@ -22149,7 +22143,7 @@ function WebGLState( gl, extensions, capabilities ) {
2214922143 const currentScissor = new Vector4().fromArray( scissorParam );
2215022144 const currentViewport = new Vector4().fromArray( viewportParam );
2215122145
22152- function createTexture( type, target, count ) {
22146+ function createTexture( type, target, count, dimensions ) {
2215322147
2215422148 const data = new Uint8Array( 4 ); // 4 is required to match default unpack alignment of 4.
2215522149 const texture = gl.createTexture();
@@ -22160,7 +22154,15 @@ function WebGLState( gl, extensions, capabilities ) {
2216022154
2216122155 for ( let i = 0; i < count; i ++ ) {
2216222156
22163- gl.texImage2D( target + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
22157+ if ( isWebGL2 && ( type === gl.TEXTURE_3D || type === gl.TEXTURE_2D_ARRAY ) ) {
22158+
22159+ gl.texImage3D( target, 0, gl.RGBA, 1, 1, dimensions, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
22160+
22161+ } else {
22162+
22163+ gl.texImage2D( target + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
22164+
22165+ }
2216422166
2216522167 }
2216622168
@@ -22172,6 +22174,13 @@ function WebGLState( gl, extensions, capabilities ) {
2217222174 emptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );
2217322175 emptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );
2217422176
22177+ if ( isWebGL2 ) {
22178+
22179+ emptyTextures[ gl.TEXTURE_2D_ARRAY ] = createTexture( gl.TEXTURE_2D_ARRAY, gl.TEXTURE_2D_ARRAY, 1, 1 );
22180+ emptyTextures[ gl.TEXTURE_3D ] = createTexture( gl.TEXTURE_3D, gl.TEXTURE_3D, 1, 1 );
22181+
22182+ }
22183+
2217522184 // init
2217622185
2217722186 colorBuffer.setClear( 0, 0, 0, 1 );
@@ -23774,7 +23783,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2377423783 glFormat = utils.convert( texture.format, texture.encoding );
2377523784
2377623785 let glType = utils.convert( texture.type ),
23777- glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding, texture.isVideoTexture );
23786+ glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
2377823787
2377923788 setTextureParameters( textureType, texture, supportsMips );
2378023789
@@ -24997,7 +25006,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2499725006 const format = texture.format;
2499825007 const type = texture.type;
2499925008
25000- if ( texture.isCompressedTexture === true || texture.isVideoTexture === true || texture. format === _SRGBAFormat ) return image;
25009+ if ( texture.isCompressedTexture === true || texture.format === _SRGBAFormat ) return image;
2500125010
2500225011 if ( encoding !== LinearEncoding ) {
2500325012
@@ -26012,7 +26021,7 @@ class WebXRManager extends EventDispatcher {
2601226021 {
2601326022 format: RGBAFormat,
2601426023 type: UnsignedByteType,
26015- encoding: renderer.outputEncoding ,
26024+ encoding: renderer.outputColorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding ,
2601626025 stencilBuffer: attributes.stencil
2601726026 }
2601826027 );
@@ -26051,7 +26060,7 @@ class WebXRManager extends EventDispatcher {
2605126060 type: UnsignedByteType,
2605226061 depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
2605326062 stencilBuffer: attributes.stencil,
26054- encoding: renderer.outputEncoding ,
26063+ encoding: renderer.outputColorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding ,
2605526064 samples: attributes.antialias ? 4 : 0
2605626065 } );
2605726066
@@ -27586,7 +27595,7 @@ class WebGLRenderer {
2758627595
2758727596 // physically based shading
2758827597
27589- this.outputEncoding = LinearEncoding ;
27598+ this.outputColorSpace = LinearSRGBColorSpace ;
2759027599
2759127600 // physical lights
2759227601
@@ -28949,7 +28958,7 @@ class WebGLRenderer {
2894928958
2895028959 const materialProperties = properties.get( material );
2895128960
28952- materialProperties.outputEncoding = parameters.outputEncoding ;
28961+ materialProperties.outputColorSpace = parameters.outputColorSpace ;
2895328962 materialProperties.instancing = parameters.instancing;
2895428963 materialProperties.skinning = parameters.skinning;
2895528964 materialProperties.morphTargets = parameters.morphTargets;
@@ -28972,7 +28981,7 @@ class WebGLRenderer {
2897228981
2897328982 const fog = scene.fog;
2897428983 const environment = material.isMeshStandardMaterial ? scene.environment : null;
28975- const encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.encoding : LinearEncoding );
28984+ const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? ( _currentRenderTarget.texture.encoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace ) : LinearSRGBColorSpace );
2897628985 const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment );
2897728986 const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
2897828987 const vertexTangents = !! material.normalMap && !! geometry.attributes.tangent;
@@ -29014,7 +29023,7 @@ class WebGLRenderer {
2901429023
2901529024 needsProgramChange = true;
2901629025
29017- } else if ( materialProperties.outputEncoding !== encoding ) {
29026+ } else if ( materialProperties.outputColorSpace !== colorSpace ) {
2901829027
2901929028 needsProgramChange = true;
2902029029
@@ -29763,6 +29772,20 @@ class WebGLRenderer {
2976329772
2976429773 }
2976529774
29775+ get outputEncoding() { // @deprecated, r152
29776+
29777+ console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
29778+ return this.outputColorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding;
29779+
29780+ }
29781+
29782+ set outputEncoding( encoding ) { // @deprecated, r152
29783+
29784+ console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
29785+ this.outputColorSpace = encoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
29786+
29787+ }
29788+
2976629789}
2976729790
2976829791class WebGL1Renderer extends WebGLRenderer {}
0 commit comments