Voxel Graph Quick Start
Last updated
Last updated
Right click the content browser -> new voxel graph
Add a Set Value node:
Link a Z node to it:
The density will be negative when Z < 0, and positive when Z > 0. As a negative density corresponds to a full voxel, this is what we want.
You can now set your voxel world World Generator property to Object and set its value to your graph. You should see a flat world.
For the hills, we're going to use perlin noise:
This will give us a height. However noise output is between -1 and 1: this is too small for hills! Let's multiply it by a Float Constant node:
We might want to control the hills height from blueprint. Let's expose the constant:
Click on the constant node
On the detail panel on the left, apply the following settings:
Your node should now look like that:
We want to have a positive density (empty) when Z > height, and a negative one (full) when Z < height.
We could do it that way:
However, this would lead to bad looking terrain:
Instead, we're going to subtract the height from the Z value:
That way, we still have a positive density when Z > height and a negative one when Z < height, but without any discontinuities!
This gives the following terrain:
First of all, as we're going to reuse the noise output, we're going to add a local variable. Local variables are only syntaxic sugar - the pins are linked together in a precompiler pass - but they can clean a lot voxel graphs.
Right click in the voxel graph and select Create Local Variable
Select the new node
In the detail panel on the left, set its name to Height and its type to Float
Link the perlin noise output to it, and replace its usage by a new Height node:
Set your voxel world Material Config property to RGB, and the Voxel Material property to M_VoxelMaterial_Colors.
Add the following nodes:
Your world should now look like this:
Set your voxel world Material Config property to Single Index, and the Material Collection property to ExampleCollection.
Add the following nodes:
Your world should now look like this:
Notice how while there is a blending, it's far from perfect.
Set your voxel world Material Config property to Double Index, and the Material Collection property to ExampleCollection.
Add the following nodes:
Your world should now look like this:
Notice how smooth the blending is. If you want a smaller blending distance: