AFAIK, WebGL2 doesn't have a limitation with texture sizes which should be power of 2 in WebGL1. But, with WebGL2, I have tried to generate mipmaps for compressed textures in DDS format with custom sizes (not power of 2) and always got an exception: "level 0 not power of 2...". I've tried with one mipmap level and miltiple levels. No luck. It only works when the sizes are power of 2. Does anybody know why? I've it tried with mipmaps created with a tool like imagemagick and mipmaps generated at runtime with gl.generateMipmap(target). No luck.
Asked
Active
Viewed 275 times
0
-
I know little about WebGL2 mipmaps, but did you disable CLAMP_TO_EDGE so that it can use "virtual-pixels" past the edge by extending the image via duplications or mirror or some other extension method? – fmw42 Dec 23 '18 at 19:10
-
Don't use DDS on daily basis and as far as i recall DXTn uses 4x4 blocks (according to wikipedia) and has to be power of two, but this limitation also can comes from your hardware. Have your tried to validate your texture with external tools [link](http://www.amnoid.de/ddsview/). How you load your texture exactly to be draw on a Full Screenquad [texture reference](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/texture.xhtml) or something else ? – nabr Dec 23 '18 at 19:58
-
@fmw42 I didn't use CLAMP_TO_EDGE. I only set TEXTURE_MAG_FILTER and TEXTURE_MIN_FILTER – Oleg Dec 24 '18 at 20:53
-
Might CLAMP_TO_EDGE be the default? Also, WebGL2 may support that, but does DDS format support it? – fmw42 Dec 24 '18 at 21:02
-
@Nabr What do you mean with "Don't use DDS on daily basis"? I just want compressed images with mipmaps, so that the image quality looks good while zooming in / out (achieved with scaling matrix). I use quite normally shader described in webgl2fundamentals https://webgl2fundamentals.org/webgl/lessons/webgl-3d-textures.html DDS with mipmaps was created with Compressonator https://compressonator.readthedocs.io/en/latest/gui_tool/index.html I also used parse-dds to parse DDS. Here is an example: https://github.com/Jam3/parse-dds/blob/master/demo/index.js – Oleg Dec 24 '18 at 21:04
-
@fmw42 Default is gl.REPEAT – Oleg Dec 24 '18 at 21:13
-
My texture is created with this code: https://gist.github.com/ova2/a69426206f8f5ec994c57ea0f0fed23a This is similar to this one: https://github.com/Jam3/parse-dds/blob/master/demo/index.js – Oleg Dec 24 '18 at 21:16
-
Just if someone will answer this properly from your question it is unclear, what you are actually doing. So you using a 4 Years old lib (parse-dds), that relies on much older code. That could be an source of error. Second: I really don't think DXT has support for NPOT, have you any valid documentation(e.g Microsoft) for NPOT DXT files ? – nabr Dec 25 '18 at 12:36
1 Answers
0
DXT definetely works for non-POT textures. It uses 4x4 blocks, so it works fine on any image whose dimensions are multiples of 4. You have to follow this rule. Originally, my texture didn't have the width / height as multiple of 4. I've tried DXT5 with width / height of mip levels which are multiples of 4 and everything works fine. Thanks.

Oleg
- 244
- 1
- 7
-
Glad you finally found working solution! Some ideas, off topic: DXT want increase your image quality, when zooming in. It is just a GPU friendly format, that saves decompression time. The rule is: Shit in, shit out. Make sure you have a good quality to start with. Also take a look in a more Photoshop manner: you can implement a [bicubic filter maybe direct in glsl](https://stackoverflow.com/questions/13501081/efficient-bicubic-filtering-code-in-glsl) or on the CPU. Combined with user interaction like increase/decrease filtering when the user zooms in/out. – nabr Dec 26 '18 at 06:25