简体   繁体   English

WebGL纹理部分渲染

[英]WebGL texture rendering partially

I am facing a very obscure issue. 我面临一个非常模糊的问题。

I am loading .obj 3d models into a WebGL application I am working on. 我正在将.obj 3d模型加载到我正在处理的WebGL应用程序中。 I am parsing them using a custom function. 我正在使用自定义函数解析它们。 I know it works correctly. 我知道它可以正常工作。 Because I get this: 因为我得到这个:

木纹立方体

Granted the texture is stretched way too much. 授予纹理太多的拉伸。 But that's the way the UVs are mapped. 但这就是UV映射的方式。

But, when I load a goose model here's what I get: 但是,当我加载鹅模型时,我得到的是:

鹅没有纹理

An untextured goose. 没纹理的鹅。 I am using the same texture. 我正在使用相同的纹理。

Weirder still is the fact that the texture renders only around the eyes. 奇怪的是,纹理仅在眼睛周围呈现。 If I don't draw the wireframe, I get this: 如果不绘制线框,则会得到以下信息:

鹅眼

Those two tiny specs that I've circled are the eyes. 我盘旋的那两个微小的规格就是眼睛。

Just to make sure that it wasn't this model, I tried another one: 为了确保不是这个模型,我尝试了另一个模型:

部分纹理斧

I have no idea why it won't render the texture everywhere else. 我不知道为什么它不能在其他地方渲染纹理。

Here's what I've tried: 这是我尝试过的:

  • Recalcuated normals and exported from Blender again. 重新计算法线并再次从Blender中导出。 Same outcome. 结果一样。
  • Loaded models in Photoshop and they preview correctly. 在Photoshop中加载了模型,它们可以正确预览。 Meaning models are fine. 含义模型很好。
  • Checked my parsing of the .obj file into a usable format for WebGL over and over. 反复检查将我的.obj文件解析为WebGL可用的格式。 Also, since the cube loads correctly, I assume it's not that. 另外,由于多维数据集可以正确加载,所以我认为不是那样。
  • Tried switching off MipMapping, disabling CULL_FACE and changing winding order. 尝试关闭MipMapping,禁用CULL_FACE并更改绕线顺序。 No difference. 没有不同。
  • Used different texture image. 使用了不同的纹理图像。 The texture images are all NPOT. 纹理图像都是NPOT。 Tried non NPOT. 尝试非NPOT。 Nothing changed, except with different images the texels of the little eyes or the fragment on the axe changed to the texture. 什么都没有改变,除了不同的图像外,小眼睛的纹理或斧头上的碎片变成了纹理。
  • Checked UV mappings, all look fine. 检查过的UV贴图看起来都很好。 No negative or out of range values. 无负值或超出范围的值。

I am totally out of ideas. 我完全没有主意。 If someone has had similar experiences, I'd appreciate pointers as to where to look next. 如果有人有类似的经历,我将很高兴为您提供下一步的指导。

I generally don't like to ask questions without posting the code, but the code is very convoluted because I'm using sweet.js for custom javascript syntax. 我通常不喜欢在不发布代码的情况下提问,但是代码非常复杂,因为我将sweet.js用于自定义javascript语法。 Let me know if anyone would like to look at the code and I could try and clean up some code and upload somewhere. 让我知道是否有人想看一下代码,我可以尝试清理一些代码并上传到某个地方。

From your images i was wondering if you did not draw a constant number of polygon, or if the draw started then silently failed on its road because of some bug. 从您的图像中,我想知道您是否没有绘制恒定数量的多边形,或者是否开始绘制,然后由于某些错误而悄悄地失败了。 That's why i asked if the drawn polygons were the first of the models. 这就是为什么我问绘制的多边形是否是第一个模型。
And so it seems that indeed there was a hard coded limit to the number of drawn polygons. 因此,似乎确实对绘制的多边形数量存在硬编码限制。
Glad you found it ! 很高兴您找到了它!

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

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