|
@@ -1,4 +1,4 @@
|
|
|
-import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, sRGBEncoding, LinearEncoding, UnsignedByteType, _SRGBAFormat } from '../../constants.js';
|
|
|
+import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace, SRGBColorSpace } from '../../constants.js';
|
|
|
import * as MathUtils from '../../math/MathUtils.js';
|
|
|
import { ImageUtils } from '../../extras/ImageUtils.js';
|
|
|
import { createElementNS } from '../../utils.js';
|
|
@@ -135,7 +135,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
}
|
|
|
|
|
|
- function getInternalFormat( internalFormatName, glFormat, glType, encoding, forceLinearEncoding = false ) {
|
|
|
+ function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
|
|
|
|
|
|
if ( isWebGL2 === false ) return glFormat;
|
|
|
|
|
@@ -169,7 +169,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
|
|
|
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
|
|
|
- if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( encoding === sRGBEncoding && forceLinearEncoding === false ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
|
|
|
+ if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( colorSpace === SRGBColorSpace && forceLinearTransfer === false ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
|
|
|
if ( glType === _gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = _gl.RGBA4;
|
|
|
if ( glType === _gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = _gl.RGB5_A1;
|
|
|
|
|
@@ -426,7 +426,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
array.push( texture.premultiplyAlpha );
|
|
|
array.push( texture.flipY );
|
|
|
array.push( texture.unpackAlignment );
|
|
|
- array.push( texture.encoding );
|
|
|
+ array.push( texture.colorSpace );
|
|
|
|
|
|
return array.join();
|
|
|
|
|
@@ -698,10 +698,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
image = verifyColorSpace( texture, image );
|
|
|
|
|
|
const supportsMips = isPowerOfTwo( image ) || isWebGL2,
|
|
|
- glFormat = utils.convert( texture.format, texture.encoding );
|
|
|
+ glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
|
|
|
|
let glType = utils.convert( texture.type ),
|
|
|
- glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
|
|
|
+ glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
|
|
|
|
setTextureParameters( textureType, texture, supportsMips );
|
|
|
|
|
@@ -1130,9 +1130,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
const image = cubeImage[ 0 ],
|
|
|
supportsMips = isPowerOfTwo( image ) || isWebGL2,
|
|
|
- glFormat = utils.convert( texture.format, texture.encoding ),
|
|
|
+ glFormat = utils.convert( texture.format, texture.colorSpace ),
|
|
|
glType = utils.convert( texture.type ),
|
|
|
- glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
|
|
|
+ glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
|
|
|
|
const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
|
|
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
@@ -1299,9 +1299,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
// Setup storage for target texture and bind it to correct framebuffer
|
|
|
function setupFrameBufferTexture( framebuffer, renderTarget, texture, attachment, textureTarget ) {
|
|
|
|
|
|
- const glFormat = utils.convert( texture.format, texture.encoding );
|
|
|
+ const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
|
const glType = utils.convert( texture.type );
|
|
|
- const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
|
|
|
+ const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
|
const renderTargetProperties = properties.get( renderTarget );
|
|
|
|
|
|
if ( ! renderTargetProperties.__hasExternalTextures ) {
|
|
@@ -1411,9 +1411,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
const texture = textures[ i ];
|
|
|
|
|
|
- const glFormat = utils.convert( texture.format, texture.encoding );
|
|
|
+ const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
|
const glType = utils.convert( texture.type );
|
|
|
- const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
|
|
|
+ const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
|
const samples = getRenderTargetSamples( renderTarget );
|
|
|
|
|
|
if ( isMultisample && useMultisampledRTT( renderTarget ) === false ) {
|
|
@@ -1646,9 +1646,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
|
|
|
|
- const glFormat = utils.convert( texture.format, texture.encoding );
|
|
|
+ const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
|
const glType = utils.convert( texture.type );
|
|
|
- const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding, renderTarget.isXRRenderTarget === true );
|
|
|
+ const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, renderTarget.isXRRenderTarget === true );
|
|
|
const samples = getRenderTargetSamples( renderTarget );
|
|
|
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
|
|
|
@@ -1920,17 +1920,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
function verifyColorSpace( texture, image ) {
|
|
|
|
|
|
- const encoding = texture.encoding;
|
|
|
+ const colorSpace = texture.colorSpace;
|
|
|
const format = texture.format;
|
|
|
const type = texture.type;
|
|
|
|
|
|
if ( texture.isCompressedTexture === true || texture.format === _SRGBAFormat ) return image;
|
|
|
|
|
|
- if ( encoding !== LinearEncoding ) {
|
|
|
+ if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
|
|
|
|
|
|
// sRGB
|
|
|
|
|
|
- if ( encoding === sRGBEncoding ) {
|
|
|
+ if ( colorSpace === SRGBColorSpace ) {
|
|
|
|
|
|
if ( isWebGL2 === false ) {
|
|
|
|
|
@@ -1967,7 +1967,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- console.error( 'THREE.WebGLTextures: Unsupported texture encoding:', encoding );
|
|
|
+ console.error( 'THREE.WebGLTextures: Unsupported texture color space:', colorSpace );
|
|
|
|
|
|
}
|
|
|
|