Hot answers tagged

23 votes
Accepted

Storing voxels for a voxel Engine in C++

Storing the blocks as the positions and the values is actually very inefficient. Even without any overhead caused by the struct or object you use, you need to store 4 distinct values per block. It ...
Bálint's user avatar
  • 14.8k
12 votes

How does transvoxel algorithm work and how can I implement It?

The transvoxel paper is a fairly in-depth work, discussing a variety of topics on how to create an entire voxel terrain system, including an overview of marching cubes, how to fix the ambiguity ...
Schildawg's user avatar
  • 121
9 votes

How does transvoxel algorithm work and how can I implement It?

The first thing I didn't understood was if transvoxel is a modified marching cubes or a second layer that modifies the work of the marching cubes. My reading of the paper is that Transvoxel's ...
DMGregory's user avatar
  • 132k
9 votes
Accepted

How can I smooth my voxels similar to 7 Days to Die?

It is not simply Marching Cubes With marching cubes, a block would expand into the surrounding ones. In fact, with the default configurations for the Marching Cubes algorithm the result is a ...
Theraot's user avatar
  • 25.1k
7 votes

Storing voxels for a voxel Engine in C++

Octrees exist to solve exactly the problem you describe, allowing dense storage of sparse data without large search times. The fact that your voxels are the same size just means that your octree has ...
DMGregory's user avatar
  • 132k
7 votes

Texturing different block types on an optimized voxel mesh

Nice idea by the author. From experience... High vertex counts aren't that much of a problem (100Ks, millions even). Dealing with complex UV mapping is far more so. Sometimes it is worth staying ...
Engineer's user avatar
  • 29.4k
6 votes
Accepted

Unity block chunk generation pattern

Remember, the whole point of using a chunk mesh is to try to render just the outside skin, and hide all the internal detail inside the chunk where we can't see it. If we generate a whole cube (all 12 ...
DMGregory's user avatar
  • 132k
6 votes
Accepted

How should I store loaded world chunks in RAM (For my game similar to Minecraft)?

If you don't want a 2d array of chunks indexed by world position because the player might get very far away from the world origin or you might have negative indexes, then it might be worth to look at ...
Philipp's user avatar
  • 118k
6 votes
Accepted

Texturing different block types on an optimized voxel mesh

Quoting the meshing page you link: It isn’t too difficult to modify the code deal with either multiple block types or different normal directions. What you would do is modify the array called “mask” ...
DMGregory's user avatar
  • 132k
5 votes

How is structural analysis done in games (e.g.: bridge building, Dig or Die, and 3D)?

I am the dev of Dig or Die, so I can give a little more details about the game physics Indeed the most crucial point was the performances, as in the game you can build thousands of physical blocks, ...
Gaddy's user avatar
  • 151
4 votes
Accepted

How to render water reflections on multiple heights

There are two possibilities I can come up with that don't involve ordinary planar reflection. The first is to perform screen-space reflection, which is fairly cheap and works for any manner of ...
jmegaffin's user avatar
  • 4,903
4 votes

How is structural analysis done in games (e.g.: bridge building, Dig or Die, and 3D)?

I've personally had good success with Iterative Relaxation. I think it follows the laws of physics quite nicely when dealing with objects made of aggregates of blocs. I believe the BridgeBuilder ...
MrBrushy's user avatar
  • 411
4 votes
Accepted

How to make far block graphically better?

What you see is there because the textures are in a higher resolution than what they get drawn in. This results in a very pixelated look. To "fix" this you can generate mipmaps. Mipmaps are the ...
Bálint's user avatar
  • 14.8k
4 votes
Accepted

Overcoming fill rate and generation bottlenecks in voxel engine

The overhead of instantiation on the GPU is huge relative to those 12 triangles in each cubes. GPUs don't like small (12-triangles) batches. The faster the GPU the worse this overhead gets compared to ...
Stephane Hockenhull's user avatar
4 votes
Accepted

Minecraft-Style Voxel Sunlight Algorithm

For each block that you visit as you're doing your light propagation, store an offset/direction to the brightest light shining onto it from a neighbour (eg. if a block is receiving a value of 5 from ...
DMGregory's user avatar
  • 132k
4 votes
Accepted

How does a game like Minecraft handle block and entity updates?

Don't run updates more frequently than necessary. Many of the things you mentioned don't need to be updated every single game tick. The plant growing mechanic, for example, is something where you can ...
Philipp's user avatar
  • 118k
3 votes
Accepted

Cube world rendering optimizations

(In this answer I assume that your world is made of separate cubes. If some cubes joined together into grids, then the algorithm can be improved a lot.) You can check if a side is completely inside ...
HolyBlackCat's user avatar
  • 1,998
3 votes
Accepted

Voxel river flow simulation

A fairly straightforward algorithm for this can be established, if you can assume some fixed 2D grid of cells, each of which contains a value for the level of the water in them. Imagine an infinitely ...
MrCranky's user avatar
  • 6,058
3 votes

How to handle collision detection & response in voxel engine with slopes?

There is a fairly simple way to do collision detection between a single "voxel shape" and an AABB. It relies on the SAT (separating axis theorem) - finding a plane which separates both objects. As ...
JBeurer's user avatar
  • 452
3 votes

How to remove voxel lights with Minecraft-style algorithm?

You can't. That's one of the downsides to MC's lighting model. What you can do is update the just the cell by setting them to max of the neighbours minus the decay like if there wasn't a light there ...
ratchet freak's user avatar
3 votes
Accepted

How can I randomly pick points on a triangle?

What you need is a specific coordinate system where instead of having right angles in the center, you have one of the angles of the triangles. The units on each axis are also equal to the length of ...
Bálint's user avatar
  • 14.8k
3 votes
Accepted

How do i store blocks information in my Voxel game?

I would recommend you take a look at the flyweight pattern. It allows you to use objects such as tiles or blocks in very large numbers when a simple repeated representation would use an unacceptable ...
Shashimee's user avatar
  • 1,240
3 votes

How to efficiently spawn / instantiate a large amount of objects from a prefab

Don't use thousands of GameObjects. Don't use the flyweight pattern. Do as Peter says: batch your vertices. You can learn the basics of procedural mesh construction ...
Engineer's user avatar
  • 29.4k
3 votes
Accepted

Name of this technique used in games such as Minecraft or the sims

It's either called Marching cubes/squares (depends on how many axes you're working with), autotile or -fence. The marching algorithms work on filled areas. You define whether the corners of the ...
Bálint's user avatar
  • 14.8k
3 votes
Accepted

How to make player seem bigger / world smaller, without changing world coordinates

Move the camera higher up. The human brain expects to see things from the normal human eye height above the ground, about 150-170 cm. So your walls look about 4-6 metres high. Make the camera 10 times ...
user253751's user avatar
3 votes

Intersection of thick line with a grid

If the thickness of your line / the radius of the circle following it is substantially narrower than your grid spacing, then it suffices to take the circle traversing your line and approximate it as a ...
DMGregory's user avatar
  • 132k
3 votes
Accepted

Octree Terrain Destruction and LODs

The primary goal of LOD is to reduce the cost of drawing by not drawing unnecessarily fine detail. It is not usually about discarding information from RAM. In fact, in a conventional polygonal-model ...
Kevin Reid's user avatar
  • 5,398
3 votes

Isometric ordering issue with moving entities taller than one block

Usually we would sort objects by their ground position. In fact, we can argue there are two orders: Sort objects by their ground position, back to front. Sort object by their elevation, bottom to top....
Theraot's user avatar
  • 25.1k
2 votes

Efficient vertex buffer memory management?

i have implemented a minecraft renderer on myself 2 years ago. You have a vertexbuffer for every chunks. Thats right, so you only need to update that chunk if Anything changes. Due to the fact you ...
kaiser's user avatar
  • 204

Only top scored, non community-wiki answers of a minimum length are eligible