Texture Filtering and Mipmapping 纹理过滤与多级纹理 前面我们已经讲了单个2D图像的2D纹理的介绍,这篇文章主要讲解多级纹理。纹理坐标是用于生成一个2D索引,当放大和缩小设置为GL_NEAREST时,将发生一个单一纹理将匹配到纹理坐标位置中,这是 ...
Texture Filtering and Mipmapping 纹理过滤与多级纹理
前面我们已经讲了单个2D图像的2D纹理的介绍,这篇文章主要讲解多级纹理。纹理坐标是用于生成一个2D索引,当放大和缩小设置为GL_NEAREST时,将发生一个单一纹理将匹配到纹理坐标位置中,这是一个最近点的采样。
当使用一个多级纹理时,我们可以设置过滤模式,,为了达到屏幕像素和纹理图片像素更合适的比例,减少锯齿。因为多级纹理贴图的成功过滤,当在更远处观察时,我们向贴图链后移动,锯齿减少,实现高质量的图像。
// Load mipmap level 0glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height,0, GL_RGB, GL_UNSIGNED_BYTE, pixels);level = 1;prevImage = &pixels[0];while(width > 1 && height > 1){ int newWidth, newHeight; // Generate the next mipmap level GenMipMap2D( prevImage, &newImage, width, height, &newWidth, &newHeight); // Load the mipmap level glTexImage2D(GL_TEXTURE_2D, level, GL_RGB, newWidth, newHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, newImage); // Free the previous image free(prevImage); // Set the previous image for the next iteration prevImage = newImage; level++; // Half the width and height width = newWidth; height = newHeight;}free(newlmage);
原标题:OpenGL ES 3.0之Texturing纹理详解(二)
关键词:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。