I have been looking to find ways to squeeze out a bit more performance from my game. I was thinking maybe LOD would be something worth looking into.
My main concern with this is the problem of fps loss as new LOD levels are pushed to the GPU. Seems that at least someone has experienced this: https://stackoverflow.com/questions/36613604/3d-rendering-performance-pipeline-for-level-of-detail-lod-meshes-in-threejs
In that post, WestLangley suggests using the drawRange
property of BufferGeometry
with the separate geometry levels concatenated into a singular BufferGeometry
.
Not really sure which path to take. The THREE.LOD api seems convenient, but I’m guessing that I will find it less than ideal.
Anyone have any input on this?
1 Like
The geometry & material data gets pushed to the GPU the first time it gets rendered. You could use this to your advantage and render all the different LOD meshes for one frame when your game is initializing. If you use a really small scale, they’ll be unnoticeable to the user. Then when you need to jump from one detail level to another in mid-game, everything will already be in the GPU.
Alternatively, the WebGLRenderer has a .compile()
method that helps pre-load all that data to the GPU before it’s needed to avoid the mid-game frame stutter. Maybe you could pass a secondary scene with all your different LOD meshes in it, and the data will be ready to fire up when you need it.
Either of these two approaches would be faster to implement than using custom drawRange
s, since all the distance calculations and Mesh swapping is handled by the engine out of the box. Altough the custom drawRange
approach does sound like it would have better performance, since you’d be dealing with less BufferGeometry
objects. It actually sounds like a fun challenge
2 Likes
Yea I use the initial render method currently for out of view meshes.
I have had bad luck with the .compile method. Always crashes for me.
But yea cool, I’ll mess around with the initial render frame method for the LOD’s.
One question: should I pre-render the Mesh’s before or after adding them to the LOD system?
Altough the custom drawRange
approach does sound like it would have better performance, since you’d be dealing with less BufferGeometry
objects. It actually sounds like a fun challenge
Ha ok, so I guess I gotta try out both approaches and see which works best, of couuuuurse!
Thanks Marquizzo =]
1 Like
I don’t think it matters, as long as you’re using the same Mesh objects for both.
1 Like