How to not render unseen triangles?

My last post became a little confused, and the question changed a bit. My old projectbased on a “voxel engine” used Boxes and the lag had control of all the world. I changed the pre-existing Box model with a custom mesh, and the lag was reduced very much, and instantiating the Geometry containg the custom mesh only one time, reduced the lag by another bit. Now the most important thing I have to done: How do I render only visible faces of a cube? Just cubes faces (or triangles) the camera sees, that will reduce the triangles to render from 15000 to 2000, and improve the FPSses by very much.
Please, I just need directly the idea, or the code. Not complicated turns of words with no significate, no links to other engines or other programming languages, no links to premade projects, no links to libraries, no link to dead posts.
Just “How do i do it?” “You should do this, this and this…” or “try this code, that should work”. My idea for my game is really big, the world generation is only the first step. Please “don’t say: don’t do that, learn to code first”, or “try to do a pong-like game before”. I’m learning while I’m doing, you’re help will be very appreciated and it’ll make me really happy.
Thank
EmaMaker

For each filled cell, look in all 6 directions. If there is no filled cell in that direction then emit a quad.

What do you mean for cell? I don’t use arrays

If you can’t tell whether or not a block is next to another block then you are going to have a bad time. So even if it’s only temporary, you probably want to fill an array.

Else, good luck with your game. You will need lots of it.

And i don’t have idea of how to make it with arrays. I just thought out a way to place a set of cubes basing on the height. More height, less blocks. This is the only way I thought. How to i make it with arrays?

A cell is not necessary in an array. Here the cell is a place where you have a “cube”.
however you do it, there must be a way to know if there are cubes nearby another cube.

Ok, I try to do it and let you know

But how to apply it constantly to each cube? And each cube is an instance of the same class!

There are no cubes.

1 Like

whaaaaat?

Anyway, I’ve devoted enough time to this thread so I will let others take over. You are obviously an expert and want to do it a totally different way than everyone else… so good luck.

1 Like

There has been plenty of users who created their own voxel engines. Simply search the forums for ‘voxel’ or ‘voxel engine’

eg: YAVE – Yet Another Voxel Engine [Dev blog.]

There’s ton of info already out there. Even existing libraries you could use or learn from.

1 Like

I didn’t say that! And I’m not an expert! That is why I’m asking, and that’s why placing a cube with some for methods. Because I’m not an expert, and I want to learn. I don’t learn anything if you give me a premade project and you say me “Ok, take this, it works, base you project on this. It doesn’t matter if you don’t know how it works, you just need the three methods” I just what to know how things works and how make them work. and ambiguous answers are not helpful in this case, especially when english is not your first language

Thanks, but the point is that I want to sell the game, and basing it on someone other’s library is not helpful with copyrights :confused:

Code is unambiguous. Everything else is ambiguous.

Learning to read code to figure out how it works will pay off in the long run.

…but really, there are about a million articles on google on this exact subject. Probably some even already in your language.

1 Like

If the library has a license which permits you to use it then you can.

You can learn from the code, or you can learn from tutorials.
eg see if you like this one: Let's Make a Voxel Engine

1 Like

You will not find anything in my language. I know code is ambigous, but ambiguos words don’t help me

100% untrue. All of this stuff is using open source licenses so it’s fine. Just check the license. If it’s BSD or Apache based then you are fine to do whatever. Stay away from GPL.

1 Like

You need to represent your game world with a set of “chunks”, 3D arrays of “voxels” (“cubes”, “cells”…).
When you need to update a voxel (for example if the user remove the cube that represents this voxel) you generate a new mesh for the chunk where the voxel is with a mesh generation algorithm and you replace the old mesh by the new one.
But this is only a small part of what voxel engine are about, it is a vast and complex subject.

Separate game logic and visual objects. Don’t mix them. You have then a logical array of cubes. Now you can figure out There is a cube to my left don’t draw the face of my cub at that side and oh on the top there is no cube draw that face.
If you use spatials or nodes as game objects you will have a hard time, I can tell from experience.

Furthermore read existing code try to figure out how others did it there is realy no way around. Try to explain it in words is always ambiguous and insufficient.

I once wanted to understand ECS and read a lot articles about and also read a lot forum entries here but could make no sense of it. So I started to study an existing game the famous asteroid panic writen the ES way and wrote a invader like game and in the end I understood not only ES but also how to separate game logic and visual things. Took me around 5 days before I could go back to my original game idea. so take advices seriously because nearly all of us had to learn.

That’s really all I can offer you.