且构网

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

关于glTexImage3D

更新时间:2023-11-09 23:00:04

对于三维纹理,z索引指的是三维.这到底是什么意思?

For three-dimensional textures, the z index refers to the third dimension. What does this exactly mean?

无论您是什么意思.

纹理只不过是一个查找表.该查找表的索引称为纹理坐标.纹理坐标的含义完全取决于您打算如何使用它.它可能是太空中的一个位置.可能是三个维度的函数的XYZ.可能有很多事情.

A texture is nothing more than a lookup table. The index of this lookup table is called a texture coordinate. What a texture coordinate means depends entirely on how you intend to use it. It could be a position in space. It could be the XYZ of a function of three dimensions. It could be a lot of things.

停止将纹理视为图片.

在2D纹理中,纹理坐标的S和T分量表示沿纹理的X和Y轴可访问的距离.如果S为1,则表示右侧.如果S为0,则表示左侧.依此类推.

In a 2D texture, the S and T components of the texture coordinate represent how far along the X and Y axes of the texture to access. If S is 1, then it means the right side. If S is 0, it means the left side. And so forth.

3D纹理和STP坐标也是如此.如果P为0,则表示3D纹理的最远"深度.如果P为1,则表示最近"深度.

The same goes for a 3D texture and the STP coordinates. If P is 0, then it means the "farthest" depth of the 3D texture. If P is 1, it means the "nearest" depth.

就您上传的数据而言,它始终基于右手坐标系工作.因此,底部/左侧/后部是(0,0,0)点,顶部/右侧/前部是(1、1、1)点.您在数据中提供的第一个深度层是最远的深度层,第二个层是第二远的层,依此类推.

In terms of the data you upload, it always works based on a right-handed coordinate system. So the bottom/left/back is the (0, 0, 0) point, and the top/right/front is the (1, 1, 1) point. The first depth layer you provide in your data is the farthest depth layer, the next layer is the second-farthest, etc.

对于二维阵列纹理,z索引指的是切片索引.就像我们有4个2D纹理层,那么如果z = 2,它将引用第二个2D纹理切片.

For two-dimensional array textures, the z index refers to the slice index. is it like if we have 4 layers of 2D textures, then if z=2, it will refer to 2nd 2D texture slice.?

否,它将引用第三.从零开始的索引,就像C/C ++中的其他所有索引一样.

No, it will refer to the third. Zero-based index, just like everything else in C/C++.

那么,除了纹理坐标之间的差异之外,当我们有目标GL_TEXTURE_3D和GL_TEXTURE_2D_ARRAY时有什么区别?

So what is difference when we have targets GL_TEXTURE_3D and GL_TEXTURE_2D_ARRAY except diff between texture cordinates?

  1. 2D阵列的各层之间没有过滤.如果在3D纹理中将GL_TEXTURE_MAG_FILTER与GL_LINEAR一起使用,它将从8个纹理像素中采样值,并在所有3个方向上进行插值.如果使用2D阵列进行此操作,它将选择一个特定的Z层作为样本,并在该层中选择4个纹理元素以在其间进行插值.

  1. There is no filtering between layers of a 2D array. If you use GL_TEXTURE_MAG_FILTER with GL_LINEAR in a 3D texture, it will sample values from 8 texels and interpolate in all 3 directions. If you do that with a 2D array, it will pick a specific Z-layer to sample from, and pick 4 texels within that layer to interpolate between.

Mipmap的工作方式不同. 3D纹理包含3D图像.因此,每个mipmap也是3D的.因此,mipmap缩减在三维上起作用.如果基础层是32x32x32,则下一个mipmap将是16x16x16.

Mipmaps work differently. A 3D texture contains 3D images. Therefore, each mipmap is 3D as well. Therefore, mipmap reduction works three-dimensionally. If the base layer is 32x32x32, then the next mipmap will be 16x16x16.

2D阵列纹理包含 2D图像.它们包含2D图像数组,但这是实现细节.它只是2D图像的集合.每个2D图像都有自己的mipmap,但是它们是 2D mipmap .因此,二维数组纹理的每个mipmap都使用相同数量的图像作为所有其他图像.因此,如果2D阵列的基础层使用32x32 2D图像,并且其中有32个图像,则下一个mipmap层将使用16x16 2D图像,但是仍然有32个.

2D array textures contain 2D images. They contain an array of 2D images, but that's an implementation detail; it's just a collection of 2D images. Each 2D image has its own mipmaps, but these are 2D mipmaps. Therefore, each mipmap of a 2D array texture uses the same number of images as all of the others. Thus, if the base layer of a 2D array uses 32x32 2D images, and there are 32 of these images, the next mipmap layer will use 16x16 2D images, but there will still be 32 of them.

数组纹理使用整数值作为纹理坐标的第三部分(要从中获取数组层). 3D纹理对所有三个分量都使用归一化的值.

Array textures use integer values for the third component of the texture coordinate (the array layer to fetch from). 3D textures use normalized values for all three components.

简而言之,除了用于向其上载数据的功能之外,它们完全没有共同之处.

In short, except for the functions you use to upload data to them, they have nothing at all in common.

通过在OpenGL Wiki上有关纹理的各个页面上查找更多信息.