Skip to content

Commit f3fd569

Browse files
authored
WebGPURenderer: Fix texture issues. (#33296)
1 parent 332ec85 commit f3fd569

2 files changed

Lines changed: 7 additions & 24 deletions

File tree

src/renderers/common/Info.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
ByteType, UnsignedByteType, ShortType, UnsignedShortType, HalfFloatType,
44
IntType, UnsignedIntType, FloatType,
55
AlphaFormat, RedFormat, RedIntegerFormat, DepthFormat, DepthStencilFormat,
6-
RGBFormat,
6+
RGFormat, RGIntegerFormat, RGBFormat, RGBIntegerFormat,
77
UnsignedShort4444Type, UnsignedShort5551Type,
88
UnsignedInt248Type, UnsignedInt5999Type, UnsignedInt101111Type
99
} from '../../constants.js';
@@ -386,7 +386,8 @@ class Info {
386386
let channels = 4; // RGBA default
387387

388388
if ( texture.format === AlphaFormat || texture.format === RedFormat || texture.format === RedIntegerFormat || texture.format === DepthFormat || texture.format === DepthStencilFormat ) channels = 1;
389-
else if ( texture.format === RGBFormat ) channels = 3;
389+
else if ( texture.format === RGFormat || texture.format === RGIntegerFormat ) channels = 2;
390+
else if ( texture.format === RGBFormat || texture.format === RGBIntegerFormat ) channels = 3;
390391

391392
let bytesPerPixel = bytesPerChannel * channels;
392393

src/renderers/webgl-fallback/utils/WebGLTextureUtils.js

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,7 @@ class WebGLTextureUtils {
181181
if ( glType === gl.FLOAT ) internalFormat = gl.R32F;
182182
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.R16F;
183183
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.R8;
184-
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.R16;
185-
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.R32UI;
186-
if ( glType === gl.BYTE ) internalFormat = gl.R8I;
187-
if ( glType === gl.SHORT ) internalFormat = gl.R16I;
188-
if ( glType === gl.INT ) internalFormat = gl.R32I;
184+
if ( glType === gl.BYTE ) internalFormat = gl.R8_SNORM;
189185

190186
}
191187

@@ -205,11 +201,7 @@ class WebGLTextureUtils {
205201
if ( glType === gl.FLOAT ) internalFormat = gl.RG32F;
206202
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RG16F;
207203
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RG8;
208-
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.RG16;
209-
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.RG32UI;
210-
if ( glType === gl.BYTE ) internalFormat = gl.RG8I;
211-
if ( glType === gl.SHORT ) internalFormat = gl.RG16I;
212-
if ( glType === gl.INT ) internalFormat = gl.RG32I;
204+
if ( glType === gl.BYTE ) internalFormat = gl.RG8_SNORM;
213205

214206
}
215207

@@ -230,13 +222,8 @@ class WebGLTextureUtils {
230222

231223
if ( glType === gl.FLOAT ) internalFormat = gl.RGB32F;
232224
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RGB16F;
233-
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RGB8;
234-
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.RGB16;
235-
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.RGB32UI;
236-
if ( glType === gl.BYTE ) internalFormat = gl.RGB8I;
237-
if ( glType === gl.SHORT ) internalFormat = gl.RGB16I;
238-
if ( glType === gl.INT ) internalFormat = gl.RGB32I;
239225
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = ( transfer === SRGBTransfer ) ? gl.SRGB8 : gl.RGB8;
226+
if ( glType === gl.BYTE ) internalFormat = gl.RGB8_SNORM;
240227
if ( glType === gl.UNSIGNED_SHORT_5_6_5 ) internalFormat = gl.RGB565;
241228
if ( glType === gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = gl.RGB5_A1;
242229
if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = gl.RGB4;
@@ -262,13 +249,8 @@ class WebGLTextureUtils {
262249

263250
if ( glType === gl.FLOAT ) internalFormat = gl.RGBA32F;
264251
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RGBA16F;
265-
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RGBA8;
266-
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.RGBA16;
267-
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.RGBA32UI;
268-
if ( glType === gl.BYTE ) internalFormat = gl.RGBA8I;
269-
if ( glType === gl.SHORT ) internalFormat = gl.RGBA16I;
270-
if ( glType === gl.INT ) internalFormat = gl.RGBA32I;
271252
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = ( transfer === SRGBTransfer ) ? gl.SRGB8_ALPHA8 : gl.RGBA8;
253+
if ( glType === gl.BYTE ) internalFormat = gl.RGBA8_SNORM;
272254
if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = gl.RGBA4;
273255
if ( glType === gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = gl.RGB5_A1;
274256

0 commit comments

Comments
 (0)