使用 mipmap 会产生垃圾纹理
我在创建纹理时创建自己的 mipmap,一旦我通过 GL_LINEAR_MIPMAP_NEAREST(或任何 MIPMAP)启用 mipmap,纹理就会变得非常黑暗、模糊。如果我切换到 GL_LINEAR,它们就很好。
以下是我创建纹理的方法:
glGenTextures(1, &m_TextureId);
glBindTexture( GL_TEXTURE_2D, id );
int level = 0;
jobject mippedBitmap = srcBitmap;
while (width >= 2 && height >= 2) {
jniEnv->CallStaticVoidMethod(s_GLUtilsClass, s_texImage2DMethodID,
GL_TEXTURE_2D, level, mippedBitmap, 0);
width >>= 1;
height >>= 1;
level++;
mippedBitmap = createScaledBitmap(jniEnv, srcBitmap, width, height, true);
}
为简洁起见,我省略了所有 Bitmap.recycle()/NewGlobalRef() 调用。 createScaledBitmap
显然是对 Bitmap.createScaledBitmap() 的 JNI 调用。
我还尝试了采用位图格式和类型的 texImage2D 的其他版本。我已经确认它始终是 RGBA。
编辑:详细说明纹理 - 它们实际上几乎是黑色的。我在具有明亮颜色的 mip 上尝试了擦除颜色(),但它们仍然非常暗。
I'm creating my own mipmaps when creating textures, and as soon as I enable mipmaps via GL_LINEAR_MIPMAP_NEAREST (or anything MIPMAP), the textures are just a very dark, blurry mess. If I switch to GL_LINEAR, they're fine.
Here's how I'm creating the texture:
glGenTextures(1, &m_TextureId);
glBindTexture( GL_TEXTURE_2D, id );
int level = 0;
jobject mippedBitmap = srcBitmap;
while (width >= 2 && height >= 2) {
jniEnv->CallStaticVoidMethod(s_GLUtilsClass, s_texImage2DMethodID,
GL_TEXTURE_2D, level, mippedBitmap, 0);
width >>= 1;
height >>= 1;
level++;
mippedBitmap = createScaledBitmap(jniEnv, srcBitmap, width, height, true);
}
I've omitted all Bitmap.recycle()/NewGlobalRef() calls for brevity. createScaledBitmap
is obviously a JNI call to Bitmap.createScaledBitmap().
I also tried the other version of texImage2D that takes the format and type of the bitmap. I've verified that it's always RGBA.
EDIT: To elaborate on the textures - they're really almost black. I tried eraseColor() on the mips with bright colors, and they're still extremely dark.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(3)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
glGenerateMipmap
将使您更快、更方便地完成此任务。glGenerateMipmap
will do this task faster and much more convenient for you.