|
1 |
| -import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping } from '../../constants.js'; |
| 1 | +import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, sRGBEncoding } from '../../constants.js'; |
2 | 2 | import * as MathUtils from '../../math/MathUtils.js';
|
3 | 3 | import { createElementNS } from '../../utils.js';
|
4 | 4 |
|
@@ -132,7 +132,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
132 | 132 |
|
133 | 133 | }
|
134 | 134 |
|
135 |
| - function getInternalFormat( internalFormatName, glFormat, glType ) { |
| 135 | + function getInternalFormat( internalFormatName, glFormat, glType, encoding ) { |
136 | 136 |
|
137 | 137 | if ( isWebGL2 === false ) return glFormat;
|
138 | 138 |
|
@@ -166,7 +166,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
166 | 166 |
|
167 | 167 | if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
|
168 | 168 | if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
|
169 |
| - if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8; |
| 169 | + if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( encoding === sRGBEncoding ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8; |
170 | 170 |
|
171 | 171 | }
|
172 | 172 |
|
@@ -532,7 +532,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
532 | 532 | glFormat = utils.convert( texture.format );
|
533 | 533 |
|
534 | 534 | let glType = utils.convert( texture.type ),
|
535 |
| - glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType ); |
| 535 | + glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); |
536 | 536 |
|
537 | 537 | setTextureParameters( textureType, texture, supportsMips );
|
538 | 538 |
|
@@ -758,7 +758,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
758 | 758 | supportsMips = isPowerOfTwo( image ) || isWebGL2,
|
759 | 759 | glFormat = utils.convert( texture.format ),
|
760 | 760 | glType = utils.convert( texture.type ),
|
761 |
| - glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType ); |
| 761 | + glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); |
762 | 762 |
|
763 | 763 | setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
|
764 | 764 |
|
@@ -857,7 +857,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
857 | 857 |
|
858 | 858 | const glFormat = utils.convert( texture.format );
|
859 | 859 | const glType = utils.convert( texture.type );
|
860 |
| - const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType ); |
| 860 | + const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); |
861 | 861 |
|
862 | 862 | if ( textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY ) {
|
863 | 863 |
|
@@ -938,7 +938,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
938 | 938 |
|
939 | 939 | const glFormat = utils.convert( texture.format );
|
940 | 940 | const glType = utils.convert( texture.type );
|
941 |
| - const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType ); |
| 941 | + const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); |
942 | 942 |
|
943 | 943 | if ( isMultisample ) {
|
944 | 944 |
|
@@ -1131,7 +1131,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
1131 | 1131 |
|
1132 | 1132 | const glFormat = utils.convert( texture.format );
|
1133 | 1133 | const glType = utils.convert( texture.type );
|
1134 |
| - const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType ); |
| 1134 | + const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding ); |
1135 | 1135 | const samples = getRenderTargetSamples( renderTarget );
|
1136 | 1136 | _gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
1137 | 1137 |
|
|
0 commit comments