Tweaks
This commit is contained in:
parent
42a8d0e35f
commit
1406d3d07d
@ -92,14 +92,16 @@ It is possible to decide the height of the plane by subtracting a constant (`sdf
|
||||
|
||||
![Offset plane voxel graph screenshot](images/voxel_graph_flat_offset.png)
|
||||
|
||||
By default, the `Subtract` node does nothing because its `b` port is not connected to anything. It is possible to give a default value to such port. You can set it by clicking on the node and changing it in the inspector.
|
||||
By default, the `Add` node does nothing because its `b` port is not connected to anything. It is possible to give a default value to such port. You can set it by clicking on the node and changing it in the inspector.
|
||||
|
||||
(note: I used `Add` with a negative value for `b`, but you can also use a `Subtract` node to get the same result).
|
||||
|
||||
#### Noise
|
||||
|
||||
A flat plane is simple but a bit boring, so one typical way to generate a terrain is adding good old fractal noise. You can do this in 2D (heightmap) or 3D (volumetric).
|
||||
The 2D approach is simpler, as we only need to take our previous setup, and add 2D noise to the result. Also, since noise is generated in the range [-1 to 1], we also need a multiplier to make it larger (`sdf = y - height + noise2d(x, y) * noise_multiplier`).
|
||||
|
||||
There are several types of noise available, each with their own parameters. At time of writing, `FastNoise2D` noise is the best option.
|
||||
There are several types of noise available, each with their own parameters. At time of writing, `FastNoise2D` noise is the best option. `Noise2D` works too but it is slower and more limited (it uses Godot's `OpenSimplexNoise` class).
|
||||
|
||||
!!! note
|
||||
After you create this node, a new `FastNoiseLite` resource must be created in its parameters. If that resource is not setup, an error will occur and no voxels will be generated.
|
||||
@ -186,13 +188,13 @@ This generator uses a number of optimization strategies to make the calculations
|
||||
|
||||
#### Buffer processing
|
||||
|
||||
Contrary to many node-based or expression tools existing in Godot so far, voxel graphs don't litterally run the whole graph once per voxel. Indeed, for a 16x16x16 block, there are 4096 voxels to generate. That would mean traversing the entire graph 4096 times, and the cost of doing that can exceed the cost of the calculations themselves. Besides, switching constantly between node types to run different operations is not CPU-friendly due to all the memory jumps required.
|
||||
Contrary to many node-based or expression tools existing in Godot so far, voxel graphs are not tailored to run on voxels one by one. The main use case is to process a bunch of them. Indeed, for a 16x16x16 block, there are 4096 voxels to generate. That would mean traversing the entire graph 4096 times, and the cost of doing that individually can exceed the cost of the calculations themselves. Besides, switching constantly between node types to run different operations is not CPU-friendly due to all the jumps required.
|
||||
|
||||
So instead, outputs of each node are associated small buffers for a subset of the voxels, say, a 16x16 slice. Then, the graph is traversed once ahead-of-time to obtain a simple list of operations. It is guaranteed that if a node depends on another, the other will have run before.
|
||||
|
||||
![Graph to operations schema](images/voxel_graph_operation_list.png)
|
||||
|
||||
Finally, the generator executes the list, node by node, and each node computes a bunch of voxels at once instead of just one. This ensures that the CPU is almost exclusively used for the operations themselves, providing performance similar to C++, while graph traversal becomes neglibible. It also allows to use [SIMD](https://en.wikipedia.org/wiki/SIMD) very easily, which can be even faster than if the code was written in plain C++.
|
||||
Finally, the generator executes the list, node by node, and each node computes a bunch of voxels at once instead of just one. This ensures that the CPU is almost exclusively used for the operations themselves, providing performance similar to C++, while graph traversal becomes neglibible. It also offers the opportunity to use [SIMD](https://en.wikipedia.org/wiki/SIMD) very easily, which can be even faster than if the code was written in plain C++.
|
||||
|
||||
Buffer processing is mostly an internal detail so there are no particular settings on the scripting API.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user