Voxel Plugin
2.0p-340
2.0p-340
  • Home
  • Getting Started
    • Installing Voxel Plugin
    • Installing Example Content
    • Migrating from 1.2
  • Knowledgebase
    • Using Graphs
      • Graph Preview
      • Buffers and Uniforms
    • Channels
    • Surfaces & Materials
      • Working with Surfaces
        • Distance Fields & Distance Checks
        • Applying Materials to a Surface
      • Material Definitions
        • Creating Materials from Scratch
        • Extending the Complex Material Sample
        • Technical Details
        • Detail Textures
    • Brushes
      • Voxelized Meshes
    • Foliage
    • Navmesh & Collision
    • Sculpt Volumes
    • Blueprints
      • Setting graph parameters
      • Querying voxel graphs
    • Graph Design
      • Why Landmass & MetaGraphs
      • Execution Flow & Query Data
      • Node Types
      • MetaGraph Macros
      • Adding Custom Nodes
    • Profiling & Debugging
      • Generation Performance
      • Memory Usage & Render Performance
      • Debugging plugin code
    • Platform Support
      • Targeting Mac & iOS
      • Targeting Android
  • Resources
    • Voxel Graph API
      • Exec Nodes
        • Edit Sculpt Surface
        • Execute
        • Merge Execs
        • Debug
          • Debug Delay
        • Set Sculpt Source Surface
        • Register To Channel
        • Generate Marching Cube Collision & Navmesh
        • Generate Marching Cube Surface
        • Create Marching Cube Preview Mesh
        • Write Volume Texture
        • Generate Point Collision
        • Render Mesh
      • Misc
        • Get Previous Output
        • Query with Gradient Step
        • Query with Position
        • Filter Buffer
        • Make Value
        • Is Valid
        • Get Collision Enabled
        • Get LOD
        • Get Point Chunk Bounds
        • Is Editor World
        • Is Game World
        • Is Hidden in Editor
        • Is Preview Scene
        • Get Position 2D
        • Get Position 3D
      • Sculpt
        • Get Sculpt Surface
      • Point
        • Make Chunked Points
        • Merge Points
        • Set Point Attribute
        • Get Point Attribute
        • Set Actor Property
        • Get Actor Property
        • Set Parent Point Attribute
        • Get Parent Point Attribute
        • Set Point Mesh
        • Get Point Mesh
        • Get Parent Point Mesh
        • Set Point Position
        • Get Point Position
        • Get Parent Point Position
        • Set Point Rotation
        • Get Point Rotation
        • Get Parent Point Rotation
        • Set Point Scale
        • Get Point Scale
        • Get Parent Point Scale
        • Set Point Normal
        • Get Point Normal
        • Get Parent Point Normal
        • Set Actor Class
        • Get Actor Class
        • Get Parent Actor Class
        • Set Point Custom Data
        • Get Point Custom Data
        • Get Parent Point Custom Data
        • Get Point Seed
        • Apply Translation
        • Apply Rotation
        • Apply Scale
        • Apply Point Storage
        • Generate Surface Points
        • Make Points
        • Get Points
        • Filter Points
        • Density Filter
        • Make Radial Point Spawner
        • Prune by Bounds
        • Prune by Distance
        • Raymarch Distance Field
        • Scatter Points
      • Material
        • Make Material
        • Make Float Detail Texture Parameter
        • Make Color Detail Texture Parameter
        • Make Material Detail Texture Parameter
        • Make Normal Detail Texture Parameter
        • Make Scalar Parameter
        • Make Vector Parameter
      • Math
        • Trig
          • Sin (Radians)
          • Sin (Degrees)
          • Cos (Radians)
          • Cos (Degrees)
          • Tan (Radians)
          • Tan (Degrees)
          • Asin (Radians)
          • Asin (Degrees)
          • Acos (Radians)
          • Acos (Degrees)
          • Atan (Radians)
          • Atan (Degrees)
          • Atan2 (Radians)
          • Atan2 (Degrees)
          • Get PI
          • Radians to Degrees
          • Degrees to Radians
        • Float
          • Bilinear Interpolation
          • Frac
          • Power
        • Boolean
          • NOT Boolean
          • NOR Boolean
          • XOR Boolean
          • AND Boolean
          • OR Boolean
          • NAND Boolean
        • Integer
          • Left Shift
          • Right Shift
          • Bitwise AND
          • Bitwise OR
          • Bitwise XOR
          • Bitwise NOT
        • Rotation
          • Make Quaternion
          • Break Quaternion
          • Make Rotation from Z
          • Combine Rotation
        • Operators
          • Equal
          • Nearly Equal
          • Not Equal
          • Less
          • Greater
          • Less Equal
          • Greater Equal
          • Ceil
          • Round
          • Floor
          • Add
          • Subtract
          • Multiply
          • Divide
          • % (Integer)
          • Min
          • Max
          • Abs
          • One Minus
          • Sign
        • Misc
          • Clamp
          • Mapped Range Value Clamped
          • Mapped Range Value Unclamped
          • Height Splitter
          • Interpolate
          • Lerp
          • Safe Lerp
          • Smooth Step
        • Seed
          • Mix Seeds
          • Make Seeds
        • Vector Operators
          • Cross Product
          • Dot Product
          • Normalize
          • Length
          • Length XY
          • Distance
          • Distance 2D
        • Conversions
          • To Double Vector (Double Linear Color)
          • To Double Vector 2D (Double Linear Color)
          • To Linear Color (Double Linear Color)
          • To Vector (Double Linear Color)
          • To Vector 2D (Double Linear Color)
          • To Double Linear Color (Double)
          • To Double Vector (Double)
          • To Double Vector 2D (Double)
          • To Float (Double)
          • To Double Linear Color (Double Vector 2D)
          • To Double Vector (Double Vector 2D)
          • To Linear Color (Double Vector 2D)
          • To Vector (Double Vector 2D)
          • To Vector 2D (Double Vector 2D)
          • To Double Linear Color (Double Vector)
          • To Double Vector 2D (Double Vector)
          • To Linear Color (Double Vector)
          • To Vector (Double Vector)
          • To Vector 2D (Double Vector)
          • To Double (Float)
          • To Linear Color (Float)
          • To Vector (Float)
          • To Vector 2D (Float)
          • To Double (Integer)
          • To Float (Integer)
          • To Int Point (Integer)
          • To Int Vector (Integer)
          • To Int Vector 4 (Integer)
          • To Seed (Integer)
          • To Double Linear Color (Int Point)
          • To Double Vector (Int Point)
          • To Double Vector 2D (Int Point)
          • To Int Vector (Int Point)
          • To Int Vector 4 (Int Point)
          • To Linear Color (Int Point)
          • To Vector (Int Point)
          • To Vector 2D (Int Point)
          • To Double Linear Color (Int Vector 4)
          • To Double Vector (Int Vector 4)
          • To Double Vector 2D (Int Vector 4)
          • To Int Point (Int Vector 4)
          • To Int Vector (Int Vector 4)
          • To Linear Color (Int Vector 4)
          • To Vector (Int Vector 4)
          • To Vector 2D (Int Vector 4)
          • To Double Linear Color (Int Vector)
          • To Double Vector (Int Vector)
          • To Double Vector 2D (Int Vector)
          • To Int Point (Int Vector)
          • To Int Vector 4 (Int Vector)
          • To Linear Color (Int Vector)
          • To Vector (Int Vector)
          • To Vector 2D (Int Vector)
          • To Double Linear Color (Linear Color)
          • To Double Vector (Linear Color)
          • To Double Vector 2D (Linear Color)
          • To Vector (Linear Color)
          • To Vector 2D (Linear Color)
          • To Integer (Seed)
          • To Double Linear Color (Vector 2D)
          • To Double Vector (Vector 2D)
          • To Double Vector 2D (Vector 2D)
          • To Linear Color (Vector 2D)
          • To Vector (Vector 2D)
          • To Double Linear Color (Vector)
          • To Double Vector (Vector)
          • To Double Vector 2D (Vector)
          • To Linear Color (Vector)
          • To Vector 2D (Vector)
        • Curve
          • Make Curve from Asset
          • Sample Curve
        • Color
          • Break Double Linear Color
          • Break Linear Color
          • Make Double Linear Color
          • Make Linear Color
        • Vector
          • Break Double Vector
          • Break Vector
          • Make Double Vector
          • Make Vector
        • Vector2D
          • Break Double Vector 2D
          • Break Vector 2D
          • Make Double Vector 2D
          • Make Vector 2D
        • Interval
          • Break Float Range
          • Break Integer Range
          • Make Float Range
          • Make Integer Range
        • Int Point
          • Break Int Point
          • Make Int Point
        • Int Vector
          • Break Int Vector
          • Make Int Vector
        • Int Vector 4
          • Break Int Vector 4
          • Make Int Vector 4
        • Transform
          • Break Transform
          • Inverse Transform Location
          • Make Transform
          • Transform Location
        • Distance
          • Smooth Max
          • Smooth Min
        • Box
          • Break Box
          • Extend Box
          • Make Box
          • Make Box from Radius
          • Make Infinite Box
          • Transform Box
      • Color
        • Distance to Color
      • Surface
        • Merge Surface
        • Get Merge Data
        • Get Surface Distance
        • Get Surface Material
        • Get Surface Attribute
        • Set Surface Material
        • Set Surface Attribute
        • Bind Attribute Detail Texture
        • Make Height Surface
        • Make Volumetric Surface
        • Make Sphere Surface
        • Make Box Surface
        • Invert Surface
        • Mask Surface
        • Inflate Surface
        • Displace Surface
        • Create Voxelized Mesh Surface
        • Blend Materials
        • Get Bounds Box
        • Get Surface Bounds
        • Make Bounds from Local Box
      • Channel Nodes
        • Query Channel
      • Noise
        • Advanced Noise 2D
        • Advanced Noise 3D
        • Perlin Noise 2D
        • Perlin Noise 3D
        • Cellular Noise 2D
        • Cellular Noise 3D
        • True Distance Cellular Noise 2D
      • Name
        • Append Names
      • Array
        • Length
        • Get
      • Gradient
        • Get Gradient
      • Chunk Spawner
        • Make Invoker Chunk Spawner
        • Make Screen Size Chunk Spawner
      • Random
        • Rand Float
        • Random Vector
        • Random Rotator
        • Random Select
        • Hash Position
        • Rand Unit Vector
        • Break Random Vector Settings
        • Make Random Vector Settings
      • Flow Control
        • Select
      • Actor
        • Get Transform
      • Network
        • Is Client
        • Is Dedicated Server
        • Is Listen Server
        • Is Server
        • Is Standalone
      • Heightmap
        • Get Heightmap Bounds
        • Make Cubemap Planet Surface
        • Sample Heightmap
      • Voxelized Mesh
        • Make Voxelized Mesh from Static Mesh
    • Glossary
    • Licensing
    • Release Notes
      • 2.0p-340 Release Notes
      • 2.0p-320 Release Notes
      • 2.0p-317 Release Notes
      • 2.0p-304 Release Notes
    • Roadmap
