Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Hot answers tagged

106

With regards to Java vs C++, I've written a voxel engine in both (C++ version shown above). I've also been writing voxel engines since 2004 (when they were not vogue). :) I can say with little hesitation that C++ performance is far superior (but it is also more difficult to code). Its less about the computational speed, and more about memory management. ...


23

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 would only make sense to use it over the "storing blocks in fixed arrays" method (the one you described earlier) is when only a quarter of the blocks are solid, ...


21

For the base land, make two 2D continuous noise fields (Perlin, Simplex, Wavelet, a combination thereof - whatever works for you), one with mostly low frequency. low amplitude parts for the upper limit of the land, the other with both high frequency, high amplitude parts and low frequency, high amplitude for the lower limit of the land. Where the lower limit ...


21

When I had this problem while working on my Cubes, I found the paper "A Fast Voxel Traversal Algorithm for Ray Tracing" by John Amanatides and Andrew Woo, 1987 which describes an algorithm which can be applied to this task; it is accurate and needs only one loop iteration per voxel intersected. I have written an implementation of the relevant parts of the ...


15

Would something like this be enough? If so, check this article. Quoting the most relevant parts: In order to get more interesting noise multiple octaves of simplex noise can be added together. [...] Since I want to get a roughly spherical floating rock of sorts, I need to multiply the noise with its distance from the center. [...] I also want the rock ...


15

