开发者

Opengl es 1.1, texture compression ETC1 and Mipmaping (complete set of mipmaps error)

开发者 https://www.devze.com 2023-03-29 03:44 出处:网络
When I activate the mipmaping on uncompressed texture, all is working perfectly. When I do it on ETC1 texture, the texture is blank, certainly because le complete set of mipmaps was not given.

When I activate the mipmaping on uncompressed texture, all is working perfectly.

When I do it on ETC1 texture, the texture is blank, certainly because le complete set of mipmaps was not given.

The code is very simple and works on iPhone (with PVR compression, of course).

It doesn't work on Android. The mipmap was build with an external tool, and past together.

I stop making mipmap at the size of 4, because glCompressedTexImage2D return an opengl error if try using mipmap lower.

for(u32 i=0; i<=levels; i++)
{
    size = KC_TexByte(pagex, pagey, tex_type);
    glCompressedTexImag开发者_JAVA技巧e2D(GL_TEXTURE_2D, i, type, pagex, pagey, 0, size, ptr);

    pagex = MAX(pagex/2, 4);
    pagey = MAX(pagey/2, 4); 
    ptr += size;    

    KC_Error();    // test openGL error
}           


The reason your texture is blank is because it is required that the mipmap go all the way to 1x1.

I would imagine that the error you're getting with small compressed textures is because the texture format you're attempting to use (etc1?) doesn't support those sizes. You'd have to use non-compressed images at those small sizes...


Thanks, but your solution is not the right one; I found another solution.

  1. you're right when you explain that all the mipmap is requiered, until size 1x1
  2. you're wrong, we can't have different format between mipmap

The right way is:

  1. using size to 1x1
  2. keep in mind it's compressed data with bloc, so the size in BYTE doesn't divide by 4 each step. after 8x8, the size stay at the same value.

    sx = size in X
    sy = size in Y
    
    byte = ((sx+3)/4)*((sy+3)/4) * 8 * 2;       // 8 = bit per pixel
    


for(u32 i=0; i<=levels; i++)

Seems you'd want i < levels instead of <=.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号