1
- 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 , RedFormat , RGBFormat , RGBAFormat , AlphaFormat , RedIntegerFormat , RGFormat , RGIntegerFormat , RGBAIntegerFormat , HalfFloatType , FloatType , UnsignedIntType , IntType , UnsignedShortType , ShortType , ByteType , UnsignedInt248Type , UnsignedInt5999Type , UnsignedShort5551Type , UnsignedShort4444Type , UnsignedByteType , RGBA_BPTC_Format , RED_RGTC1_Format , SIGNED_RED_RGTC1_Format , RED_GREEN_RGTC2_Format , SIGNED_RED_GREEN_RGTC2_Format , SRGBColorSpace , NoColorSpace } from '../../../constants.js' ;
1
+ 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 , RedFormat , RGBFormat , RGBAFormat , AlphaFormat , RedIntegerFormat , RGFormat , RGIntegerFormat , RGBAIntegerFormat , HalfFloatType , FloatType , UnsignedIntType , IntType , UnsignedShortType , ShortType , ByteType , UnsignedInt248Type , UnsignedInt5999Type , UnsignedShort5551Type , UnsignedShort4444Type , UnsignedByteType , RGBA_BPTC_Format , RED_RGTC1_Format , SIGNED_RED_RGTC1_Format , RED_GREEN_RGTC2_Format , SIGNED_RED_GREEN_RGTC2_Format , SRGBTransfer , NoColorSpace } from '../../../constants.js' ;
2
+ import { ColorManagement } from '../../../math/ColorManagement.js' ;
2
3
3
4
/**
4
5
* A WebGL 2 backend utility module with common helpers.
@@ -53,6 +54,8 @@ class WebGLUtils {
53
54
54
55
let extension ;
55
56
57
+ const transfer = ColorManagement . getTransfer ( colorSpace ) ;
58
+
56
59
if ( p === UnsignedByteType ) return gl . UNSIGNED_BYTE ;
57
60
if ( p === UnsignedShort4444Type ) return gl . UNSIGNED_SHORT_4_4_4_4 ;
58
61
if ( p === UnsignedShort5551Type ) return gl . UNSIGNED_SHORT_5_5_5_1 ;
@@ -89,7 +92,7 @@ class WebGLUtils {
89
92
90
93
if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
91
94
92
- if ( colorSpace === SRGBColorSpace ) {
95
+ if ( transfer === SRGBTransfer ) {
93
96
94
97
extension = extensions . get ( 'WEBGL_compressed_texture_s3tc_srgb' ) ;
95
98
@@ -156,8 +159,8 @@ class WebGLUtils {
156
159
157
160
if ( extension !== null ) {
158
161
159
- if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ETC2 : extension . COMPRESSED_RGB8_ETC2 ;
160
- if ( p === RGBA_ETC2_EAC_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension . COMPRESSED_RGBA8_ETC2_EAC ;
162
+ if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ETC2 : extension . COMPRESSED_RGB8_ETC2 ;
163
+ if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension . COMPRESSED_RGBA8_ETC2_EAC ;
161
164
162
165
} else {
163
166
@@ -179,20 +182,20 @@ class WebGLUtils {
179
182
180
183
if ( extension !== null ) {
181
184
182
- if ( p === RGBA_ASTC_4x4_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension . COMPRESSED_RGBA_ASTC_4x4_KHR ;
183
- if ( p === RGBA_ASTC_5x4_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension . COMPRESSED_RGBA_ASTC_5x4_KHR ;
184
- if ( p === RGBA_ASTC_5x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension . COMPRESSED_RGBA_ASTC_5x5_KHR ;
185
- if ( p === RGBA_ASTC_6x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension . COMPRESSED_RGBA_ASTC_6x5_KHR ;
186
- if ( p === RGBA_ASTC_6x6_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension . COMPRESSED_RGBA_ASTC_6x6_KHR ;
187
- if ( p === RGBA_ASTC_8x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension . COMPRESSED_RGBA_ASTC_8x5_KHR ;
188
- if ( p === RGBA_ASTC_8x6_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension . COMPRESSED_RGBA_ASTC_8x6_KHR ;
189
- if ( p === RGBA_ASTC_8x8_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension . COMPRESSED_RGBA_ASTC_8x8_KHR ;
190
- if ( p === RGBA_ASTC_10x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension . COMPRESSED_RGBA_ASTC_10x5_KHR ;
191
- if ( p === RGBA_ASTC_10x6_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension . COMPRESSED_RGBA_ASTC_10x6_KHR ;
192
- if ( p === RGBA_ASTC_10x8_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension . COMPRESSED_RGBA_ASTC_10x8_KHR ;
193
- if ( p === RGBA_ASTC_10x10_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension . COMPRESSED_RGBA_ASTC_10x10_KHR ;
194
- if ( p === RGBA_ASTC_12x10_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension . COMPRESSED_RGBA_ASTC_12x10_KHR ;
195
- if ( p === RGBA_ASTC_12x12_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension . COMPRESSED_RGBA_ASTC_12x12_KHR ;
185
+ if ( p === RGBA_ASTC_4x4_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension . COMPRESSED_RGBA_ASTC_4x4_KHR ;
186
+ if ( p === RGBA_ASTC_5x4_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension . COMPRESSED_RGBA_ASTC_5x4_KHR ;
187
+ if ( p === RGBA_ASTC_5x5_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension . COMPRESSED_RGBA_ASTC_5x5_KHR ;
188
+ if ( p === RGBA_ASTC_6x5_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension . COMPRESSED_RGBA_ASTC_6x5_KHR ;
189
+ if ( p === RGBA_ASTC_6x6_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension . COMPRESSED_RGBA_ASTC_6x6_KHR ;
190
+ if ( p === RGBA_ASTC_8x5_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension . COMPRESSED_RGBA_ASTC_8x5_KHR ;
191
+ if ( p === RGBA_ASTC_8x6_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension . COMPRESSED_RGBA_ASTC_8x6_KHR ;
192
+ if ( p === RGBA_ASTC_8x8_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension . COMPRESSED_RGBA_ASTC_8x8_KHR ;
193
+ if ( p === RGBA_ASTC_10x5_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension . COMPRESSED_RGBA_ASTC_10x5_KHR ;
194
+ if ( p === RGBA_ASTC_10x6_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension . COMPRESSED_RGBA_ASTC_10x6_KHR ;
195
+ if ( p === RGBA_ASTC_10x8_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension . COMPRESSED_RGBA_ASTC_10x8_KHR ;
196
+ if ( p === RGBA_ASTC_10x10_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension . COMPRESSED_RGBA_ASTC_10x10_KHR ;
197
+ if ( p === RGBA_ASTC_12x10_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension . COMPRESSED_RGBA_ASTC_12x10_KHR ;
198
+ if ( p === RGBA_ASTC_12x12_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension . COMPRESSED_RGBA_ASTC_12x12_KHR ;
196
199
197
200
} else {
198
201
@@ -210,7 +213,7 @@ class WebGLUtils {
210
213
211
214
if ( extension !== null ) {
212
215
213
- if ( p === RGBA_BPTC_Format ) return ( colorSpace === SRGBColorSpace ) ? extension . COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension . COMPRESSED_RGBA_BPTC_UNORM_EXT ;
216
+ if ( p === RGBA_BPTC_Format ) return ( transfer === SRGBTransfer ) ? extension . COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension . COMPRESSED_RGBA_BPTC_UNORM_EXT ;
214
217
215
218
} else {
216
219
0 commit comments