Powered by GitBook
On this page
  • 1. Blending Brushes
  • 2. Optimizing Brushes
  • 2.1 Holes and glitches with high smoothness
  • 3. Brush Priorities
  • 3.1 Determinism
  • 4. Graph Instances
  • 5. Brush Preview Meshes
  • 5.1 Improving the brush asset preview

Was this helpful?

  1. Knowledgebase

Brushes

Using graphs as modular, non-destructive pieces for world-creation.

PreviousDetail TexturesNextVoxelized Meshes

Last updated 1 year ago

Was this helpful?

This article assumes basic knowledge about .

Any Voxel Graph can run any nodes, which means there are no preset graph types. But the way graphs are used in practice often does end up following a few common patterns.

One of these patterns is the 'brush' pattern, where a graph is used on a moveable object that doesn't output anything into the world - it only writes data into a channel. Another graph then reads back that channel, and produces a visible output from it.

Examples of this (which can be found in the ) are:

  • A graph writes a sphere into a FoliageDensity channel. This channel is queried in a second graph, which outputs foliage, where it is used as a mask. Foliage now no longer generates where the first graph is placed in the world.

  • A graph writes a voxelized mesh into a Surface channel. This channel is queried in a second graph which has a Generate Marching Cube Surface node, rendering the surface into the world, including the changes made by the first graph.

