本文介绍了ThreeJS中InstancedMesh和InterleavedBuffer的区别及使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮助我们解决threejs中InstancedMesh和InterleavedBuffer之间的区别.我对这两个主题都有些困惑,谁能告诉我哪种是渲染大量几何体的优化方法.

Can anyone help we out with the difference between InstancedMesh and InterleavedBuffer in threejs. I'm kinds confused with both the topics and can anyone let me know which is the optimized way to go with to render some large amount of geometry.

提前致谢.

推荐答案

实例化渲染和交错缓冲区是两个独立的东西.您可以单独或结合使用这两种技术.

Instanced rendering and interleaved buffers a two separate things. You can use both techniques on their own or in combination.

THREE.InstancedMesh 为实例化提供了方便的界面渲染.当您必须渲染大量具有相同材质和几何体但具有不同世界变换的对象时,此方法非常有用.THREE.InstancedMesh 允许您通过减少绘制调用的数量来提高应用程序的性能.因此,您可以一次绘制所有对象,而不是使用单个绘制调用绘制每个对象.

THREE.InstancedMesh provides a convenient interface for instanced rendering. This approach is useful when you have to render a huge number of objects with the same material and geometry but with different world transformations. THREE.InstancedMesh allows you to improve the performance of your app by reducing the amount of draw calls. So instead of drawing each object with a single draw call, you can draw them all at once.

InterleavedBuffer 提供了管理顶点数据的可能性以交错的方式.这样做的动机是为了提高 GPU 上的缓存命中量.如果你对这种方法背后的理论更感兴趣,我建议你谷歌数组结构与结构数组".后一种适用于InterleavedBuffer.

InterleavedBuffer provides the possibility to manage your vertex data in an interleaved fashion. The motivation of doing this is to improve the amount of cache hits on the GPU. If you are more interested in the theory behind this approach, I suggest you google "structure of arrays vs. array of structures". The latter one applies to InterleavedBuffer.

一般来说,这两种技术的性能优势取决于具体的用例.根据我的个人经验,交错缓冲区的好处很难衡量,因为性能改进取决于相应的 GPU.在许多情况下,我发现使用交错缓冲区时 FPS 没有区别.但是,如果绘制调用的数量较多并且您通过使用实例化渲染来降低它,则更容易看到性能改进.

In general, the performance benefits of both techniques depends on the specific use case. According to my personal experiences, the benefits of interleaved buffers is hard to measure since the performance improvements depend on the respective GPU. In many cases, I've seen no difference in FPS when using interleaved buffers. However, it's much more easier to see a performance improvement if the amount of draw calls is high and you lower it by using instanced rendering.

three.js 提供了这两种技术的示例.webgl_buffergeometry_instancing_interleaved 演示了一个组合.

three.js provides examples for both techniques. webgl_buffergeometry_instancing_interleaved demonstrates a combination.

three.js R114

这篇关于ThreeJS中InstancedMesh和InterleavedBuffer的区别及使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 21:40