在 GLSL 中进行光线追踪时,如何迭代场景对象?
我使用 GLSL 进行光线追踪,因为这一切都是通过 WebGL 在浏览器中发生的。我可以通过浮点纹理将对象信息传递到片段着色器。在查看纹理以查找对象信息时,我尝试使用带有表达式中变量的 for 循环来表示它何时完成。它无法编译,它需要一个常量表达式。我可以做到这一点,但这是一个动态场景,所以我不知道会有多少对象。
找到场景中所有物体的正确方法是什么?
I'm using GLSL for raytracing because this is all happening in browser via WebGL. I can get my object information through to the fragment shader via floating point textures. In looking through the texture to find my object information, I tried to use a for loop with a variable in the expression to say when it was complete. It didn't compile, it wanted a constant expression. I can do this, but it is a dynamic scene, so I don't know how many objects there are going to be.
What's the correct way to find all the objects in the scene?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以编译着色器以包含场景中的所有对象,并调用所有适当的相交测试,然后当您需要更新场景时,只需将所有场景对象包含到着色器中并重新编译
You could just compile your shader to include all of the objects in your scene and appropriate intersection tests all called, then when you need to update your scene just include all the scene objects in to the shader and recompile