You mention doing frustum culling on individual blocks — try throwing that out. Most rendering chunks should be either entirely visible or entirely invisible. Minecraft only rebuilds a display list/vertex buffer (I don't know which it uses) when a block is modified in a given chunk, and so do I. If you're modifying the display list whenever the view changes,...


15

From your diagram, it looks like the geometry you're constructing contains T-junctions - places where a vertex of one triangle is supposed to lie exactly on another triangle's edge (resulting in one edge meeting another in a "T" shape). Due to the limitations of finite-precision arithmetic, the vertex usually cannot be guaranteed to meet the edge perfectly ...


14

First. Lets write what do we know about each voxel : voxel = (x, y, z, color) // or some other information General storage General way is simply this: set of voxels = set of (x,y,z, color) Note, that triplet (x,y,z) identify each voxel uniquely, since voxel is point in space and there is no way two points occupy one place (I believe we are talking about ...


14

This is achieved by interpolating ramps between cubes of different height. When you have a scenery like this (seen from the side) # #### ## ############ you would add polygons to make it look like this: /#\ /####\ /##\ ############ An algorithm to calculate these ramps is the marching cubes algorithm. When you want it to be even more beautiful, ...


13

Pixel. The term voxel is short for "volume pixel" or "volume picture element." Consequently a voxel without the "volume" bit is just a regular pixel. The term for gameplay structural unit in a 2D game that can be deformed, damaged or destroyed in the course of game play (as in Terraria and games of its ilk) would most commonly be called a "tile," although ...


12

A* would work just fine. Path finding is what you want, finding the shortest path is just as fast (or faster) than finding any path at all. In this situation A* is likely the most suitable given you have a start and end point. this means you have the added heuristic to speed up the search. With A* typically the first path you find is the shortest, so it's ...


11

Castle Story looks like this due to technical constraints: Were there to be a heightmap per each voxel in the entire volume, rather than only a heightmap per each surface voxel, storage cost would be vastly greater, on the order of O(n^3) which can be prohibitive, as opposed to a more favourable O(n^2), where n is the side length of a cubic voxel space ...


10

What about the third option, using instanced arrays? Basically you draw many many boxes (made of a simple 8-vertex cube) with a single draw call, sourcing the positions (and other data) as per-instance attributes from the voxel-data VBO (using glVertexAttribDivisor in OpenGL, I'm sure DX has that, too). This might be faster than the geometry shader approach ...


10

Due to the sheer volume of data in your average voxel world, it will be challenging to draw much geometry with your approach, before hardware limits are reached, without some kind of spatial subdivision approach. You also need to be highly efficient in packing data at the bit/byte level. Method: RLE Enter Run-Length Encoding (RLE) compression as a popular ...


10

Terrain generation falls under the form part of development. It's an artistic endeavor, so I'm not so sure there's a correct answer. However, I can try to tell you about the knobs you can turn to get different results, and it'll be up to you to turn them to get the result you want. Compress/expand: You can stretch or shrink the noise along a specific axis ...


10

You don't need a new way of storing them, just just need a new way of accessing them. Storing the data in lists in the chunks is fine. You just need a way to index into them at the world level. The world should contain a list of chunks currently loaded, and the chunks contain lists of voxels. Each chunk should be the same size (contain the same volume of ...


9

I'm thinking of a minecraft type scene, where by voxel you mean a world of blocks that are actually rendered using polygons: If you use a geometry shader it will be difficult to avoid having exactly three faces (or whatever) per voxel. If you have lots of adjacent blocks that are of the same texture then you can use tiling of the textures to have much less ...


9

Simplest option is to grab the lighting from the block your standing on (or if possible the lighting on the block in the air that corresponds to the block the pickaxe is in) and use that for lighting the pickaxe/player. Or in other words, calculate the lighting for the pickaxe as if it was a block in that position. To get more realistic shadows you would ...


9

There are a couple different ways to store the data for a game with blocks like Minecraft. The way I believe Minecraft does it is breaks the world up in the 16x16x256 Chunks. The chunks around the player are loaded into memory when the player starts the game, then a background thread loads more as you walk around. Here is a video that shows it: http://www....


9

If you're prepared to do some pre-processing and eat the storage cost, then partitioning voxels into connected groups at build time gives an obvious answer to 'is there a path at all'. There is a path between two voxels if they're in the same group. The problem with that obviously is that you have to store group information somewhere, and that depends on ...


8

The continuation of my comment: In essence when choosing an existing format these are the problems you must consider: Am I saving time by using this? Do I get a editor? Do I get a library to load this from the game media? Am I deriving any benefit from using this? Are there clever optimizations in existing libraries? Is the format compact, but not ...


8

While I appreciate Kevin Reid's answer, it was at a level that was higher than what my question was asking. Understandably with out knowledge of Bullet Physics, it'd be hard to answer this question. I got this working and have an answer that is specific to Bullet Physics. Along with extending the RigidBody class like I mentioned in my question. I also ...


7

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 novel addition is a kind of "adapter" to bridge regions of voxels at different resolutions. Let's say you have an area of very dense voxel samples near your ...


7

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 problem, vertex sharing, triplanar texturing, and texture splatting. The area you are interested in is covered in chapter 4, Level of Detail. It introduces 512 new ...


7

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 a fixed depth. eg. for a 16x16x16 chunk, you need at most 5 levels of tree: chunk root (16x16x16) first tier octant (8x8x8) second tier octant (4x4x4) third ...


7

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 other data structures. A hash table with the coordinates as keys A 2-d tree which you auto-balance so that the root is always at the player (can also be useful ...


6

Every light has a precise (floating point) position, and bounding sphere defined by a scalar light radius value, LR. Every voxel has a precise (floating point) position at it's centre, which you can easily calculate from its position in the grid. Run through every one of 8192 voxels once only, and for each, see if it falls within each of N lights' spherical ...


6

I think Minecraft is almost a genre, at this point. There are many success where people are taking the core concept adding something new. But you have to find the core mechanic that differentiates you from the original.


6

That depends on the spatial subdivision method you use, although all subdivision methods (like any compression method) eventually pan out where no further compression can take place, due to data structure overheads and other logical/mathematical factors. An example can be found in octrees. For each node in the octree, a pointer must be kept to it's parent ...


6

Ok, it's pretty simple. The good bit is, once you fix this stuff it'll perform a couple of orders of magnitude better ;) The first rule is that for functions that are frequently used and perform read operations, you can't afford to allocate memory if you want your game to actually function or perform at an interactive level. You can't afford to allocate a ...


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