Everything is. Could you explain what the code is doing and which part specifically is blocking you?
For optimising CPU - you can run your app in the browser, then when it’s running, open devtools Performance tab and press the recording circle on the top-left. Let it run for 5-10 seconds and stop the recording. Then in the bottom tab of the performance snapshot click Bottom-Up and sort the list by Total Time. This will show you step by step which functions take most time to run on the CPU - try either removing them or minimising their impact as much as possible, caching whatever’s cache-able etc.
For optimising GPU - make sure you’re using instancing whenever possible, especially in such minecraft-like games. Make sure your textures are as tiny as viable. Make sure you’re using cheap materials most of the time, use MeshStandardMaterial only when necessary - starting from MeshBasicMaterial (for non-lit things), MeshLambertMaterial, MeshPhongMaterial, MeshStandardMaterial, MeshPhysicalMaterial (super-rarely needed.)
Optimising both, CPU and GPU, specifically the CPU for avoiding neckbottles. I cant send the files of the optimized game, but, this is running at 10fps when I put more than 30 on render distance input and 1 on chunksize, so… what can i do? sorry my bad english…
Hi, I had written a mini example using my own library that uses instancedMesh + frustum culling (so the gpu should work less). Could this be useful to you?
Maybe instantiating as many instancedMesh, as many chunks could be a solution?
Right now, raycasting is taking the vast majority of your frame time. So that’s something you might want to optimize first.
I see you already are using instancing per tile type… That’s a good optimization.
I think the next level up in complexity is to use hand built geometries and greedy meshing to reduce the polygon counts, and remove interior faces on your meshes.
You combine that with a chunk base generation approach to generate single geometries per chunk, and then maintain a visible set of those chunks.
EDIT 4: I compared both of scripts and these of them have different performance score. The HritikRC’s Minecraft render slower than the script without trees and water, and I tried to debug with the ‘performance’ window, but only appears the main loop without any command to quit or place for more performance… Any solution?
There is my file: v3 mod 1 v82.zip (4.2 MB)
And this is the another: