Search code examples
pngwebgltextures

Why some PNG can't use gl.REPEAT for gl.TEXTURE_WRAP_S/T?


gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);

I have two png files, the first bigger one repeat success, and the second one failure, just show nothing in webgl canvas, just the same code as shown above. I made second picture by screen capture tool from the first one. the first one, original picture the second one, screen capture from the first one


Solution

  • If you're using WebGL 1 then the reason is that the dimensions of the second image are not a power of two, the only texture wrap that works on npot(non-power of two) textures is CLAMP.