In my scene, I have a a 16x16 grid of InstancedMeshes. Each InstancedMesh has about 10,000 instances of a single-polygon (3-vertex) geometry. Each single-polygon geometry instance represents a little tuft of grass, and is scattered randomly across each tile.
At any given time, around ~650,000 instances are visible in the camera frustum. I am using a tiled layout to help the renderer cull the non-visible InstancedMeshes, since each InstancedMesh is culled based on the collective bounding box of all its instances.
This is my attempt at foliage on an open-world terrain.
For the first few seconds after the scene loads, whenever I look around with the first-person camera, there is a lot of lag and stutter.
After the first few seconds, however, the FPS jumps up to normal levels (60fps+).
I tried using renderer.compileAsync() on each InstancedMesh to “precompile” the shaders, but that didn’t do anything.
Next, I tried using THREE.Points, and that worked really well (there was no “first render” lag)–except the size of each point is limited to 1 pixel .
If all textures, models are loaded, then render once all meshes with frustumCulled=false, visible=true (all textures, geometries must be already loaded) and only then run project.
If you have got mesh which while not in scene, then render it separately like scene, but mesh.
I’ve wondered about this too… I’ve also seen compileAsync not really appear to do much.. I wonder if its also dependent on frustumCulled being false…
Yeah. Just saying.. what a lot of people think is shader compilation stutter, is really only a small bit of the overall stutter caused by first texture+geometry uploads… maybe?
it takes time to load into the video card memory both textures and geometry in the required form. for example, a texture weighs 4096*4096 weighs 1 MB and it is PNG, but in the video card it will be 88.08 MB. if its ktx format, then maybe less mb in videocard and time.
The camera seems like it does nothing, it gets set in a render state but it doesnt seem the compilation really depends on it. Weird, i’d remove that argument.