如何在 GLGE 中将纹理加载到立方体的不同面? (或者至少是 WebGL)

发布于 2024-12-04 04:01:57 字数 671 浏览 2 评论 0原文

我有 6 个纹理,想加载到立方体的 6 个不同面上。我正在尝试使用 GLGE.TextureCube(); 制作新纹理。然后我将所有六个图像加载到应该位于立方体上的面上,就像这样

    mapTex = new GLGE.TextureCube();
    mapTex.setSrcNegX("models/map/negx.jpg"); // they are all 1024x1024
    mapTex.setSrcNegY("models/map/negy.jpg");
    mapTex.setSrcNegZ("models/map/negz.jpg");
    mapTex.setSrcPosX("models/map/posx.jpg");
    mapTex.setSrcPosY("models/map/posy.jpg");
    mapTex.setSrcPosZ("models/map/posz.jpg");

然后我将纹理添加到Wavefront对象。然而,似乎 6 个纹理图像中只有一张被映射,并且映射不正确。

我的猜测是,当它从其他 6 个纹理贴图中创建新的纹理贴图时,会将它们平铺在一起,因此新纹理贴图的坐标不再与我的 obj 文件相对应。

如何正确地将 6 个纹理组合到一张地图上以与 GLGE 一起使用?或者有没有办法在网格的面上手动加载纹理?

I have 6 textures I would like to load on 6 different faces of a cube. I'm trying to make a new texture by using GLGE.TextureCube();. And then I load all six images to the faces the supposedly should be on the cube like so

    mapTex = new GLGE.TextureCube();
    mapTex.setSrcNegX("models/map/negx.jpg"); // they are all 1024x1024
    mapTex.setSrcNegY("models/map/negy.jpg");
    mapTex.setSrcNegZ("models/map/negz.jpg");
    mapTex.setSrcPosX("models/map/posx.jpg");
    mapTex.setSrcPosY("models/map/posy.jpg");
    mapTex.setSrcPosZ("models/map/posz.jpg");

And then I add the texture to the Wavefront object. However, it seems only one of the 6 texture images is getting mapped and its mapped incorrectly.

My guess is that when it creates the new texture map out of the other 6, it tiles them beside each other so the new texture map's co-ordinates no longer correspond to that my obj file.

How can I properly combine 6 textures to one map to be used with GLGE? Or is there a way to manually load a texture on a face of a Mesh?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空城旧梦 2024-12-11 04:01:57

立方体贴图有些特殊,因为通常的 UV (ST) 纹理坐标不适用于它们。顾名思义,立方体贴图由 6 个二次纹理组成,排列为立方体的面。纹理坐标不是立方体面上的绝对位置,而是从立方体中心出发的方向,并且从给定方向的中心发出的光线照射到立方体的位置就是那张特定脸上的纹理。

如果您应用第三个坐标为零的纹理坐标(如 Wavefront 中的纹理坐标),您将仅处理立方体表面的一部分,即与 XY 平面相交的部分。如果您想查看正在运行的立方体贴图,请使用对象的平滑法线作为纹理坐标。

Cube maps are somewhat special, as the usual UV (ST) texture coordinates don't work for them. A cube map, the name suggests it, consists of 6 quadratic textures, arranged as the faces of a cube. The texture coordinates are not absolute positions on the cube's faces, but directions from the center of the cube away, and the position where a ray from the center in the given direction hits the cube, is the position of the texture on that particular face.

If you apply texture coordinates with the third coordinate being zero, like those in Wavefront, you will address only a slice of the cube's face, namely the part that intersects with the XY plane. If you want to see a working cubemap in action, use the object's smooth normals as texture coordinates.

埖埖迣鎅 2024-12-11 04:01:57

您需要使用不同的纹理坐标,例如:
MaterialLayer.setMapinput(GLGE.MAP_OBJ)
根据您想要的尝试 GLGE.MAP_OBJ、GLGE.MAP_NORM 或 GLGE.MAP_ENV

You'll need to use a different texture coordinate, eg:
materialLayer.setMapinput(GLGE.MAP_OBJ)
depending on what you want try GLGE.MAP_OBJ,GLGE.MAP_NORM or GLGE.MAP_ENV

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文