diff --git a/src/renderers/webgl/WebGLTextures.js b/src/renderers/webgl/WebGLTextures.js index 8418d297f91ec12ba1d19398890ee9fc6a860f25..bed41834c1578ce8896936ead8dfd512b153d40b 100644 --- a/src/renderers/webgl/WebGLTextures.js +++ b/src/renderers/webgl/WebGLTextures.js @@ -2,7 +2,7 @@ * @author mrdoob / http://mrdoob.com/ */ -import { LinearFilter, NearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, FloatType, HalfFloatType, ClampToEdgeWrapping, NearestMipMapLinearFilter, NearestMipMapNearestFilter } from '../../constants'; +import { LinearFilter, NearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, FloatType, HalfFloatType, UnsignedByteType, ClampToEdgeWrapping, NearestMipMapLinearFilter, NearestMipMapNearestFilter } from '../../constants'; import { _Math } from '../../math/Math'; function WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, info ) { @@ -410,6 +410,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY ); _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha ); + + if ( texture.isDataTexture && texture.unpackAlignment !== 1 && + _Math.isPowerOfTwo( texture.image.width ) === false && + texture.format === RGBFormat && + texture.type === UnsignedByteType ) { + + console.warn( 'THREE.WebGLRenderer: Changed unpackAlignment to 1. See #9566.', texture ); + texture.unpackAlignment = 1; + + } + _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment ); var image = clampToMaxSize( texture.image, capabilities.maxTextureSize );