Opengl ES 2 中的纹理无法正常工作

发布于 2024-10-05 19:04:51 字数 957 浏览 0 评论 0原文

我正在 iPhone 上使用 Opengl ES 2,现在我正在尝试让我的纹理在我的对象上工作。我正在使用 .obj 文件,其中的所有数据都是正确的。我自己编写了一个解析器来检索所有数据,我将其转换为 C 中的静态数组。我暂时放弃材质属性,仅手动从 .mtl 文件获取图像路径。

我有一个包含 336 个三角形的对象,具有相关的顶点、顶点面和纹理坐标 (u,v),因此观察起来并不简单。

将所有数据传递到着色器中,生成的图像如下:

http://img530.imageshack。 us/img530/9637/pic1io.png

http://img404.imageshack。 us/img404/7358/pic2pg.png

但它应该看起来像这样(在对象查看器中显示它)。请忽略材料特性。

http://img16.imageshack.us/img16/1401/pic3cq.png

使用此图像作为纹理:

http://img217.imageshack.us/img217/1300/ shirtdiffuse.png

我想这可能与纹理坐标面有关?它是在我的 .obj 文件中定义的,但我根本没有使用它们。在书籍和教程中我没有找到任何与此相关的内容。

问候尼古拉斯

I'm working with Opengl ES 2 on iphone and right now I am trying to get my textures working on my objects. I'm using .obj files and all the data in them are correct. I have written a parser myself to retrieve all data, I convert it to static arrays in C. I discard the material properties for now, only getting the image path from the .mtl files manually.

I have an object with 336 triangles, making this non-trivial to observe, with appertaining vertices, vertex faces and texture coordinates (u,v).

Passing all data into the shaders, the resulting image is this:

http://img530.imageshack.us/img530/9637/pic1io.png

http://img404.imageshack.us/img404/7358/pic2pg.png

But it should look like this (Displaying it in an object viewer). Please ignore the material properties.

http://img16.imageshack.us/img16/1401/pic3cq.png

Using this image as a texture:

http://img217.imageshack.us/img217/1300/shirtdiffuse.png

I'm thinking it might have to do with texture coordinate faces ? It is defined in my .obj file, and I'm not using them at all. In books and tutorials I have not found anything concerning this.

Regards Niclas

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

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

发布评论

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

评论(1

吹泡泡o 2024-10-12 19:04:51

您是否尝试过垂直翻转纹理?有时,纹理加载后会布局在内存中,因此垂直线的方向与纹理坐标中的预期相反。

Have you tried to flip the texture vertically? Some times when a texture has been loaded it is layed out in memory so the vertical lines come in the opposit direction as intended in the texcoords.

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