Browse Source

Texture+WebGLRenderTarget: Replace .encoding with .colorSpace (#25771)

* Texture+WebGLRenderTarget: Replace .encoding with .colorSpace

* Fix typo

* Update WebGLCubeRenderTarget.js

* WebGLRenderer: Update remaining use of .encoding

* Examples: Update examples, replace .encoding → .colorSpace

---------

Co-authored-by: Michael Herzog <[email protected]>
Don McCurdy 2 năm trước cách đây
mục cha
commit
88c95377c1
78 tập tin đã thay đổi với 320 bổ sung248 xóa
  1. 1 1
      docs/examples/en/loaders/GLTFLoader.html
  2. 1 1
      docs/examples/zh/loaders/GLTFLoader.html
  3. 2 2
      examples/jsm/exporters/EXRExporter.js
  4. 4 4
      examples/jsm/exporters/GLTFExporter.js
  5. 34 23
      examples/jsm/exporters/KTX2Exporter.js
  6. 2 2
      examples/jsm/interactive/HTMLMesh.js
  7. 11 9
      examples/jsm/lights/LightProbeGenerator.js
  8. 2 2
      examples/jsm/loaders/3MFLoader.js
  9. 7 7
      examples/jsm/loaders/ColladaLoader.js
  10. 6 6
      examples/jsm/loaders/EXRLoader.js
  11. 5 5
      examples/jsm/loaders/FBXLoader.js
  12. 9 9
      examples/jsm/loaders/GLTFLoader.js
  13. 4 4
      examples/jsm/loaders/HDRCubeTextureLoader.js
  14. 9 8
      examples/jsm/loaders/KTX2Loader.js
  15. 2 2
      examples/jsm/loaders/MTLLoader.js
  16. 2 2
      examples/jsm/loaders/RGBELoader.js
  17. 3 3
      examples/jsm/loaders/USDZLoader.js
  18. 2 2
      examples/jsm/misc/MD2Character.js
  19. 2 2
      examples/jsm/misc/MD2CharacterComplex.js
  20. 14 6
      examples/jsm/nodes/core/NodeBuilder.js
  21. 6 6
      examples/jsm/renderers/webgpu/WebGPUTextures.js
  22. 1 2
      examples/jsm/renderers/webgpu/WebGPUUtils.js
  23. 1 1
      examples/misc_controls_arcball.html
  24. 2 2
      examples/misc_exporter_collada.html
  25. 2 2
      examples/webgl_geometry_teapot.html
  26. 1 1
      examples/webgl_lightningstrike.html
  27. 1 1
      examples/webgl_lightprobe.html
  28. 1 1
      examples/webgl_lightprobe_cubecamera.html
  29. 4 4
      examples/webgl_lights_physical.html
  30. 1 1
      examples/webgl_lights_spotlight.html
  31. 1 1
      examples/webgl_loader_md2.html
  32. 1 1
      examples/webgl_loader_md2_control.html
  33. 1 1
      examples/webgl_materials_displacementmap.html
  34. 2 2
      examples/webgl_materials_envmaps.html
  35. 1 1
      examples/webgl_materials_envmaps_exr.html
  36. 1 1
      examples/webgl_materials_envmaps_hdr.html
  37. 3 3
      examples/webgl_materials_matcap.html
  38. 2 2
      examples/webgl_materials_normalmap.html
  39. 1 1
      examples/webgl_materials_physical_clearcoat.html
  40. 1 1
      examples/webgl_materials_standard.html
  41. 2 2
      examples/webgl_materials_variations_basic.html
  42. 2 2
      examples/webgl_materials_variations_lambert.html
  43. 2 2
      examples/webgl_materials_variations_phong.html
  44. 1 1
      examples/webgl_nodes_materials_physical_clearcoat.html
  45. 1 1
      examples/webgl_nodes_materials_standard.html
  46. 1 1
      examples/webgl_portal.html
  47. 1 1
      examples/webgl_postprocessing_3dlut.html
  48. 2 2
      examples/webgl_postprocessing_advanced.html
  49. 5 5
      examples/webgl_shaders_tonemapping.html
  50. 1 1
      manual/examples/load-obj-auto-camera-xz.html
  51. 1 1
      manual/examples/load-obj-auto-camera.html
  52. 1 1
      manual/examples/load-obj-materials-fixed.html
  53. 1 1
      manual/examples/load-obj-materials-windmill2.html
  54. 1 1
      manual/examples/load-obj-materials.html
  55. 1 1
      manual/examples/load-obj-no-materials.html
  56. 1 1
      manual/examples/load-obj-wat.html
  57. 1 1
      manual/examples/postprocessing-3dlut-identity.html
  58. 1 1
      manual/examples/postprocessing-3dlut-prep.html
  59. 1 1
      manual/examples/postprocessing-3dlut-w-loader.html
  60. 1 1
      manual/examples/postprocessing-3dlut.html
  61. 2 0
      src/constants.js
  62. 3 3
      src/extras/PMREMGenerator.js
  63. 5 1
      src/loaders/DataTextureLoader.js
  64. 2 1
      src/loaders/ObjectLoader.js
  65. 12 3
      src/renderers/WebGLCubeRenderTarget.js
  66. 11 2
      src/renderers/WebGLRenderTarget.js
  67. 1 1
      src/renderers/WebGLRenderer.js
  68. 3 3
      src/renderers/webgl/WebGLBackground.js
  69. 2 2
      src/renderers/webgl/WebGLPrograms.js
  70. 18 18
      src/renderers/webgl/WebGLTextures.js
  71. 20 20
      src/renderers/webgl/WebGLUtils.js
  72. 3 13
      src/renderers/webxr/WebXRManager.js
  73. 2 2
      src/textures/CompressedTexture.js
  74. 2 2
      src/textures/CubeTexture.js
  75. 2 2
      src/textures/DataTexture.js
  76. 34 10
      src/textures/Texture.js
  77. 13 1
      src/utils.js
  78. 1 1
      test/unit/src/textures/Texture.tests.js

+ 1 - 1
docs/examples/en/loaders/GLTFLoader.html

@@ -144,7 +144,7 @@
 
 		<code>
 		// If texture is used for color information, set colorspace.
-		texture.encoding = THREE.sRGBEncoding;
+		texture.colorSpace = THREE.SRGBColorSpace;
 
 		// UVs use the convention that (0, 0) corresponds to the upper left corner of a texture.
 		texture.flipY = false;

+ 1 - 1
docs/examples/zh/loaders/GLTFLoader.html

@@ -149,7 +149,7 @@
 
 		<code>
 		// If texture is used for color information, set colorspace.
-		texture.encoding = THREE.sRGBEncoding;
+		texture.colorSpace = THREE.SRGBColorSpace;
 
 		// UVs use the convention that (0, 0) corresponds to the upper left corner of a texture.
 		texture.flipY = false;

+ 2 - 2
examples/jsm/exporters/EXRExporter.js

@@ -87,7 +87,7 @@ function buildInfo( renderTarget, options = {} ) {
 		HEIGHT = renderTarget.height,
 		TYPE = renderTarget.texture.type,
 		FORMAT = renderTarget.texture.format,
-		ENCODING = renderTarget.texture.encoding,
+		COLOR_SPACE = renderTarget.texture.colorSpace,
 		COMPRESSION = ( options.compression !== undefined ) ? options.compression : ZIP_COMPRESSION,
 		EXPORTER_TYPE = ( options.type !== undefined ) ? options.type : HalfFloatType,
 		OUT_TYPE = ( EXPORTER_TYPE === FloatType ) ? 2 : 1,
@@ -99,7 +99,7 @@ function buildInfo( renderTarget, options = {} ) {
 		height: HEIGHT,
 		type: TYPE,
 		format: FORMAT,
-		encoding: ENCODING,
+		colorSpace: COLOR_SPACE,
 		compression: COMPRESSION,
 		blockLines: COMPRESSION_SIZE,
 		dataType: OUT_TYPE,

+ 4 - 4
examples/jsm/exporters/GLTFExporter.js

@@ -5,7 +5,7 @@ import {
 	DoubleSide,
 	InterpolateDiscrete,
 	InterpolateLinear,
-	LinearEncoding,
+	NoColorSpace,
 	LinearFilter,
 	LinearMipmapLinearFilter,
 	LinearMipmapNearestFilter,
@@ -20,7 +20,7 @@ import {
 	RepeatWrapping,
 	Scene,
 	Source,
-	sRGBEncoding,
+	SRGBColorSpace,
 	Vector3
 } from 'three';
 
@@ -801,7 +801,7 @@ class GLTFWriter {
 
 		function getEncodingConversion( map ) {
 
-			if ( map.encoding === sRGBEncoding ) {
+			if ( map.colorSpace === SRGBColorSpace ) {
 
 				return function SRGBToLinear( c ) {
 
@@ -876,7 +876,7 @@ class GLTFWriter {
 		const texture = reference.clone();
 
 		texture.source = new Source( canvas );
-		texture.encoding = LinearEncoding;
+		texture.colorSpace = NoColorSpace;
 
 		return texture;
 

+ 34 - 23
examples/jsm/exporters/KTX2Exporter.js

@@ -7,8 +7,9 @@ import {
 	RGIntegerFormat,
 	RedFormat,
 	RedIntegerFormat,
-	LinearEncoding,
-	sRGBEncoding,
+	NoColorSpace,
+	LinearSRGBColorSpace,
+	SRGBColorSpace,
 	DataTexture,
 	REVISION,
 } from 'three';
@@ -22,6 +23,7 @@ import {
 	KHR_DF_CHANNEL_RGBSDA_RED,
 	KHR_DF_MODEL_RGBSDA,
 	KHR_DF_PRIMARIES_BT709,
+	KHR_DF_PRIMARIES_UNSPECIFIED,
 	KHR_DF_SAMPLE_DATATYPE_FLOAT,
 	KHR_DF_SAMPLE_DATATYPE_LINEAR,
 	KHR_DF_SAMPLE_DATATYPE_SIGNED,
@@ -45,40 +47,49 @@ const VK_FORMAT_MAP = {
 
 	[ RGBAFormat ]: {
 		[ FloatType ]: {
-			[ LinearEncoding ]: VK_FORMAT_R32G32B32A32_SFLOAT,
+			[ NoColorSpace ]: VK_FORMAT_R32G32B32A32_SFLOAT,
+			[ LinearSRGBColorSpace ]: VK_FORMAT_R32G32B32A32_SFLOAT,
 		},
 		[ HalfFloatType ]: {
-			[ LinearEncoding ]: VK_FORMAT_R16G16B16A16_SFLOAT,
+			[ NoColorSpace ]: VK_FORMAT_R16G16B16A16_SFLOAT,
+			[ LinearSRGBColorSpace ]: VK_FORMAT_R16G16B16A16_SFLOAT,
 		},
 		[ UnsignedByteType ]: {
-			[ LinearEncoding ]: VK_FORMAT_R8G8B8A8_UNORM,
-			[ sRGBEncoding ]: VK_FORMAT_R8G8B8A8_SRGB,
+			[ NoColorSpace ]: VK_FORMAT_R8G8B8A8_UNORM,
+			[ LinearSRGBColorSpace ]: VK_FORMAT_R8G8B8A8_UNORM,
+			[ SRGBColorSpace ]: VK_FORMAT_R8G8B8A8_SRGB,
 		},
 	},
 
 	[ RGFormat ]: {
 		[ FloatType ]: {
-			[ LinearEncoding ]: VK_FORMAT_R32G32_SFLOAT,
+			[ NoColorSpace ]: VK_FORMAT_R32G32_SFLOAT,
+			[ LinearSRGBColorSpace ]: VK_FORMAT_R32G32_SFLOAT,
 		},
 		[ HalfFloatType ]: {
-			[ LinearEncoding ]: VK_FORMAT_R16G16_SFLOAT,
+			[ NoColorSpace ]: VK_FORMAT_R16G16_SFLOAT,
+			[ LinearSRGBColorSpace ]: VK_FORMAT_R16G16_SFLOAT,
 		},
 		[ UnsignedByteType ]: {
-			[ LinearEncoding ]: VK_FORMAT_R8G8_UNORM,
-			[ sRGBEncoding ]: VK_FORMAT_R8G8_SRGB,
+			[ NoColorSpace ]: VK_FORMAT_R8G8_UNORM,
+			[ LinearSRGBColorSpace ]: VK_FORMAT_R8G8_UNORM,
+			[ SRGBColorSpace ]: VK_FORMAT_R8G8_SRGB,
 		},
 	},
 
 	[ RedFormat ]: {
 		[ FloatType ]: {
-			[ LinearEncoding ]: VK_FORMAT_R32_SFLOAT,
+			[ NoColorSpace ]: VK_FORMAT_R32_SFLOAT,
+			[ LinearSRGBColorSpace ]: VK_FORMAT_R32_SFLOAT,
 		},
 		[ HalfFloatType ]: {
-			[ LinearEncoding ]: VK_FORMAT_R16_SFLOAT,
+			[ NoColorSpace ]: VK_FORMAT_R16_SFLOAT,
+			[ LinearSRGBColorSpace ]: VK_FORMAT_R16_SFLOAT,
 		},
 		[ UnsignedByteType ]: {
-			[ LinearEncoding ]: VK_FORMAT_R8_SRGB,
-			[ sRGBEncoding ]: VK_FORMAT_R8_UNORM,
+			[ NoColorSpace ]: VK_FORMAT_R8_UNORM,
+			[ LinearSRGBColorSpace ]: VK_FORMAT_R8_UNORM,
+			[ SRGBColorSpace ]: VK_FORMAT_R8_SRGB,
 		},
 	},
 
@@ -96,7 +107,7 @@ const KHR_DF_CHANNEL_MAP = {
 const ERROR_INPUT = 'THREE.KTX2Exporter: Supported inputs are DataTexture, Data3DTexture, or WebGLRenderer and WebGLRenderTarget.';
 const ERROR_FORMAT = 'THREE.KTX2Exporter: Supported formats are RGBAFormat, RGFormat, or RedFormat.';
 const ERROR_TYPE = 'THREE.KTX2Exporter: Supported types are FloatType, HalfFloatType, or UnsignedByteType."';
-const ERROR_ENCODING = 'THREE.KTX2Exporter: Supported encodings are sRGB (UnsignedByteType only) or Linear.';
+const ERROR_COLOR_SPACE = 'THREE.KTX2Exporter: Supported color spaces are SRGBColorSpace (UnsignedByteType only), LinearSRGBColorSpace, or NoColorSpace.';
 
 export class KTX2Exporter {
 
@@ -130,9 +141,9 @@ export class KTX2Exporter {
 
 		}
 
-		if ( VK_FORMAT_MAP[ texture.format ][ texture.type ][ texture.encoding ] === undefined ) {
+		if ( VK_FORMAT_MAP[ texture.format ][ texture.type ][ texture.colorSpace ] === undefined ) {
 
-			throw new Error( ERROR_ENCODING );
+			throw new Error( ERROR_COLOR_SPACE );
 
 		}
 
@@ -142,7 +153,7 @@ export class KTX2Exporter {
 		const channelCount = getChannelCount( texture );
 		const container = new KTX2Container();
 
-		container.vkFormat = VK_FORMAT_MAP[ texture.format ][ texture.type ][ texture.encoding ];
+		container.vkFormat = VK_FORMAT_MAP[ texture.format ][ texture.type ][ texture.colorSpace ];
 		container.typeSize = array.BYTES_PER_ELEMENT;
 		container.pixelWidth = texture.image.width;
 		container.pixelHeight = texture.image.height;
@@ -157,11 +168,11 @@ export class KTX2Exporter {
 
 		const basicDesc = container.dataFormatDescriptor[ 0 ];
 
-		// TODO: After `texture.encoding` is replaced, distinguish between
-		// non-color data (unspecified model and primaries) and sRGB or Linear-sRGB colors.
 		basicDesc.colorModel = KHR_DF_MODEL_RGBSDA;
-		basicDesc.colorPrimaries = KHR_DF_PRIMARIES_BT709;
-		basicDesc.transferFunction = texture.encoding === sRGBEncoding
+		basicDesc.colorPrimaries = texture.colorSpace === NoColorSpace
+			? KHR_DF_PRIMARIES_UNSPECIFIED
+			: KHR_DF_PRIMARIES_BT709;
+		basicDesc.transferFunction = texture.colorSpace === SRGBColorSpace
 			? KHR_DF_TRANSFER_SRGB
 			: KHR_DF_TRANSFER_LINEAR;
 
@@ -177,7 +188,7 @@ export class KTX2Exporter {
 
 			let channelType = KHR_DF_CHANNEL_MAP[ i ];
 
-			if ( texture.encoding === LinearEncoding ) {
+			if ( texture.colorSpace === LinearSRGBColorSpace || texture.colorSpace === NoColorSpace ) {
 
 				channelType |= KHR_DF_SAMPLE_DATATYPE_LINEAR;
 

+ 2 - 2
examples/jsm/interactive/HTMLMesh.js

@@ -4,7 +4,7 @@ import {
 	Mesh,
 	MeshBasicMaterial,
 	PlaneGeometry,
-	sRGBEncoding,
+	SRGBColorSpace,
 	Color
 } from 'three';
 
@@ -59,7 +59,7 @@ class HTMLTexture extends CanvasTexture {
 		this.dom = dom;
 
 		this.anisotropy = 16;
-		this.encoding = sRGBEncoding;
+		this.colorSpace = SRGBColorSpace;
 		this.minFilter = LinearFilter;
 		this.magFilter = LinearFilter;
 

+ 11 - 9
examples/jsm/lights/LightProbeGenerator.js

@@ -1,10 +1,11 @@
 import {
 	Color,
 	LightProbe,
-	LinearEncoding,
+	LinearSRGBColorSpace,
 	SphericalHarmonics3,
 	Vector3,
-	sRGBEncoding
+	SRGBColorSpace,
+	NoColorSpace
 } from 'three';
 
 class LightProbeGenerator {
@@ -55,7 +56,7 @@ class LightProbeGenerator {
 				color.setRGB( data[ i ] / 255, data[ i + 1 ] / 255, data[ i + 2 ] / 255 );
 
 				// convert to linear color space
-				convertColorToLinear( color, cubeTexture.encoding );
+				convertColorToLinear( color, cubeTexture.colorSpace );
 
 				// pixel coordinate on unit cube
 
@@ -153,7 +154,7 @@ class LightProbeGenerator {
 				color.setRGB( data[ i ] / 255, data[ i + 1 ] / 255, data[ i + 2 ] / 255 );
 
 				// convert to linear color space
-				convertColorToLinear( color, cubeRenderTarget.texture.encoding );
+				convertColorToLinear( color, cubeRenderTarget.texture.colorSpace );
 
 				// pixel coordinate on unit cube
 
@@ -223,22 +224,23 @@ class LightProbeGenerator {
 
 }
 
-function convertColorToLinear( color, encoding ) {
+function convertColorToLinear( color, colorSpace ) {
 
-	switch ( encoding ) {
+	switch ( colorSpace ) {
 
-		case sRGBEncoding:
+		case SRGBColorSpace:
 
 			color.convertSRGBToLinear();
 			break;
 
-		case LinearEncoding:
+		case LinearSRGBColorSpace:
+		case NoColorSpace:
 
 			break;
 
 		default:
 
-			console.warn( 'WARNING: LightProbeGenerator convertColorToLinear() encountered an unsupported encoding.' );
+			console.warn( 'WARNING: LightProbeGenerator convertColorToLinear() encountered an unsupported color space.' );
 			break;
 
 	}

+ 2 - 2
examples/jsm/loaders/3MFLoader.js

@@ -17,7 +17,7 @@ import {
 	NearestFilter,
 	RepeatWrapping,
 	TextureLoader,
-	sRGBEncoding
+	SRGBColorSpace
 } from 'three';
 import * as fflate from '../libs/fflate.module.js';
 
@@ -789,7 +789,7 @@ class ThreeMFLoader extends Loader {
 
 				} );
 
-				texture.encoding = sRGBEncoding;
+				texture.colorSpace = SRGBColorSpace;
 
 				// texture parameters
 

+ 7 - 7
examples/jsm/loaders/ColladaLoader.js

@@ -36,7 +36,7 @@ import {
 	Vector2,
 	Vector3,
 	VectorKeyframeTrack,
-	sRGBEncoding
+	SRGBColorSpace
 } from 'three';
 import { TGALoader } from '../loaders/TGALoader.js';
 
@@ -1579,7 +1579,7 @@ class ColladaLoader extends Loader {
 
 			material.name = data.name || '';
 
-			function getTexture( textureObject, encoding = null ) {
+			function getTexture( textureObject, colorSpace = null ) {
 
 				const sampler = effect.profile.samplers[ textureObject.id ];
 				let image = null;
@@ -1627,9 +1627,9 @@ class ColladaLoader extends Loader {
 
 						}
 
-						if ( encoding !== null ) {
+						if ( colorSpace !== null ) {
 
-							texture.encoding = encoding;
+							texture.colorSpace = colorSpace;
 
 						}
 
@@ -1663,7 +1663,7 @@ class ColladaLoader extends Loader {
 
 					case 'diffuse':
 						if ( parameter.color ) material.color.fromArray( parameter.color );
-						if ( parameter.texture ) material.map = getTexture( parameter.texture, sRGBEncoding );
+						if ( parameter.texture ) material.map = getTexture( parameter.texture, SRGBColorSpace );
 						break;
 					case 'specular':
 						if ( parameter.color && material.specular ) material.specular.fromArray( parameter.color );
@@ -1673,14 +1673,14 @@ class ColladaLoader extends Loader {
 						if ( parameter.texture ) material.normalMap = getTexture( parameter.texture );
 						break;
 					case 'ambient':
-						if ( parameter.texture ) material.lightMap = getTexture( parameter.texture, sRGBEncoding );
+						if ( parameter.texture ) material.lightMap = getTexture( parameter.texture, SRGBColorSpace );
 						break;
 					case 'shininess':
 						if ( parameter.float && material.shininess ) material.shininess = parameter.float;
 						break;
 					case 'emission':
 						if ( parameter.color && material.emissive ) material.emissive.fromArray( parameter.color );
-						if ( parameter.texture ) material.emissiveMap = getTexture( parameter.texture, sRGBEncoding );
+						if ( parameter.texture ) material.emissiveMap = getTexture( parameter.texture, SRGBColorSpace );
 						break;
 
 				}

+ 6 - 6
examples/jsm/loaders/EXRLoader.js

@@ -3,7 +3,7 @@ import {
 	DataUtils,
 	FloatType,
 	HalfFloatType,
-	LinearEncoding,
+	NoColorSpace,
 	LinearFilter,
 	RedFormat,
 	RGBAFormat
@@ -2072,7 +2072,7 @@ class EXRLoader extends DataTextureLoader {
 				uncompress: null,
 				getter: null,
 				format: null,
-				encoding: null,
+				colorSpace: NoColorSpace,
 			};
 
 			switch ( EXRHeader.compression ) {
@@ -2204,12 +2204,12 @@ class EXRLoader extends DataTextureLoader {
 			if ( EXRDecoder.outputChannels == 4 ) {
 
 				EXRDecoder.format = RGBAFormat;
-				EXRDecoder.encoding = LinearEncoding;
+				EXRDecoder.colorSpace = NoColorSpace;
 
 			} else {
 
 				EXRDecoder.format = RedFormat;
-				EXRDecoder.encoding = LinearEncoding;
+				EXRDecoder.colorSpace = NoColorSpace;
 
 			}
 
@@ -2272,7 +2272,7 @@ class EXRLoader extends DataTextureLoader {
 			height: EXRDecoder.height,
 			data: EXRDecoder.byteArray,
 			format: EXRDecoder.format,
-			encoding: EXRDecoder.encoding,
+			colorSpace: EXRDecoder.colorSpace,
 			type: this.type,
 		};
 
@@ -2289,7 +2289,7 @@ class EXRLoader extends DataTextureLoader {
 
 		function onLoadCallback( texture, texData ) {
 
-			texture.encoding = texData.encoding;
+			texture.colorSpace = texData.colorSpace;
 			texture.minFilter = LinearFilter;
 			texture.magFilter = LinearFilter;
 			texture.generateMipmaps = false;

+ 5 - 5
examples/jsm/loaders/FBXLoader.js

@@ -39,7 +39,7 @@ import {
 	Vector3,
 	Vector4,
 	VectorKeyframeTrack,
-	sRGBEncoding
+	SRGBColorSpace
 } from 'three';
 import * as fflate from '../libs/fflate.module.js';
 import { NURBSCurve } from '../curves/NURBSCurve.js';
@@ -629,7 +629,7 @@ class FBXTreeParser {
 					parameters.map = scope.getTexture( textureMap, child.ID );
 					if ( parameters.map !== undefined ) {
 
-						parameters.map.encoding = sRGBEncoding;
+						parameters.map.colorSpace = SRGBColorSpace;
 
 					}
 
@@ -643,7 +643,7 @@ class FBXTreeParser {
 					parameters.emissiveMap = scope.getTexture( textureMap, child.ID );
 					if ( parameters.emissiveMap !== undefined ) {
 
-						parameters.emissiveMap.encoding = sRGBEncoding;
+						parameters.emissiveMap.colorSpace = SRGBColorSpace;
 
 					}
 
@@ -659,7 +659,7 @@ class FBXTreeParser {
 					if ( parameters.envMap !== undefined ) {
 
 						parameters.envMap.mapping = EquirectangularReflectionMapping;
-						parameters.envMap.encoding = sRGBEncoding;
+						parameters.envMap.colorSpace = SRGBColorSpace;
 
 					}
 
@@ -669,7 +669,7 @@ class FBXTreeParser {
 					parameters.specularMap = scope.getTexture( textureMap, child.ID );
 					if ( parameters.specularMap !== undefined ) {
 
-						parameters.specularMap.encoding = sRGBEncoding;
+						parameters.specularMap.colorSpace = SRGBColorSpace;
 
 					}
 

+ 9 - 9
examples/jsm/loaders/GLTFLoader.js

@@ -60,7 +60,7 @@ import {
 	Vector2,
 	Vector3,
 	VectorKeyframeTrack,
-	sRGBEncoding
+	SRGBColorSpace
 } from 'three';
 import { toTrianglesDrawMode } from '../utils/BufferGeometryUtils.js';
 
@@ -663,7 +663,7 @@ class GLTFMaterialsUnlitExtension {
 
 			if ( metallicRoughness.baseColorTexture !== undefined ) {
 
-				pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, sRGBEncoding ) );
+				pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, SRGBColorSpace ) );
 
 			}
 
@@ -944,7 +944,7 @@ class GLTFMaterialsSheenExtension {
 
 		if ( extension.sheenColorTexture !== undefined ) {
 
-			pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, sRGBEncoding ) );
+			pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, SRGBColorSpace ) );
 
 		}
 
@@ -1177,7 +1177,7 @@ class GLTFMaterialsSpecularExtension {
 
 		if ( extension.specularColorTexture !== undefined ) {
 
-			pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, sRGBEncoding ) );
+			pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, SRGBColorSpace ) );
 
 		}
 
@@ -3117,7 +3117,7 @@ class GLTFParser {
 	 * @param {Object} mapDef
 	 * @return {Promise<Texture>}
 	 */
-	assignTexture( materialParams, mapName, mapDef, encoding ) {
+	assignTexture( materialParams, mapName, mapDef, colorSpace ) {
 
 		const parser = this;
 
@@ -3146,9 +3146,9 @@ class GLTFParser {
 
 			}
 
-			if ( encoding !== undefined ) {
+			if ( colorSpace !== undefined ) {
 
-				texture.encoding = encoding;
+				texture.colorSpace = colorSpace;
 
 			}
 
@@ -3309,7 +3309,7 @@ class GLTFParser {
 
 			if ( metallicRoughness.baseColorTexture !== undefined ) {
 
-				pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, sRGBEncoding ) );
+				pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, SRGBColorSpace ) );
 
 			}
 
@@ -3400,7 +3400,7 @@ class GLTFParser {
 
 		if ( materialDef.emissiveTexture !== undefined && materialType !== MeshBasicMaterial ) {
 
-			pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture, sRGBEncoding ) );
+			pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture, SRGBColorSpace ) );
 
 		}
 

+ 4 - 4
examples/jsm/loaders/HDRCubeTextureLoader.js

@@ -4,7 +4,7 @@ import {
 	FileLoader,
 	FloatType,
 	HalfFloatType,
-	LinearEncoding,
+	NoColorSpace,
 	LinearFilter,
 	Loader
 } from 'three';
@@ -31,7 +31,7 @@ class HDRCubeTextureLoader extends Loader {
 
 			case FloatType:
 
-				texture.encoding = LinearEncoding;
+				texture.colorSpace = NoColorSpace;
 				texture.minFilter = LinearFilter;
 				texture.magFilter = LinearFilter;
 				texture.generateMipmaps = false;
@@ -39,7 +39,7 @@ class HDRCubeTextureLoader extends Loader {
 
 			case HalfFloatType:
 
-				texture.encoding = LinearEncoding;
+				texture.colorSpace = NoColorSpace;
 				texture.minFilter = LinearFilter;
 				texture.magFilter = LinearFilter;
 				texture.generateMipmaps = false;
@@ -70,7 +70,7 @@ class HDRCubeTextureLoader extends Loader {
 						const dataTexture = new DataTexture( texData.data, texData.width, texData.height );
 
 						dataTexture.type = texture.type;
-						dataTexture.encoding = texture.encoding;
+						dataTexture.colorSpace = texture.colorSpace;
 						dataTexture.format = texture.format;
 						dataTexture.minFilter = texture.minFilter;
 						dataTexture.magFilter = texture.magFilter;

+ 9 - 8
examples/jsm/loaders/KTX2Loader.js

@@ -19,7 +19,7 @@ import {
 	FileLoader,
 	FloatType,
 	HalfFloatType,
-	LinearEncoding,
+	NoColorSpace,
 	LinearFilter,
 	LinearMipmapLinearFilter,
 	Loader,
@@ -35,7 +35,7 @@ import {
 	RGBA_S3TC_DXT5_Format,
 	RGBAFormat,
 	RGFormat,
-	sRGBEncoding,
+	SRGBColorSpace,
 	UnsignedByteType,
 } from 'three';
 import { WorkerPool } from '../utils/WorkerPool.js';
@@ -253,7 +253,8 @@ class KTX2Loader extends Loader {
 		texture.generateMipmaps = false;
 
 		texture.needsUpdate = true;
-		texture.encoding = dfdTransferFn === KHR_DF_TRANSFER_SRGB ? sRGBEncoding : LinearEncoding;
+		// TODO: Detect NoColorSpace vs. LinearSRGBColorSpace based on primaries.
+		texture.colorSpace = dfdTransferFn === KHR_DF_TRANSFER_SRGB ? SRGBColorSpace : NoColorSpace;
 		texture.premultiplyAlpha = !! ( dfdFlags & KHR_DF_FLAG_ALPHA_PREMULTIPLIED );
 
 		return texture;
@@ -697,11 +698,11 @@ const TYPE_MAP = {
 
 };
 
-const ENCODING_MAP = {
+const COLOR_SPACE_MAP = {
 
-	[ VK_FORMAT_R8G8B8A8_SRGB ]: sRGBEncoding,
-	[ VK_FORMAT_R8G8_SRGB ]: sRGBEncoding,
-	[ VK_FORMAT_R8_SRGB ]: sRGBEncoding,
+	[ VK_FORMAT_R8G8B8A8_SRGB ]: SRGBColorSpace,
+	[ VK_FORMAT_R8G8_SRGB ]: SRGBColorSpace,
+	[ VK_FORMAT_R8_SRGB ]: SRGBColorSpace,
 
 };
 
@@ -779,7 +780,7 @@ async function createDataTexture( container ) {
 
 	texture.type = TYPE_MAP[ vkFormat ];
 	texture.format = FORMAT_MAP[ vkFormat ];
-	texture.encoding = ENCODING_MAP[ vkFormat ] || LinearEncoding;
+	texture.colorSpace = COLOR_SPACE_MAP[ vkFormat ] || NoColorSpace;
 
 	texture.needsUpdate = true;
 

+ 2 - 2
examples/jsm/loaders/MTLLoader.js

@@ -9,7 +9,7 @@ import {
 	RepeatWrapping,
 	TextureLoader,
 	Vector2,
-	sRGBEncoding
+	SRGBColorSpace
 } from 'three';
 
 /**
@@ -361,7 +361,7 @@ class MaterialCreator {
 
 			if ( mapType === 'map' || mapType === 'emissiveMap' ) {
 
-				map.encoding = sRGBEncoding;
+				map.colorSpace = SRGBColorSpace;
 
 			}
 

+ 2 - 2
examples/jsm/loaders/RGBELoader.js

@@ -3,7 +3,7 @@ import {
 	DataUtils,
 	FloatType,
 	HalfFloatType,
-	LinearEncoding,
+	NoColorSpace,
 	LinearFilter
 } from 'three';
 
@@ -445,7 +445,7 @@ class RGBELoader extends DataTextureLoader {
 				case FloatType:
 				case HalfFloatType:
 
-					texture.encoding = LinearEncoding;
+					texture.colorSpace = NoColorSpace;
 					texture.minFilter = LinearFilter;
 					texture.magFilter = LinearFilter;
 					texture.generateMipmaps = false;

+ 3 - 3
examples/jsm/loaders/USDZLoader.js

@@ -9,7 +9,7 @@ import {
 	MeshStandardMaterial,
 	MirroredRepeatWrapping,
 	RepeatWrapping,
-	sRGBEncoding,
+	SRGBColorSpace,
 	TextureLoader,
 	Object3D,
 } from 'three';
@@ -457,7 +457,7 @@ class USDZLoader extends Loader {
 						const sampler = findTexture( root, /(\w+).output/.exec( path )[ 1 ] );
 
 						material.map = buildTexture( sampler );
-						material.map.encoding = sRGBEncoding;
+						material.map.colorSpace = SRGBColorSpace;
 
 					} else if ( 'color3f inputs:diffuseColor' in surface ) {
 
@@ -494,7 +494,7 @@ class USDZLoader extends Loader {
 					const sampler = data[ 'def Shader "diffuseColor_texture"' ];
 
 					material.map = buildTexture( sampler );
-					material.map.encoding = sRGBEncoding;
+					material.map.colorSpace = SRGBColorSpace;
 
 				}
 

+ 2 - 2
examples/jsm/misc/MD2Character.js

@@ -6,7 +6,7 @@ import {
 	Object3D,
 	TextureLoader,
 	UVMapping,
-	sRGBEncoding
+	SRGBColorSpace
 } from 'three';
 import { MD2Loader } from '../loaders/MD2Loader.js';
 
@@ -73,7 +73,7 @@ class MD2Character {
 				textures[ i ] = textureLoader.load( baseUrl + textureUrls[ i ], checkLoadingComplete );
 				textures[ i ].mapping = UVMapping;
 				textures[ i ].name = textureUrls[ i ];
-				textures[ i ].encoding = sRGBEncoding;
+				textures[ i ].colorSpace = SRGBColorSpace;
 
 			}
 

+ 2 - 2
examples/jsm/misc/MD2CharacterComplex.js

@@ -5,7 +5,7 @@ import {
 	Object3D,
 	TextureLoader,
 	UVMapping,
-	sRGBEncoding
+	SRGBColorSpace
 } from 'three';
 import { MD2Loader } from '../loaders/MD2Loader.js';
 import { MorphBlendMesh } from '../misc/MorphBlendMesh.js';
@@ -157,7 +157,7 @@ class MD2CharacterComplex {
 				textures[ i ] = textureLoader.load( baseUrl + textureUrls[ i ], checkLoadingComplete );
 				textures[ i ].mapping = UVMapping;
 				textures[ i ].name = textureUrls[ i ];
-				textures[ i ].encoding = sRGBEncoding;
+				textures[ i ].colorSpace = SRGBColorSpace;
 
 			}
 

+ 14 - 6
examples/jsm/nodes/core/NodeBuilder.js

@@ -7,7 +7,7 @@ import NodeKeywords from './NodeKeywords.js';
 import NodeCache from './NodeCache.js';
 import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
 
-import { REVISION, LinearEncoding, Color, Vector2, Vector3, Vector4 } from 'three';
+import { REVISION, NoColorSpace, LinearEncoding, sRGBEncoding, SRGBColorSpace, Color, Vector2, Vector3, Vector4 } from 'three';
 
 import { stack } from './StackNode.js';
 import { maxMipLevel } from '../utils/MaxMipLevelNode.js';
@@ -356,25 +356,33 @@ class NodeBuilder {
 
 	}
 
+	/** @deprecated, r152 */
 	getTextureEncodingFromMap( map ) {
 
-		let encoding;
+		console.warn( 'THREE.NodeBuilder: Method .getTextureEncodingFromMap replaced by .getTextureColorSpaceFromMap in r152+.' );
+		return this.getTextureColorSpaceFromMap( map ) === SRGBColorSpace ? sRGBEncoding : LinearEncoding;
+
+	}
+
+	getTextureColorSpaceFromMap( map ) {
+
+		let colorSpace;
 
 		if ( map && map.isTexture ) {
 
-			encoding = map.encoding;
+			colorSpace = map.colorSpace;
 
 		} else if ( map && map.isWebGLRenderTarget ) {
 
-			encoding = map.texture.encoding;
+			colorSpace = map.texture.colorSpace;
 
 		} else {
 
-			encoding = LinearEncoding;
+			colorSpace = NoColorSpace;
 
 		}
 
-		return encoding;
+		return colorSpace;
 
 	}
 

+ 6 - 6
examples/jsm/renderers/webgpu/WebGPUTextures.js

@@ -1,6 +1,6 @@
 import { GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension } from './constants.js';
 import { VideoTexture, CubeTexture, Texture, NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearFilter, RepeatWrapping, MirroredRepeatWrapping,
-	RGBAFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, sRGBEncoding
+	RGBAFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBColorSpace
 } from 'three';
 import WebGPUTextureUtils from './WebGPUTextureUtils.js';
 
@@ -607,22 +607,22 @@ class WebGPUTextures {
 
 		const format = texture.format;
 		const type = texture.type;
-		const encoding = texture.encoding;
+		const colorSpace = texture.colorSpace;
 
 		let formatGPU;
 
 		switch ( format ) {
 
 			case RGBA_S3TC_DXT1_Format:
-				formatGPU = ( encoding === sRGBEncoding ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
+				formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
 				break;
 
 			case RGBA_S3TC_DXT3_Format:
-				formatGPU = ( encoding === sRGBEncoding ) ? GPUTextureFormat.BC2RGBAUnormSRGB : GPUTextureFormat.BC2RGBAUnorm;
+				formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC2RGBAUnormSRGB : GPUTextureFormat.BC2RGBAUnorm;
 				break;
 
 			case RGBA_S3TC_DXT5_Format:
-				formatGPU = ( encoding === sRGBEncoding ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
+				formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
 				break;
 
 			case RGBAFormat:
@@ -630,7 +630,7 @@ class WebGPUTextures {
 				switch ( type ) {
 
 					case UnsignedByteType:
-						formatGPU = ( encoding === sRGBEncoding ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
+						formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
 						break;
 
 					case HalfFloatType:

+ 1 - 2
examples/jsm/renderers/webgpu/WebGPUUtils.js

@@ -1,4 +1,3 @@
-import { LinearSRGBColorSpace, SRGBColorSpace, sRGBEncoding } from 'three';
 import { GPUPrimitiveTopology, GPUTextureFormat } from './constants.js';
 
 class WebGPUUtils {
@@ -17,7 +16,7 @@ class WebGPUUtils {
 
 		if ( renderTarget !== null ) {
 
-			return renderTarget.texture.encoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
+			return renderTarget.texture.colorSpace;
 
 		}
 

+ 1 - 1
examples/misc_controls_arcball.html

@@ -128,7 +128,7 @@
 						material.metalness = 1;
 
 						const diffuseMap = textureLoader.load( 'Cerberus_A.jpg', render );
-						diffuseMap.encoding = THREE.sRGBEncoding;
+						diffuseMap.colorSpace = THREE.SRGBColorSpace;
 						material.map = diffuseMap;
 
 						material.metalnessMap = material.roughnessMap = textureLoader.load( 'Cerberus_RM.jpg', render );

+ 2 - 2
examples/misc_exporter_collada.html

@@ -102,7 +102,7 @@
 				const textureMap = loader.load( 'textures/uv_grid_opengl.jpg' );
 				textureMap.wrapS = textureMap.wrapT = THREE.RepeatWrapping;
 				textureMap.anisotropy = 16;
-				textureMap.encoding = THREE.sRGBEncoding;
+				textureMap.colorSpace = THREE.SRGBColorSpace;
 
 				// NORMAL MAP
 
@@ -118,7 +118,7 @@
 				];
 
 				textureCube = new THREE.CubeTextureLoader().load( urls );
-				textureCube.encoding = THREE.sRGBEncoding;
+				textureCube.colorSpace = THREE.SRGBColorSpace;
 
 				// MATERIALS
 				const materialColor = new THREE.Color();

+ 2 - 2
examples/webgl_geometry_teapot.html

@@ -90,14 +90,14 @@
 				const textureMap = new THREE.TextureLoader().load( 'textures/uv_grid_opengl.jpg' );
 				textureMap.wrapS = textureMap.wrapT = THREE.RepeatWrapping;
 				textureMap.anisotropy = 16;
-				textureMap.encoding = THREE.sRGBEncoding;
+				textureMap.colorSpace = THREE.SRGBColorSpace;
 
 				// REFLECTION MAP
 				const path = 'textures/cube/pisa/';
 				const urls = [ 'px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png' ];
 
 				textureCube = new THREE.CubeTextureLoader().setPath( path ).load( urls );
-				textureCube.encoding = THREE.sRGBEncoding;
+				textureCube.colorSpace = THREE.SRGBColorSpace;
 
 				materials[ 'wireframe' ] = new THREE.MeshBasicMaterial( { wireframe: true } );
 				materials[ 'flat' ] = new THREE.MeshPhongMaterial( { specular: 0x000000, flatShading: true, side: THREE.DoubleSide } );

+ 1 - 1
examples/webgl_lightningstrike.html

@@ -429,7 +429,7 @@
 
 				const textureCube = new THREE.CubeTextureLoader().load( urls );
 				textureCube.mapping = THREE.CubeReflectionMapping;
-				textureCube.encoding = THREE.sRGBEncoding;
+				textureCube.colorSpace = THREE.SRGBColorSpace;
 
 				const sphereMaterial = new THREE.MeshPhysicalMaterial( {
 					transparent: true,

+ 1 - 1
examples/webgl_lightprobe.html

@@ -101,7 +101,7 @@
 
 				new THREE.CubeTextureLoader().load( urls, function ( cubeTexture ) {
 
-					cubeTexture.encoding = THREE.sRGBEncoding;
+					cubeTexture.colorSpace = THREE.SRGBColorSpace;
 
 					scene.background = cubeTexture;
 

+ 1 - 1
examples/webgl_lightprobe_cubecamera.html

@@ -85,7 +85,7 @@
 
 				new THREE.CubeTextureLoader().load( urls, function ( cubeTexture ) {
 
-					cubeTexture.encoding = THREE.sRGBEncoding;
+					cubeTexture.colorSpace = THREE.SRGBColorSpace;
 
 					scene.background = cubeTexture;
 

+ 4 - 4
examples/webgl_lights_physical.html

@@ -124,7 +124,7 @@
 					map.wrapT = THREE.RepeatWrapping;
 					map.anisotropy = 4;
 					map.repeat.set( 10, 24 );
-					map.encoding = THREE.sRGBEncoding;
+					map.colorSpace = THREE.SRGBColorSpace;
 					floorMat.map = map;
 					floorMat.needsUpdate = true;
 
@@ -162,7 +162,7 @@
 					map.wrapT = THREE.RepeatWrapping;
 					map.anisotropy = 4;
 					map.repeat.set( 1, 1 );
-					map.encoding = THREE.sRGBEncoding;
+					map.colorSpace = THREE.SRGBColorSpace;
 					cubeMat.map = map;
 					cubeMat.needsUpdate = true;
 
@@ -186,7 +186,7 @@
 				textureLoader.load( 'textures/planets/earth_atmos_2048.jpg', function ( map ) {
 
 					map.anisotropy = 4;
-					map.encoding = THREE.sRGBEncoding;
+					map.colorSpace = THREE.SRGBColorSpace;
 					ballMat.map = map;
 					ballMat.needsUpdate = true;
 
@@ -194,7 +194,7 @@
 				textureLoader.load( 'textures/planets/earth_specular_2048.jpg', function ( map ) {
 
 					map.anisotropy = 4;
-					map.encoding = THREE.sRGBEncoding;
+					map.colorSpace = THREE.SRGBColorSpace;
 					ballMat.metalnessMap = map;
 					ballMat.needsUpdate = true;
 

+ 1 - 1
examples/webgl_lights_spotlight.html

@@ -84,7 +84,7 @@
 					const texture = loader.load( filename );
 					texture.minFilter = THREE.LinearFilter;
 					texture.magFilter = THREE.LinearFilter;
-					texture.encoding = THREE.sRGBEncoding;
+					texture.colorSpace = THREE.SRGBColorSpace;
 
 					textures[ filename ] = texture;
 

+ 1 - 1
examples/webgl_loader_md2.html

@@ -115,7 +115,7 @@
 				ground.rotation.x = - Math.PI / 2;
 				ground.material.map.repeat.set( 8, 8 );
 				ground.material.map.wrapS = ground.material.map.wrapT = THREE.RepeatWrapping;
-				ground.material.map.encoding = THREE.sRGBEncoding;
+				ground.material.map.colorSpace = THREE.SRGBColorSpace;
 				ground.receiveShadow = true;
 
 				scene.add( ground );

+ 1 - 1
examples/webgl_loader_md2_control.html

@@ -123,7 +123,7 @@
 				ground.material.map.repeat.set( 64, 64 );
 				ground.material.map.wrapS = THREE.RepeatWrapping;
 				ground.material.map.wrapT = THREE.RepeatWrapping;
-				ground.material.map.encoding = THREE.sRGBEncoding;
+				ground.material.map.colorSpace = THREE.SRGBColorSpace;
 				// note that because the ground does not cast a shadow, .castShadow is left false
 				ground.receiveShadow = true;
 

+ 1 - 1
examples/webgl_materials_displacementmap.html

@@ -162,7 +162,7 @@
 				];
 
 				const reflectionCube = new THREE.CubeTextureLoader().load( urls );
-				reflectionCube.encoding = THREE.sRGBEncoding;
+				reflectionCube.colorSpace = THREE.SRGBColorSpace;
 
 				// textures
 

+ 2 - 2
examples/webgl_materials_envmaps.html

@@ -57,13 +57,13 @@
 				loader.setPath( 'textures/cube/Bridge2/' );
 
 				textureCube = loader.load( [ 'posx.jpg', 'negx.jpg', 'posy.jpg', 'negy.jpg', 'posz.jpg', 'negz.jpg' ] );
-				textureCube.encoding = THREE.sRGBEncoding;
+				textureCube.colorSpace = THREE.SRGBColorSpace;
 
 				const textureLoader = new THREE.TextureLoader();
 
 				textureEquirec = textureLoader.load( 'textures/2294472375_24a3b8ef46_o.jpg' );
 				textureEquirec.mapping = THREE.EquirectangularReflectionMapping;
-				textureEquirec.encoding = THREE.sRGBEncoding;
+				textureEquirec.colorSpace = THREE.SRGBColorSpace;
 
 				scene.background = textureCube;
 

+ 1 - 1
examples/webgl_materials_envmaps_exr.html

@@ -108,7 +108,7 @@
 				new THREE.TextureLoader().load( 'textures/equirectangular.png', function ( texture ) {
 
 					texture.mapping = THREE.EquirectangularReflectionMapping;
-					texture.encoding = THREE.sRGBEncoding;
+					texture.colorSpace = THREE.SRGBColorSpace;
 
 					pngCubeRenderTarget = pmremGenerator.fromEquirectangular( texture );
 					pngBackground = texture;

+ 1 - 1
examples/webgl_materials_envmaps_hdr.html

@@ -116,7 +116,7 @@
 					.setPath( './textures/cube/pisa/' )
 					.load( ldrUrls, function () {
 
-						ldrCubeMap.encoding = THREE.sRGBEncoding;
+						ldrCubeMap.colorSpace = THREE.SRGBColorSpace;
 
 						ldrCubeRenderTarget = pmremGenerator.fromCubemap( ldrCubeMap );
 

+ 3 - 3
examples/webgl_materials_matcap.html

@@ -163,7 +163,7 @@
 
 				texture.needsUpdate = true;
 
-				mesh.material.needsUpdate = true; // because the encoding can change
+				mesh.material.needsUpdate = true; // because the color space can change
 
 				render();
 
@@ -175,7 +175,7 @@
 
 					const texture = new THREE.Texture( event.target );
 
-					texture.encoding = THREE.sRGBEncoding;
+					texture.colorSpace = THREE.SRGBColorSpace;
 
 					updateMatcap( texture );
 
@@ -207,7 +207,7 @@
 
 				texture.format = texData.format;
 				texture.type = texData.type;
-				texture.encoding = THREE.LinearEncoding;
+				texture.colorSpace = THREE.LinearSRGBColorSpace;
 				texture.minFilter = THREE.LinearFilter;
 				texture.magFilter = THREE.LinearFilter;
 				texture.generateMipmaps = false;

+ 2 - 2
examples/webgl_materials_normalmap.html

@@ -91,10 +91,10 @@
 				const textureLoader = new THREE.TextureLoader();
 
 				const diffuseMap = textureLoader.load( 'models/gltf/LeePerrySmith/Map-COL.jpg' );
-				diffuseMap.encoding = THREE.sRGBEncoding;
+				diffuseMap.colorSpace = THREE.SRGBColorSpace;
 
 				const specularMap = textureLoader.load( 'models/gltf/LeePerrySmith/Map-SPEC.jpg' );
-				specularMap.encoding = THREE.sRGBEncoding;
+				specularMap.colorSpace = THREE.SRGBColorSpace;
 
 				const normalMap = textureLoader.load( 'models/gltf/LeePerrySmith/Infinite-Level_02_Tangent_SmoothUV.jpg' );
 

+ 1 - 1
examples/webgl_materials_physical_clearcoat.html

@@ -68,7 +68,7 @@
 							const textureLoader = new THREE.TextureLoader();
 
 							const diffuse = textureLoader.load( 'textures/carbon/Carbon.png' );
-							diffuse.encoding = THREE.sRGBEncoding;
+							diffuse.colorSpace = THREE.SRGBColorSpace;
 							diffuse.wrapS = THREE.RepeatWrapping;
 							diffuse.wrapT = THREE.RepeatWrapping;
 							diffuse.repeat.x = 10;

+ 1 - 1
examples/webgl_materials_standard.html

@@ -88,7 +88,7 @@
 						material.metalness = 1; // attenuates metalnessMap
 
 						const diffuseMap = loader.load( 'Cerberus_A.jpg' );
-						diffuseMap.encoding = THREE.sRGBEncoding;
+						diffuseMap.colorSpace = THREE.SRGBColorSpace;
 						material.map = diffuseMap;
 						// roughness is in G channel, metalness is in B channel
 						material.metalnessMap = material.roughnessMap = loader.load( 'Cerberus_RM.jpg' );

+ 2 - 2
examples/webgl_materials_variations_basic.html

@@ -60,7 +60,7 @@
 				const reflectionCube = new THREE.CubeTextureLoader()
 					.setPath( 'textures/cube/SwedishRoyalCastle/' )
 					.load( [ 'px.jpg', 'nx.jpg', 'py.jpg', 'ny.jpg', 'pz.jpg', 'nz.jpg' ] );
-				reflectionCube.encoding = THREE.sRGBEncoding;
+				reflectionCube.colorSpace = THREE.SRGBColorSpace;
 
 				scene = new THREE.Scene();
 				scene.background = reflectionCube;
@@ -69,7 +69,7 @@
 
 				let imgTexture = new THREE.TextureLoader().load( 'textures/planets/moon_1024.jpg' );
 				imgTexture.wrapS = imgTexture.wrapT = THREE.RepeatWrapping;
-				imgTexture.encoding = THREE.sRGBEncoding;
+				imgTexture.colorSpace = THREE.SRGBColorSpace;
 				imgTexture.anisotropy = 16;
 				imgTexture = null;
 

+ 2 - 2
examples/webgl_materials_variations_lambert.html

@@ -60,7 +60,7 @@
 				const reflectionCube = new THREE.CubeTextureLoader()
 					.setPath( 'textures/cube/SwedishRoyalCastle/' )
 					.load( [ 'px.jpg', 'nx.jpg', 'py.jpg', 'ny.jpg', 'pz.jpg', 'nz.jpg' ] );
-				reflectionCube.encoding = THREE.sRGBEncoding;
+				reflectionCube.colorSpace = THREE.SRGBColorSpace;
 
 				scene = new THREE.Scene();
 				scene.background = reflectionCube;
@@ -69,7 +69,7 @@
 
 				let imgTexture = new THREE.TextureLoader().load( 'textures/planets/moon_1024.jpg' );
 				imgTexture.wrapS = imgTexture.wrapT = THREE.RepeatWrapping;
-				imgTexture.encoding = THREE.sRGBEncoding;
+				imgTexture.colorSpace = THREE.SRGBColorSpace;
 				imgTexture.anisotropy = 16;
 				imgTexture = null;
 

+ 2 - 2
examples/webgl_materials_variations_phong.html

@@ -60,7 +60,7 @@
 				const reflectionCube = new THREE.CubeTextureLoader()
 					.setPath( 'textures/cube/SwedishRoyalCastle/' )
 					.load( [ 'px.jpg', 'nx.jpg', 'py.jpg', 'ny.jpg', 'pz.jpg', 'nz.jpg' ] );
-				reflectionCube.encoding = THREE.sRGBEncoding;
+				reflectionCube.colorSpace = THREE.SRGBColorSpace;
 
 				scene = new THREE.Scene();
 				scene.background = reflectionCube;
@@ -69,7 +69,7 @@
 
 				let imgTexture = new THREE.TextureLoader().load( 'textures/planets/moon_1024.jpg' );
 				imgTexture.wrapS = imgTexture.wrapT = THREE.RepeatWrapping;
-				imgTexture.encoding = THREE.sRGBEncoding;
+				imgTexture.colorSpace = THREE.SRGBColorSpace;
 				imgTexture.anisotropy = 16;
 				imgTexture = null;
 

+ 1 - 1
examples/webgl_nodes_materials_physical_clearcoat.html

@@ -72,7 +72,7 @@
 							const textureLoader = new THREE.TextureLoader();
 
 							const diffuse = textureLoader.load( 'textures/carbon/Carbon.png' );
-							diffuse.encoding = THREE.sRGBEncoding;
+							diffuse.colorSpace = THREE.SRGBColorSpace;
 							diffuse.wrapS = THREE.RepeatWrapping;
 							diffuse.wrapT = THREE.RepeatWrapping;
 

+ 1 - 1
examples/webgl_nodes_materials_standard.html

@@ -122,7 +122,7 @@
 
 						const diffuseMap = loader.load( 'Cerberus_A.jpg' );
 						diffuseMap.wrapS = THREE.RepeatWrapping;
-						diffuseMap.encoding = THREE.sRGBEncoding;
+						diffuseMap.colorSpace = THREE.SRGBColorSpace;
 
 						const rmMap = loader.load( 'Cerberus_RM.jpg' );
 						rmMap.wrapS = THREE.RepeatWrapping;

+ 1 - 1
examples/webgl_portal.html

@@ -196,7 +196,7 @@
 				CameraUtils.frameCorners( portalCamera, bottomLeftCorner, bottomRightCorner, topLeftCorner, false );
 
 				// render the portal
-				thisPortalTexture.texture.encoding = renderer.outputColorSpace === THREE.SRGBColorSpace ? THREE.sRGBEncoding : THREE.LinearEncoding;
+				thisPortalTexture.texture.colorSpace = renderer.outputColorSpace;
 				renderer.setRenderTarget( thisPortalTexture );
 				renderer.state.buffers.depth.setMask( true ); // make sure the depth buffer is writable so it can be properly cleared, see #18897
 				if ( renderer.autoClear === false ) renderer.clear();

+ 1 - 1
examples/webgl_postprocessing_3dlut.html

@@ -132,7 +132,7 @@
 					minFilter: THREE.LinearFilter,
 					magFilter: THREE.LinearFilter,
 					format: THREE.RGBAFormat,
-					encoding: THREE.sRGBEncoding
+					colorSpace: THREE.SRGBColorSpace
 				} );
 
 				composer = new EffectComposer( renderer, target );

+ 2 - 2
examples/webgl_postprocessing_advanced.html

@@ -105,7 +105,7 @@
 				//
 
 				const diffuseMap = new THREE.TextureLoader().load( 'textures/cube/SwedishRoyalCastle/pz.jpg' );
-				diffuseMap.encoding = THREE.sRGBEncoding;
+				diffuseMap.colorSpace = THREE.SRGBColorSpace;
 
 				const materialColor = new THREE.MeshBasicMaterial( {
 					map: diffuseMap,
@@ -295,7 +295,7 @@
 			function createMesh( geometry, scene, scale ) {
 
 				const diffuseMap = new THREE.TextureLoader().load( 'models/gltf/LeePerrySmith/Map-COL.jpg' );
-				diffuseMap.encoding = THREE.sRGBEncoding;
+				diffuseMap.colorSpace = THREE.SRGBColorSpace;
 
 				const mat2 = new THREE.MeshPhongMaterial( {
 

+ 5 - 5
examples/webgl_shaders_tonemapping.html

@@ -214,14 +214,14 @@
 				textureLoader.load( 'textures/planets/earth_atmos_4096.jpg', function ( tex ) {
 
 					earthMat.map = tex;
-					earthMat.map.encoding = THREE.sRGBEncoding;
+					earthMat.map.colorSpace = THREE.SRGBColorSpace;
 					earthMat.needsUpdate = true;
 
 				} );
 				textureLoader.load( 'textures/planets/earth_specular_2048.jpg', function ( tex ) {
 
 					earthMat.specularMap = tex;
-					earthMat.specularMap.encoding = THREE.sRGBEncoding;
+					earthMat.specularMap.colorSpace = THREE.SRGBColorSpace;
 					earthMat.needsUpdate = true;
 
 				} );
@@ -232,7 +232,7 @@
 				// } );
 
 				const earthLights = textureLoader.load( 'textures/planets/earth_lights_2048.png' );
-				earthLights.encoding = THREE.sRGBEncoding;
+				earthLights.colorSpace = THREE.SRGBColorSpace;
 
 				const earthLightsMat = new THREE.MeshBasicMaterial( {
 					color: 0xffffff,
@@ -244,7 +244,7 @@
 				} );
 
 				const clouds = textureLoader.load( 'textures/planets/earth_clouds_2048.png' );
-				clouds.encoding = THREE.sRGBEncoding;
+				clouds.colorSpace = THREE.SRGBColorSpace;
 
 				const earthCloudsMat = new THREE.MeshLambertMaterial( {
 					color: 0xffffff,
@@ -336,7 +336,7 @@
 							 r + 'dark-s_pz.jpg', r + 'dark-s_nz.jpg' ];
 
 				const textureCube = new THREE.CubeTextureLoader().load( urls );
-				textureCube.encoding = THREE.sRGBEncoding;
+				textureCube.colorSpace = THREE.SRGBColorSpace;
 
 				sceneCube.background = textureCube;
 

+ 1 - 1
manual/examples/load-obj-auto-camera-xz.html

@@ -62,7 +62,7 @@ function main() {
 
     const loader = new THREE.TextureLoader();
     const texture = loader.load('resources/images/checker.png');
-    texture.encoding = THREE.sRGBEncoding;
+    texture.colorSpace = THREE.SRGBColorSpace;
     texture.wrapS = THREE.RepeatWrapping;
     texture.wrapT = THREE.RepeatWrapping;
     texture.magFilter = THREE.NearestFilter;

+ 1 - 1
manual/examples/load-obj-auto-camera.html

@@ -62,7 +62,7 @@ function main() {
 
     const loader = new THREE.TextureLoader();
     const texture = loader.load('resources/images/checker.png');
-    texture.encoding = THREE.sRGBEncoding;
+    texture.colorSpace = THREE.SRGBColorSpace;
     texture.wrapS = THREE.RepeatWrapping;
     texture.wrapT = THREE.RepeatWrapping;
     texture.magFilter = THREE.NearestFilter;

+ 1 - 1
manual/examples/load-obj-materials-fixed.html

@@ -63,7 +63,7 @@ function main() {
 
     const loader = new THREE.TextureLoader();
     const texture = loader.load('resources/images/checker.png');
-    texture.encoding = THREE.sRGBEncoding;
+    texture.colorSpace = THREE.SRGBColorSpace;
     texture.wrapS = THREE.RepeatWrapping;
     texture.wrapT = THREE.RepeatWrapping;
     texture.magFilter = THREE.NearestFilter;

+ 1 - 1
manual/examples/load-obj-materials-windmill2.html

@@ -63,7 +63,7 @@ function main() {
 
     const loader = new THREE.TextureLoader();
     const texture = loader.load('resources/images/checker.png');
-    texture.encoding = THREE.sRGBEncoding;
+    texture.colorSpace = THREE.SRGBColorSpace;
     texture.wrapS = THREE.RepeatWrapping;
     texture.wrapT = THREE.RepeatWrapping;
     texture.magFilter = THREE.NearestFilter;

+ 1 - 1
manual/examples/load-obj-materials.html

@@ -63,7 +63,7 @@ function main() {
 
     const loader = new THREE.TextureLoader();
     const texture = loader.load('resources/images/checker.png');
-    texture.encoding = THREE.sRGBEncoding;
+    texture.colorSpace = THREE.SRGBColorSpace;
     texture.wrapS = THREE.RepeatWrapping;
     texture.wrapT = THREE.RepeatWrapping;
     texture.magFilter = THREE.NearestFilter;

+ 1 - 1
manual/examples/load-obj-no-materials.html

@@ -62,7 +62,7 @@ function main() {
 
     const loader = new THREE.TextureLoader();
     const texture = loader.load('resources/images/checker.png');
-    texture.encoding = THREE.sRGBEncoding;
+    texture.colorSpace = THREE.SRGBColorSpace;
     texture.wrapS = THREE.RepeatWrapping;
     texture.wrapT = THREE.RepeatWrapping;
     texture.magFilter = THREE.NearestFilter;

+ 1 - 1
manual/examples/load-obj-wat.html

@@ -62,7 +62,7 @@ function main() {
 
     const loader = new THREE.TextureLoader();
     const texture = loader.load('resources/images/checker.png');
-    texture.encoding = THREE.sRGBEncoding;
+    texture.colorSpace = THREE.SRGBColorSpace;
     texture.wrapS = THREE.RepeatWrapping;
     texture.wrapT = THREE.RepeatWrapping;
     texture.magFilter = THREE.NearestFilter;

+ 1 - 1
manual/examples/postprocessing-3dlut-identity.html

@@ -115,7 +115,7 @@ function main() {
   {
     const loader = new THREE.TextureLoader();
     bgTexture = loader.load('resources/images/beach.jpg');
-    bgTexture.encoding = THREE.sRGBEncoding;
+    bgTexture.colorSpace = THREE.SRGBColorSpace;
     const planeGeo = new THREE.PlaneGeometry(2, 2);
     const planeMat = new THREE.MeshBasicMaterial({
       map: bgTexture,

+ 1 - 1
manual/examples/postprocessing-3dlut-prep.html

@@ -65,7 +65,7 @@ function main() {
   {
     const loader = new THREE.TextureLoader();
     bgTexture = loader.load('resources/images/beach.jpg');
-    bgTexture.encoding = THREE.sRGBEncoding;
+    bgTexture.colorSpace = THREE.SRGBColorSpace;
     const planeGeo = new THREE.PlaneGeometry(2, 2);
     const planeMat = new THREE.MeshBasicMaterial({
       map: bgTexture,

+ 1 - 1
manual/examples/postprocessing-3dlut-w-loader.html

@@ -179,7 +179,7 @@ function main() {
   {
     const loader = new THREE.TextureLoader();
     bgTexture = loader.load('resources/images/beach.jpg');
-    bgTexture.encoding = THREE.sRGBEncoding;
+    bgTexture.colorSpace = THREE.SRGBColorSpace;
     const planeGeo = new THREE.PlaneGeometry(2, 2);
     const planeMat = new THREE.MeshBasicMaterial({
       map: bgTexture,

+ 1 - 1
manual/examples/postprocessing-3dlut.html

@@ -181,7 +181,7 @@ function main() {
   {
     const loader = new THREE.TextureLoader();
     bgTexture = loader.load('resources/images/beach.jpg');
-    bgTexture.encoding = THREE.sRGBEncoding;
+    bgTexture.colorSpace = THREE.SRGBColorSpace;
     const planeGeo = new THREE.PlaneGeometry(2, 2);
     const planeMat = new THREE.MeshBasicMaterial({
       map: bgTexture,

+ 2 - 0
src/constants.js

@@ -139,7 +139,9 @@ export const AdditiveAnimationBlendMode = 2501;
 export const TrianglesDrawMode = 0;
 export const TriangleStripDrawMode = 1;
 export const TriangleFanDrawMode = 2;
+/** @deprecated Use LinearSRGBColorSpace or NoColorSpace in three.js r152+. */
 export const LinearEncoding = 3000;
+/** @deprecated Use SRGBColorSpace in three.js r152+. */
 export const sRGBEncoding = 3001;
 export const BasicDepthPacking = 3200;
 export const RGBADepthPacking = 3201;

+ 3 - 3
src/extras/PMREMGenerator.js

@@ -2,13 +2,13 @@ import {
 	CubeReflectionMapping,
 	CubeRefractionMapping,
 	CubeUVReflectionMapping,
-	LinearEncoding,
 	LinearFilter,
 	NoToneMapping,
 	NoBlending,
 	RGBAFormat,
 	HalfFloatType,
-	BackSide
+	BackSide,
+	LinearSRGBColorSpace
 } from '../constants.js';
 
 import { BufferAttribute } from '../core/BufferAttribute.js';
@@ -255,7 +255,7 @@ class PMREMGenerator {
 			generateMipmaps: false,
 			type: HalfFloatType,
 			format: RGBAFormat,
-			encoding: LinearEncoding,
+			colorSpace: LinearSRGBColorSpace,
 			depthBuffer: false
 		};
 

+ 5 - 1
src/loaders/DataTextureLoader.js

@@ -54,7 +54,11 @@ class DataTextureLoader extends Loader {
 
 			texture.anisotropy = texData.anisotropy !== undefined ? texData.anisotropy : 1;
 
-			if ( texData.encoding !== undefined ) {
+			if ( texData.colorSpace !== undefined ) {
+
+				texture.colorSpace = texData.colorSpace;
+
+			} else if ( texData.encoding !== undefined ) { // @deprecated, r152
 
 				texture.encoding = texData.encoding;
 

+ 2 - 1
src/loaders/ObjectLoader.js

@@ -655,7 +655,8 @@ class ObjectLoader extends Loader {
 				if ( data.format !== undefined ) texture.format = data.format;
 				if ( data.internalFormat !== undefined ) texture.internalFormat = data.internalFormat;
 				if ( data.type !== undefined ) texture.type = data.type;
-				if ( data.encoding !== undefined ) texture.encoding = data.encoding;
+				if ( data.colorSpace !== undefined ) texture.colorSpace = data.colorSpace;
+				if ( data.encoding !== undefined ) texture.encoding = data.encoding; // @deprecated, r152
 
 				if ( data.minFilter !== undefined ) texture.minFilter = parseConstant( data.minFilter, TEXTURE_FILTER );
 				if ( data.magFilter !== undefined ) texture.magFilter = parseConstant( data.magFilter, TEXTURE_FILTER );

+ 12 - 3
src/renderers/WebGLCubeRenderTarget.js

@@ -1,4 +1,4 @@
-import { BackSide, LinearFilter, LinearMipmapLinearFilter, NoBlending } from '../constants.js';
+import { BackSide, LinearFilter, LinearMipmapLinearFilter, NoBlending, NoColorSpace, SRGBColorSpace, sRGBEncoding } from '../constants.js';
 import { Mesh } from '../objects/Mesh.js';
 import { BoxGeometry } from '../geometries/BoxGeometry.js';
 import { ShaderMaterial } from '../materials/ShaderMaterial.js';
@@ -6,6 +6,7 @@ import { cloneUniforms } from './shaders/UniformsUtils.js';
 import { WebGLRenderTarget } from './WebGLRenderTarget.js';
 import { CubeCamera } from '../cameras/CubeCamera.js';
 import { CubeTexture } from '../textures/CubeTexture.js';
+import { warnOnce } from '../utils.js';
 
 class WebGLCubeRenderTarget extends WebGLRenderTarget {
 
@@ -18,7 +19,15 @@ class WebGLCubeRenderTarget extends WebGLRenderTarget {
 		const image = { width: size, height: size, depth: 1 };
 		const images = [ image, image, image, image, image, image ];
 
-		this.texture = new CubeTexture( images, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
+		if ( options.encoding !== undefined ) {
+
+			// @deprecated, r152
+			warnOnce( 'THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace.' );
+			options.colorSpace = options.encoding === sRGBEncoding ? SRGBColorSpace : NoColorSpace;
+
+		}
+
+		this.texture = new CubeTexture( images, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
 
 		// By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js)
 		// in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words,
@@ -38,7 +47,7 @@ class WebGLCubeRenderTarget extends WebGLRenderTarget {
 	fromEquirectangularTexture( renderer, texture ) {
 
 		this.texture.type = texture.type;
-		this.texture.encoding = texture.encoding;
+		this.texture.colorSpace = texture.colorSpace;
 
 		this.texture.generateMipmaps = texture.generateMipmaps;
 		this.texture.minFilter = texture.minFilter;

+ 11 - 2
src/renderers/WebGLRenderTarget.js

@@ -1,8 +1,9 @@
 import { EventDispatcher } from '../core/EventDispatcher.js';
 import { Texture } from '../textures/Texture.js';
-import { LinearFilter } from '../constants.js';
+import { LinearFilter, NoColorSpace, SRGBColorSpace, sRGBEncoding } from '../constants.js';
 import { Vector4 } from '../math/Vector4.js';
 import { Source } from '../textures/Source.js';
+import { warnOnce } from '../utils.js';
 
 /*
  In options, we can specify:
@@ -28,7 +29,15 @@ class WebGLRenderTarget extends EventDispatcher {
 
 		const image = { width: width, height: height, depth: 1 };
 
-		this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
+		if ( options.encoding !== undefined ) {
+
+			// @deprecated, r152
+			warnOnce( 'THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace.' );
+			options.colorSpace = options.encoding === sRGBEncoding ? SRGBColorSpace : NoColorSpace;
+
+		}
+
+		this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
 		this.texture.isRenderTargetTexture = true;
 
 		this.texture.flipY = false;

+ 1 - 1
src/renderers/WebGLRenderer.js

@@ -1519,7 +1519,7 @@ class WebGLRenderer {
 
 			const fog = scene.fog;
 			const environment = material.isMeshStandardMaterial ? scene.environment : null;
-			const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? ( _currentRenderTarget.texture.encoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace ) : LinearSRGBColorSpace );
+			const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace );
 			const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment );
 			const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
 			const vertexTangents = !! material.normalMap && !! geometry.attributes.tangent;

+ 3 - 3
src/renderers/webgl/WebGLBackground.js

@@ -1,4 +1,4 @@
-import { BackSide, FrontSide, CubeUVReflectionMapping, sRGBEncoding } from '../../constants.js';
+import { BackSide, FrontSide, CubeUVReflectionMapping, SRGBColorSpace } from '../../constants.js';
 import { BoxGeometry } from '../../geometries/BoxGeometry.js';
 import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
 import { ShaderMaterial } from '../../materials/ShaderMaterial.js';
@@ -108,7 +108,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
 			boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
 			boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
 			boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
-			boxMesh.material.toneMapped = ( background.encoding === sRGBEncoding ) ? false : true;
+			boxMesh.material.toneMapped = ( background.colorSpace === SRGBColorSpace ) ? false : true;
 
 			if ( currentBackground !== background ||
 				currentBackgroundVersion !== background.version ||
@@ -164,7 +164,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
 
 			planeMesh.material.uniforms.t2D.value = background;
 			planeMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
-			planeMesh.material.toneMapped = ( background.encoding === sRGBEncoding ) ? false : true;
+			planeMesh.material.toneMapped = ( background.colorSpace === SRGBColorSpace ) ? false : true;
 
 			if ( background.matrixAutoUpdate === true ) {
 

+ 2 - 2
src/renderers/webgl/WebGLPrograms.js

@@ -1,4 +1,4 @@
-import { BackSide, DoubleSide, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, sRGBEncoding, NormalBlending, LinearSRGBColorSpace, SRGBColorSpace } from '../../constants.js';
+import { BackSide, DoubleSide, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, NormalBlending, LinearSRGBColorSpace } from '../../constants.js';
 import { Layers } from '../../core/Layers.js';
 import { WebGLProgram } from './WebGLProgram.js';
 import { WebGLShaderCache } from './WebGLShaderCache.js';
@@ -176,7 +176,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
 			instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
 
 			supportsVertexTextures: SUPPORTS_VERTEX_TEXTURES,
-			outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? ( currentRenderTarget.texture.encoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace ) : LinearSRGBColorSpace ),
+			outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace ),
 
 			map: HAS_MAP,
 			matcap: HAS_MATCAP,

+ 18 - 18
src/renderers/webgl/WebGLTextures.js

@@ -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 );
 
 			}
 

+ 20 - 20
src/renderers/webgl/WebGLUtils.js

@@ -1,10 +1,10 @@
-import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, sRGBEncoding, _SRGBAFormat, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format } from '../../constants.js';
+import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, _SRGBAFormat, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, SRGBColorSpace, NoColorSpace } from '../../constants.js';
 
 function WebGLUtils( gl, extensions, capabilities ) {
 
 	const isWebGL2 = capabilities.isWebGL2;
 
-	function convert( p, encoding = null ) {
+	function convert( p, colorSpace = NoColorSpace ) {
 
 		let extension;
 
@@ -74,7 +74,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
 
 		if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
 
-			if ( encoding === sRGBEncoding ) {
+			if ( colorSpace === SRGBColorSpace ) {
 
 				extension = extensions.get( 'WEBGL_compressed_texture_s3tc_srgb' );
 
@@ -159,8 +159,8 @@ function WebGLUtils( gl, extensions, capabilities ) {
 
 			if ( extension !== null ) {
 
-				if ( p === RGB_ETC2_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
-				if ( p === RGBA_ETC2_EAC_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
+				if ( p === RGB_ETC2_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
+				if ( p === RGBA_ETC2_EAC_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
 
 			} else {
 
@@ -182,20 +182,20 @@ function WebGLUtils( gl, extensions, capabilities ) {
 
 			if ( extension !== null ) {
 
-				if ( p === RGBA_ASTC_4x4_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
-				if ( p === RGBA_ASTC_5x4_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
-				if ( p === RGBA_ASTC_5x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
-				if ( p === RGBA_ASTC_6x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
-				if ( p === RGBA_ASTC_6x6_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
-				if ( p === RGBA_ASTC_8x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
-				if ( p === RGBA_ASTC_8x6_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
-				if ( p === RGBA_ASTC_8x8_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
-				if ( p === RGBA_ASTC_10x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
-				if ( p === RGBA_ASTC_10x6_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
-				if ( p === RGBA_ASTC_10x8_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
-				if ( p === RGBA_ASTC_10x10_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
-				if ( p === RGBA_ASTC_12x10_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
-				if ( p === RGBA_ASTC_12x12_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
+				if ( p === RGBA_ASTC_4x4_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
+				if ( p === RGBA_ASTC_5x4_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
+				if ( p === RGBA_ASTC_5x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
+				if ( p === RGBA_ASTC_6x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
+				if ( p === RGBA_ASTC_6x6_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
+				if ( p === RGBA_ASTC_8x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
+				if ( p === RGBA_ASTC_8x6_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
+				if ( p === RGBA_ASTC_8x8_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
+				if ( p === RGBA_ASTC_10x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
+				if ( p === RGBA_ASTC_10x6_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
+				if ( p === RGBA_ASTC_10x8_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
+				if ( p === RGBA_ASTC_10x10_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
+				if ( p === RGBA_ASTC_12x10_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
+				if ( p === RGBA_ASTC_12x12_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
 
 			} else {
 
@@ -213,7 +213,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
 
 			if ( extension !== null ) {
 
-				if ( p === RGBA_BPTC_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
+				if ( p === RGBA_BPTC_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
 
 			} else {
 

+ 3 - 13
src/renderers/webxr/WebXRManager.js

@@ -8,17 +8,7 @@ import { WebGLAnimation } from '../webgl/WebGLAnimation.js';
 import { WebGLRenderTarget } from '../WebGLRenderTarget.js';
 import { WebXRController } from './WebXRController.js';
 import { DepthTexture } from '../../textures/DepthTexture.js';
-import {
-	DepthFormat,
-	DepthStencilFormat,
-	RGBAFormat,
-	UnsignedByteType,
-	UnsignedIntType,
-	UnsignedInt248Type,
-	SRGBColorSpace,
-	sRGBEncoding,
-	LinearEncoding,
-} from '../../constants.js';
+import { DepthFormat, DepthStencilFormat, RGBAFormat, UnsignedByteType, UnsignedIntType, UnsignedInt248Type } from '../../constants.js';
 
 class WebXRManager extends EventDispatcher {
 
@@ -294,7 +284,7 @@ class WebXRManager extends EventDispatcher {
 						{
 							format: RGBAFormat,
 							type: UnsignedByteType,
-							encoding: renderer.outputColorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding,
+							colorSpace: renderer.outputColorSpace,
 							stencilBuffer: attributes.stencil
 						}
 					);
@@ -333,7 +323,7 @@ class WebXRManager extends EventDispatcher {
 							type: UnsignedByteType,
 							depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
 							stencilBuffer: attributes.stencil,
-							encoding: renderer.outputColorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding,
+							colorSpace: renderer.outputColorSpace,
 							samples: attributes.antialias ? 4 : 0
 						} );
 

+ 2 - 2
src/textures/CompressedTexture.js

@@ -2,9 +2,9 @@ import { Texture } from './Texture.js';
 
 class CompressedTexture extends Texture {
 
-	constructor( mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
+	constructor( mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, colorSpace ) {
 
-		super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
+		super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, colorSpace );
 
 		this.isCompressedTexture = true;
 

+ 2 - 2
src/textures/CubeTexture.js

@@ -3,12 +3,12 @@ import { CubeReflectionMapping } from '../constants.js';
 
 class CubeTexture extends Texture {
 
-	constructor( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
+	constructor( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, colorSpace ) {
 
 		images = images !== undefined ? images : [];
 		mapping = mapping !== undefined ? mapping : CubeReflectionMapping;
 
-		super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
+		super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, colorSpace );
 
 		this.isCubeTexture = true;
 

+ 2 - 2
src/textures/DataTexture.js

@@ -3,9 +3,9 @@ import { NearestFilter } from '../constants.js';
 
 class DataTexture extends Texture {
 
-	constructor( data = null, width = 1, height = 1, format, type, mapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, encoding ) {
+	constructor( data = null, width = 1, height = 1, format, type, mapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, colorSpace ) {
 
-		super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
+		super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, colorSpace );
 
 		this.isDataTexture = true;
 

+ 34 - 10
src/textures/Texture.js

@@ -3,23 +3,27 @@ import {
 	MirroredRepeatWrapping,
 	ClampToEdgeWrapping,
 	RepeatWrapping,
-	LinearEncoding,
 	UnsignedByteType,
 	RGBAFormat,
 	LinearMipmapLinearFilter,
 	LinearFilter,
-	UVMapping
+	UVMapping,
+	sRGBEncoding,
+	SRGBColorSpace,
+	NoColorSpace,
+	LinearEncoding
 } from '../constants.js';
 import * as MathUtils from '../math/MathUtils.js';
 import { Vector2 } from '../math/Vector2.js';
 import { Matrix3 } from '../math/Matrix3.js';
 import { Source } from './Source.js';
+import { warnOnce } from '../utils.js';
 
 let textureId = 0;
 
 class Texture extends EventDispatcher {
 
-	constructor( image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = Texture.DEFAULT_ANISOTROPY, encoding = LinearEncoding ) {
+	constructor( image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = Texture.DEFAULT_ANISOTROPY, colorSpace = NoColorSpace ) {
 
 		super();
 
@@ -62,11 +66,17 @@ class Texture extends EventDispatcher {
 		this.flipY = true;
 		this.unpackAlignment = 4;	// valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
 
-		// Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.
-		//
-		// Also changing the encoding after already used by a Material will not automatically make the Material
-		// update. You need to explicitly call Material.needsUpdate to trigger it to recompile.
-		this.encoding = encoding;
+		if ( typeof colorSpace === 'string' ) {
+
+			this.colorSpace = colorSpace;
+
+		} else { // @deprecated, r152
+
+			warnOnce( 'THREE.Texture: Property .encoding has been replaced by .colorSpace.' );
+			this.colorSpace = colorSpace === sRGBEncoding ? SRGBColorSpace : NoColorSpace;
+
+		}
+
 
 		this.userData = {};
 
@@ -136,7 +146,7 @@ class Texture extends EventDispatcher {
 		this.premultiplyAlpha = source.premultiplyAlpha;
 		this.flipY = source.flipY;
 		this.unpackAlignment = source.unpackAlignment;
-		this.encoding = source.encoding;
+		this.colorSpace = source.colorSpace;
 
 		this.userData = JSON.parse( JSON.stringify( source.userData ) );
 
@@ -182,7 +192,7 @@ class Texture extends EventDispatcher {
 			format: this.format,
 			internalFormat: this.internalFormat,
 			type: this.type,
-			encoding: this.encoding,
+			colorSpace: this.colorSpace,
 
 			minFilter: this.minFilter,
 			magFilter: this.magFilter,
@@ -305,6 +315,20 @@ class Texture extends EventDispatcher {
 
 	}
 
+	get encoding() { // @deprecated, r152
+
+		warnOnce( 'THREE.Texture: Property .encoding has been replaced by .colorSpace.' );
+		return this.colorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding;
+
+	}
+
+	set encoding( encoding ) { // @deprecated, r152
+
+		warnOnce( 'THREE.Texture: Property .encoding has been replaced by .colorSpace.' );
+		this.colorSpace = encoding === sRGBEncoding ? SRGBColorSpace : NoColorSpace;
+
+	}
+
 }
 
 Texture.DEFAULT_IMAGE = null;

+ 13 - 1
src/utils.js

@@ -68,4 +68,16 @@ function createElementNS( name ) {
 
 }
 
-export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS };
+const _cache = {};
+
+function warnOnce( message ) {
+
+	if ( message in _cache ) return;
+
+	_cache[ message ] = true;
+
+	console.warn( message );
+
+}
+
+export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS, warnOnce };

+ 1 - 1
test/unit/src/textures/Texture.tests.js

@@ -179,7 +179,7 @@ export default QUnit.module( 'Textures', () => {
 
 		} );
 
-		QUnit.todo( 'encoding', ( assert ) => {
+		QUnit.todo( 'colorSpace', ( assert ) => {
 
 			assert.ok( false, 'everything\'s gonna be alright' );