开发者

How to create 4-dimensional textures?

EDIT

glTexcoord4f allows to specif four dimensions of a texture, bu开发者_如何学Pythont how do you create 4-dimensional textures


The r component is used to specify either the depth in a 3D (volumetric) texture, or the layer in a 2D texture array.

The q component plays the same role, like the vertex position w element: It is used for scaling the perspective divide in perspective texture projection.


There isn't any real "meaning" to them. If you were using shaders, you can assign any meaning you want to them.

For example, in our game: we used the xy for the actual texcoords, the z for which texture to sample from, and the w (4th component) to control the brightness.

There is such thing as 3D and 4D textures which do actually require 3 and 4 texcoords respectively, I suppose that could be the "meaning" of them.

The main reason that they exist, is because graphics cards work with 4 component vectors. When you pass a 2D texcoord in, it's still a 4-vector behind the scenes (the other r and q components aren't set). OpenGL provides you with the functionality to use them, on the off chance that you might need it.


The r component is the 3rd coordinate for GL_TEXTURE_3D (for rendering volumes). I am not familiar with any method that uses the 4th coordinate.

But it seems reasonable to have that available as all homogeneous OpenGL vectors have 4 components.


There is no such thing as a 4-dimensional texture. At least, not without extensions.

The reason glTexCoord4D exists is to allow passing 4 values. In the modern shader-based rendering world, "texture coordinates" don't have to be texture coordinates at all. They're just values the shader uses to do whatever it does.

Many of the texture lookup functions in shaders take more texture coordinate dimensions than the dimensionality of the actual texture. All texture functions for shadow textures take an extra coordinate, which represents the comparison value. All of the Proj texture functions take an extra coordinate, which represents the homogeneous coordinate for a homogeneous coordinate system.

In fixed-function land, 4D texture coordinates can be used for projective texturing of 3D textures. So the 4D coordinate is in a homogeneous coordinate system.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