You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/_index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ link = "/wiki/procedural-generation"
33
33
34
34
[[extra.list]]
35
35
title = "Engines"
36
-
content = "Don't want to start entirely from scratch? Fear not! There are various <a href='wiki/engines'>Game Engines</a> you can use as basis for your project..."
36
+
content = "Don't want to start entirely <a href='wiki/engine-creation'>from scratch</a>? Fear not! There are various <a href='wiki/engines'>Game Engines</a> you can use as basis for your project..."
{% info_notice() %} Note: This section is about *runtime* storage, not [serialization](/wiki/serialization). {% end %}
11
-
12
10
The simplest way to store voxels is to define a three-dimensional array of elements (be it `struct`s or `integer`s), where each element represents a single voxel:
13
11
14
12
```c#
@@ -41,7 +39,8 @@ var voxels = new VOXEL[height * depth * width];
41
39
// So let's define a function (here a lambda) for it:
// ^ NOTE: You may want to throw an error right here
44
-
// if the coordinate components are out of bounds.
42
+
// if either the coordinate components
43
+
// or the resulting index are out of bounds.
45
44
46
45
// Set a voxel:
47
46
voxels[idx(x,y,z)] =voxel;
@@ -52,7 +51,7 @@ var voxel = voxels[idx(x,y,z)];
52
51
53
52
Now, storing voxels in a plain array like this is perfectly fine for small scenes...
54
53
55
-
However, for larger scenes, we'll have to use a data-structure that allows both loading and purging *parts of our volume* (called [Chunks](/wiki/chunking)) from memory, nearly in realtime, without slowing down *accessing*our voxel data.
54
+
However, for larger scenes, we'll have to use a data-structure that allows both loading and purging *parts of our volume* (called [Chunks](/wiki/chunking) or Bricks) from memory, nearly in realtime, without slowing down the *access times* of our voxel data too much.
56
55
57
56
> **Note:** These techniques can often be combined.
Copy file name to clipboardExpand all lines: content/wiki/engines/index.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,10 +36,12 @@ Following are a few things you must keep in mind and be aware of **before** you
36
36
2. It is a *massive* amount of work, potentially spanning over years of your life.
37
37
3. Having several years of programming experience is a must; nobody will hold your hand in this endeavour.
38
38
4. All the tooling for asset-, level- and gameplay-creation? You'll have to make them.
39
-
5. Running into driver bugs will eat a lot of time and cause premature balding.
39
+
5. Running into driver bugs and various platform/OS differences will eat a lot of time and cause premature balding.
40
40
41
41
The above list might make you question *"Why would anyone do this?!"*, to which most of [us](/wiki/community) will say... because it's fun! :D
42
42
43
43
A more concrete reason is that, by writing both the high- and low-level code, you can gain *a lot* of performance (that'd otherwise be left on the table) *and* the freedom to make some truly awesome things.
44
44
45
-
{% todo_notice() %} Create an article for game engine creation. {% end %}
45
+
But with that said, keep in mind that *creating a game* is still best done with an existing engine.
46
+
47
+
If you're still here, [let's get started](/wiki/engine-creation), shall we?
> This is a rewrite; the original article can be found here: [https://www.longor.net/articles/voxel-palette-compression-reddit](https://www.longor.net/articles/voxel-palette-compression-reddit)
10
-
11
9
When writing a voxel engine, eventually you will come to realize that storing your voxels as 32-bit integers (or worse: as individual heap-allocated objects!) is eating a lot more memory than you'd like, potentially slowing down your game without any obvious reason as to *why*, and doing [bit-twiddling](https://graphics.stanford.edu/~seander/bithacks.html) to pack your data into a smaller space, is probably giving you quite a headache, so you might be thinking: There *has* to be a better way! *Right*...?
12
10
13
11
**And there is!**
@@ -91,3 +89,7 @@ Given a 32-bit architecture which aligns allocations on 32-bit/4-byte boundaries
91
89
This gives you at minimum ***31 bits*** to encode a voxel type in (*63* bits on a 64-bit CPU!), which should be *way* more than enough for terrain (which tends to make up the majority of a voxel world by sheer volume), thus eliminating a *ton* of allocations and pointers!
92
90
93
91
{% todo_notice() %} Implementation? {% end %}
92
+
93
+
## References
94
+
95
+
This article is a rewrite; the original article can be found here: [https://www.longor.net/articles/voxel-palette-compression-reddit](https://www.longor.net/articles/voxel-palette-compression-reddit)
0 commit comments