简体   繁体   English

3D立方体的纹理坐标

[英]3D texture coordinates for a cube

I want to use glTexImage3D with cube. 我想在立方体中使用glTexImage3D。 what will be the texture coordinates for it? 它的纹理坐标是什么? i am using GL_TEXTURE_3D as target. 我使用GL_TEXTURE_3D作为目标。 I tried with uv coordinates same as 2d texture coordinates with z component 0-depth for each face. 我尝试使用与2d纹理坐标相同的uv坐标,每个面具有z分量0深度。 But that goes wrong. 但那是错误的。

These are the texture coordinates i was using which seems to be incorrect. 这些是我使用的纹理坐标似乎是不正确的。

        GLfloat texcoords[]={

        0.0, 0.0,0.0,
        1.0, 0.0,1.0,
        1.0, 1.0,1.0,
        0.0, 1.0,0.0,

        0.0, 0.0,0.0,
        1.0, 0.0,1.0,
        1.0, 1.0,1.0,
        0.0, 1.0,0.0,

        0.0, 0.0,0.0,
        1.0, 0.0,1.0,
        1.0, 1.0,1.0,
        0.0, 1.0,0.0,

        0.0, 0.0,0.0,
        1.0, 0.0,1.0,
        1.0, 1.0,1.0,
        0.0, 1.0,0.0,

        0.0, 0.0,0.0,
        1.0, 0.0,1.0,
        1.0, 1.0,1.0,
        0.0, 1.0,0.0,

        0.0, 0.0,0.0,
        1.0, 0.0,1.0,
        1.0, 1.0,1.0,
        0.0, 1.0,0.0
};

You probably do not want to use a 3D texture just for texturing the faces of a cube. 您可能不希望仅使用3D纹理来纹理多维数据集的面。 More likely you want to use a cube map – essentially a set of 6 2D textures one for each face of a cube – which by its very nature nicely matches the topology of a cube. 您更有可能想要使用立方体贴图 - 实际上是一组6个2D纹理,每个面对一个立方体的一个面 - 这本身就很好地匹配了立方体的拓扑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM