The “try with a smaller game” answer, is not a good answer. @pspeed, i respect you and i like your game, it gave me a bit of inspiration, viewing what could be done with jMonkey. but I don’t need the answer “try with something else”. I just need help with the performances.
Thanks to your answers I know what to search, now. And i know what I have to focus on
Good luck with it
Thre is also the easy mans solution (i sue it for smaller block spaceships)
heavy use of instancing can render a whole lot of cubes quite fast, and is simpler than a proper mesh generating algorithm.
Together with some far terrain solution, this will work quite ok
For a “small amount” of “whole lot of cubes”.
Rendering terrain as cubes renders about 4-5x as much triangles as actually needed. And that’s assuming you are only rendering the visible blocks. The visible faces is a teeny tiny percentage of all faces. I mean, even if you just consider a 10x10x10 cube floating in space, that’s 600 visible faces but 6000 total faces. Now imagine that’s a world that extends off into the distance. 1000x1000 only 10 deep… that’s 1 million visible faces but 60 million total faces. You simply must render only the visible faces for terrain.
Instancing is also no silver bullet, here. It’s fine for a relatively small number of ‘blocks’ but you still pay a per-instance cost that is quite a lot higher than a normal batched per-triangle cost. It may be only one draw call but the driver still has to perform per instance setup.
And besides, when making a block world “rendering only visible faces” is pretty much the easiest of the dozen problems to solve. If that’s where things get difficult then the rest will be virtually impossible.
True, but it might be good enough for a start for his project, if he cannot reduce the scale. (I know this, remember I’m still at my original game idea, and I started with jme2) So a acceptable solution might be ok, with the knowledge of coming back there later and replacing it. (will also lead to clean interface usage hopefully, so it can actually be replaced later)
I won’t stop people from the head trough the wall method, because I’m already half trough after a few years And I know I wouldn’t have listened myself.
Yes, but my contention is that “later” will be “next week” with a new question of “I’ve done it this way but it’s too slow and I can only have 128x128 terrain visible at a time which is unacceptable.”
…then we are right back to this thread.
Terrain cannot be done with block instancing… not for anything deserving the word “terrain” anyway.
And really the “hey, is there a neighbor? No, ok emit face” algorithm is so totally simple. I mean, even if you were to go with the totally naive approach that would be to emit JME Quads and use the GeometryBatchFactory. Ugly but waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay better than instancing all of the blocks.
I did the same exercise a time ago, this is/was my dev blog:
If you want to make a game with a Minecraft-like world you could use the engine I made.
But it only supports this kind of game.
Thanks. I’ll try it, but I need only the Minecraft-like generation
Hi again. I studied a little on how to use meshes with jme3’s tutorials. Very useful. I applied it to my world and i have to say that performances increased a lot! Now I can stay up on 10-30-70 FPSses depending on the quantity of triangles. Now the point is: how do I do render only visible (or close to it) triangles? Something like a render distance, can’t find anything about it…
That’s not what we mean by visible triangles.
If you put two blocks together then there are two quads that are hidden inside the blocks. Don’t draw those. In a block world, this ‘invisible’ faces represent 90% or more of the total number of faces.
If you spatially organize your world then JME already won’t draw objects that aren’t in the view.
That is what I need, just didn’t know how to say it in enlgish, it’s not my mother language… How do I do what you sayed?
To render only the visible faces you look at any of the other samples already provided to see how they work.
Basic idea is simple. Forget blocks. Nothing is blocks.
For every cell in your world, check the neighbors. If there is no neighbor then add that quad.
I don’t have cells, I don’t use arrays to gen my world, what I use is the simplest idea I had, but I’ll see
Can I base my project on your voxel engine? Or just understand how to make some things to work. What about selling a game based on your library?
You can base your project on my engine. I advise you to keep the code of the game separated from the code of the engine for updates and to stay free to switch to another engine later.
I haven’t choose a license right now, but yes I’m planing to choose one that allow commercial use.
Perfect! Thanks so much!!
What is the method that generates the world? It’s a while a search for it, but I couldn’t find anything
There is an example in test.TestLandscape
You need to instantiate a VoxelSystem object and notify when the camera is moving and the engine will generate the world.