1. Blending Brushes

By default when registering to a channel, the previous state of the channel is completely ignored. Because brushes are generally used on top of other terrain elements, that's inconvenient and should be accounted for. This can be done by combining the brush' surface with the existing state of the channel using a Query Channel.

It is usually desirable to combine the brush surface with the current state of the channel the brush is about to write into. The result of that combination can then be written into the channel. This prevents brushes completely overriding others that come before them (and therefore making those previous brushes useless).

Image

The combining of surfaces can be done with one of a handful of nodes, all of which also take a Smoothness input (this is usually ), allowing clean blending of multiple surfaces. The following functions exist:

  • Smooth Union

    • This node adds the two surfaces together.

  • Smooth Intersection

    • This node returns the area that overlaps between two surfaces. Somewhat counter-intuitively, an increase in smoothness will make the returned overlap smaller.

  • Smooth Subtraction

    • This node subtracts the "surface to subtract" from another. With this operation, order is incredibly important, as A-B is not the same as B-A.

Images

2. Optimizing Brushes

The Register to Channel node takes a bounds input. When nothing is plugged into this pin, the brush will be registered with infite bounds, in turn meaning that this graph will be run for every voxel in the world. This is incredibly wasteful, as voxels a kilometer away obviously do not need to be affected by a small brush. While this does not matter too much when only a single brush is used, the total world generation time will increase rapidly as the amount of brushes grows, as each will affect every voxel in the world.

