My github repository with the code is this:
And the trouble is that it runs laggy when i increase the fps or render distance to 10. Any solution? Thanks anyway!
My github repository with the code is this:
And the trouble is that it runs laggy when i increase the fps or render distance to 10. Any solution? Thanks anyway!
It’s not viable to use geometries for minecraft-like games. What you need is (1) divide world into chunks of blocks (blocks as data, not blocks are 3D objects), then (2) use a meshing algorithm on dirty (ie. modified) chunks to render them into 3D geometries (don’t to meshing on every frame, only when a chunk is modified.)
Long story short - minecraft worlds are not built with blocks, rather geometries generated from block data, that finally will look like the blue one here:
Its applicable to this code?:
I have another example, but player cant put or break blocks, and the physics doesnt work…
It’s applicable to building a minecraft game. Your code uses blocks (and waaaay too many materials) without doing any kind of meshing - so in the end you’re rendering 100x times more triangles than necessary (since meshing merges planar vertices into planes and makes sure internal walls of blocks are not actually created in the geometries.)
Be sure to (1) use meshing, and (2) use as few materials as possible - theoretically speaking, you should be able to render the entire world with a single material / draw call (that’ll require merging all textures into a single texture atlas), although using single material for each block type should be ok (you’ll get a few more draw calls, but as long as you’re doing meshing, that won’t be that performance-killing.)
I suspect better method is rendering only the surfaces of all blocks as the mesh. Or not?
With that we can only render the surface, doesnt affect the hidden blocks. Its is sucesfull with the opaque blocks, but another trouble is for rendering the non-opaque blocks…
U have the optimized code here, but with a counterpart: The world is finite:
DrFrankxio/industrias-carmelo-v0.20
Solved, the link of the clonable game is here: