且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

正确使用GLTexImage3D时出现问题

更新时间:2023-11-09 22:29:28

纹理环绕参数GL_TEXTURE_WRAP_SGL_TEXTURE_WRAP_TGL_TEXTURE_WRAP_R默认为GL_REPEAT.
缩小功能(GL_TEXTURE_MIN_FILTER)和放大功能(GL_TEXTURE_MAG_FILTER)的默认参数分别为GL_NEAREST_MIPMAP_LINEARGL_LINEAR. 参见 glTexParameter .

The texture wrap parameters GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T and GL_TEXTURE_WRAP_R are by default GL_REPEAT.
The default parameters for the minifying function (GL_TEXTURE_MIN_FILTER) and magnification function are (GL_TEXTURE_MAG_FILTER) are GL_NEAREST_MIPMAP_LINEAR respectively GL_LINEAR.
See glTexParameter.

"REPEAT"和"LINEAR"的组合会导致将第一个体素与行,列或深度层的最后一个体素混合(内插)(如果将纹理坐标参数传递给)查找功能是0.0.

The combination of "REPEAT" and "LINEAR" causes, that the first voxel is mixed (interpolated) with the last voxel of a row, column, or depth-layer, if the the texture coordinate parameters, which is passed to the lookup function, is 0.0.

如果使用wrap参数GL_CLAMP_TO_EDGE,则第一个和最后一个体素将不会混合,因为纹理坐标已被钳位.

If you would use the wrap parameter GL_CLAMP_TO_EDGE, then the first and the last voxel won't become mixed, because the texture coordinate is clamped.

请注意,第一个体素(或体素)的纹理坐标为1/(2*N),最后一个体素的坐标为1 - 1/(2*N),其中N是行,列或层中体素的数量.因此,坐标0.0正好位于第一个和最后一个体素的中间. GL_REPEAT会将坐标0.0钳位到1/(2*N).

Note the texture coordinate of the first voxel (or texel) is 1/(2*N) and the coordinate of the last voxel is 1 - 1/(2*N), where N is the number of voxels in a row, column or layer. Because of that the coordinate 0.0, is exactly in the middle of the first and the last voxel. GL_REPEAT would clamp the coordinate 0.0 to 1/(2*N).