This can be addressed by assigning a sensible value to the Bounds pin. When using a node that creates a surface, this surface generally includes correct bounds, so a Get Surface Bounds node can be used on the surface pin, and this can be plugged into the channel's bounds pin.

When a surface is generated manually, for instance using a Make Volumetric Surface node, the math for the bounds will need to be done manually as well.

With the brush' bounds configured properly, the brush will only affect the world's generation within those bounds, making world generation significantly cheaper.

2.1 Holes and glitches with high smoothness

If you increase your smoothness a lot, you might start to notice holes in the voxel mesh:

This is because as the smoothness increases, the area affected by the brush increases as well, but the voxelized mesh bounds don't increase accordingly.

Plugging the same value as was used on the Smooth Union into the Channel's Smoothness pin will allow the plugin to account for this increase in bounds.

With the smoothness properly accounted for in the channel registration, the artifacts should now be resolved.

If accounting for smoothness does not fix holes in the surface, another likely culprit is an inconsistent distance field, leading to falsely failed distance checks. Read more about this issue and its workarounds here: Distance Fields & Distance Checks

3. Brush Priorities

The Register to Channel node has a Priority pin. This is used to sort brushes.

The brush with the highest priority will be queried first. If that brush calls Query Channel, the brush with the second highest priority will then be queried, and so on.

Brush priority can be useful to tune when dealing with smoothness: usually, you want to apply Smoothness after everything else has been computed. If a brush does not seem to be properly affected by its smoothness setting, the solution is often to adjust its priority.

3.1 Determinism

In order to always have different priorities & make the sorting deterministic, brushes have an internal priority computed as follows:

  • Compare the Register to Channel Priority

  • If equal, fall back to a priority based on the path of the graph asset the node is in

  • If equal, fall back to a priority based on the path of the brush actor

  • If equal, fall back to a priority based on the node id hash

This is not usually very important, but it can be a source of problems if brushes are spawned at runtime. If that is the case, make sure all brush actor names are synchronized between clients & servers, and that the names of these actors are saved and loaded properly. Failure to do so will likely result in brushes being having inconsistent effects across game instances.

4. Graph Instances

When you have a lot of parameters, sometimes you want to create templates for these parameters - just like material instances in the engine.

In order to do this, find the graph this instance should be based on, right-click it and select "Create Instance". This will create a Graph Instance object which inherits its logic from the parent, but allows you to override just the parameters.

5. Brush Preview Meshes

By default, graphs don't generate any sort of collision, making them hard to select in the viewport. For brushes, a preview mesh can be generated using the Create Marching Cube Preview Mesh, which can then be used as collider so it can be selected. Additionally, this will help show which brushes are selected and what shapes they have.

By default, the preview mesh is a perfect match of the rendered mesh. This is not always desirable as it leads to Z-fighting and overlapping meshes.

This can be accounted for by using the Grow node on the surface plugged into the preview mesh node.

5.1 Improving the brush asset preview

The Preview tab of a graph asset uses the same preview mesh and material as the editor viewport.

The Is Preview Scene node tells a graph whether it is being shown in the editor viewport, or in the graph editor scene. Using it, you can configure your graph to run different logic, or use a different material, between these two situations.

Be careful when controlling bounds manually, or using high smoothness. If you set bounds that are too small, or don't account for smoothness, you might start to get in the voxel mesh.

Channels
Voxel Content
rendering glitches/holes
The "Create Voxelized Mesh Surface" comes with correct bounds, so we can use those directly for the channel registration.
In this case, the parent brush has Smoothness exposed as a parameter, so that can be customized on the instance.
This node creates a standalone mesh with collision, rendered when it is selected.