0

我有一个用于进行光线跟踪的 WebGL 片段着色器。我使用纹理传入球体和三角形数据。到目前为止,我已经有 2 个球体和 3 个三角形在工作。当我添加调用以检查与第四个三角形的相交时,着色器没有链接,调用getProgramInfoLog()只返回 null。

片段着色器会变得太大吗?还是我需要寻找其他原因?我如何确定问题可能出在哪里?

这是一个代码片段,注释掉任何一个checkTriangleIntersection调用都会导致着色器成功链接。

checkTriangleIntersection(0.0, rayOrigin, rayDir, piOfNearest, normalOfNearest, colourOfNearest, distOfNearest);        
checkTriangleIntersection(1.0, rayOrigin, rayDir, piOfNearest, normalOfNearest, colourOfNearest, distOfNearest);
checkTriangleIntersection(2.0, rayOrigin, rayDir, piOfNearest, normalOfNearest, colourOfNearest, distOfNearest);
//checkTriangleIntersection(3.0, rayOrigin, rayDir, piOfNearest, normalOfNearest, colourOfNearest, distOfNearest);

由于所有调用都是相同的,除了索引,我认为代码本身不会有任何问题,但是我可能会遇到某种限制吗?

在我添加额外的函数调用之前,我得到了超过 30 FPS,即使我添加了额外的调用,顶点和片段着色器都可以编译。

4

1 回答 1

0

我通过将调用checkTriangleIntersection()放入for循环中解决了这个问题。

于 2011-12-23T05:34:40.727 回答