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. Working with Material Definitions
  • 1.1 Configuring Parameters
  • 2. Configuring a Custom Material
  • 2.1 Reading Data from Material Definitions
  • 2.2 How Layers Blend

Was this helpful?

  1. Knowledgebase
  2. Surfaces & Materials
  3. Material Definitions

Creating Materials from Scratch

Building a custom material is complicated, but the Complex Material template doesn't fit every use case.

PreviousMaterial DefinitionsNextExtending the Complex Material Sample

Last updated 1 year ago

Was this helpful?

This is an advanced workflow. Extending the Complex Material Sample is preferred.

1. Working with Material Definitions

For a straight-forward example, download and explore the BasicMaterial sample.

A material definition, or an instance of one, is an asset that represents a texture layer on the terrain. It defines a set of parameters to be used, generally float data or textures, and a material that reads the parameters for the asset's preview. These parameters will then be sent through to the material being used on the terrain as needed.

Material Definition Instances use a Material Definition as template. These are similar to material instances in Unreal Engine. They inherit from their parent, and can override the values assigned to the parameters. Each customized MDI can then be used as a layer on the terrain.

Material definitions and instances are similar to Multi-Index Layers from Voxel Plugin 1.2.

A material definition's preview material can be configured in the Details panel when no parameters are selected. This material will only be used for previewing the definition and its instances in editor viewports. It should usually be the same material as the terrain has assigned.

1.1 Configuring Parameters

Float-based parameter types are straight-forward to use; just click the plus button, set the name and type, and then set a default value. No other configuration is needed.

Texture parameters have a few extra configuration settings that can be important to consider, which can be found in the Value dropdown underneath the Default Value. Most Material Definitions will have quite a few texture parameters configured, and these settings will vary across them.

1.1.1 Texture and Mip Size

Texture Size and Last Mip Texture Size affect the VRAM (GPU memory) overhead of the texture in the final material.

We recommend keeping texture size as low as possible to minimize VRAM use (A single 4k texture takes up as much space as sixteen 1k textures). If more detail is needed, consider adding it with another texture overlay in the material graph.

The Last Mip Texture Size value should generally be left at its default, unless you understand the impacts of MipMaps on a technical level.

1.1.2 Texture Compression Settings

The Compression type is the most important of these three values. If it is configured incorrectly, instances will throw errors when assigning textures, and your materials might not compile. Currently, the following compression types are available:

  • DXT1

    • Colour textures without alpha channel.

  • DXT5

    • Colour textures with alpha channel. Twice as much memory use.

  • BC5

    • Used exclusively for normal maps.

The compression type picked here has to match whichever compression method is selected in a texture asset's texture settings. If there is a mismatch, the plugin will throw errors.

1.1.3 Using Alpha Channels

Because DXT5 (color with alpha) uses twice as much VRAM as DXT1 (color without alpha), DXT1 should be used for color textures wherever possible. Only set the compression to DXT5 if the alpha channel is really necessary. Doing so doubles the VRAM usage of the entire array, not just for the textures that have an alpha.

Attempting to assign a texture asset with an alpha channel when DXT1 compression is selected on the material definition will cause errors. When this happens, just tick the "Compress Without Alpha" tickbox in the asset's compression settings and save it - this will switch the texture to DXT1.

Color textures without alpha can be assigned without issues when the texture parameter is set to DXT5.

2. Configuring a Custom Material

2.1 Reading Data from Material Definitions

Data from a Material Definition and its instances can be accessed in materials using a handful of helper nodes. To do so, a combination of a Voxel Parameter node and a Get Voxel ... Parameter node is used.

When working with Material Functions, Voxel Parameter nodes can be passed as input pin. The input type needs to be set to Function Input TextureExternal.

The Voxel Parameter node can be configured in the details panel when selected; it takes a reference to a Material Definition, and will then show a dropdown with all the parameters from that Material Definition. The output from this node can then be plugged into the Parameter pin on a Get Voxel ... Parameter. Use the appropriate Get node for the type the parameter has in the Material Definition. For example, if a parameter is a Linear Color, use the Get Voxel Color Parameter node.

2.2 How Layers Blend

The Get Voxel ... Parameter nodes can be used without plugging anything into the MaterialId pin. When used like this, they will do a lerp (linear blend) between the top three layers' value for this parameter.

If a standard linear blend isn't enough, the blend can be done manually by using the MaterialId pin. The relevant MaterialIds and their weights can be retrieved with the Get Voxel Material ID node. In this context, the Layer0/Layer1/Layer2 pins are the indexes of the three highest-weighted layers, and the LerpAlphas are the relevant weights between them.

Material and material definitions like the one shown throughout this article are available for download through the .

With a material definition configured as above, instances can be created and configured, and they can be in a Voxel Graph. A material definition by itself won't make a material appear on the terrain though; for this, an accompanying master material needs to be created.

Voxel Content menu
assigned to surfaces
A material definition on the left, with an instance using it as parent on the right.
A Material Definition with a Texture2D parameter selected. Note the additional settings underneath the Default Value.
A material graph with the Material Definition workflow nodes placed, and a Voxel Parameter node selected.
The "Get Voxel Parameter" node is actually three getters blended together. This can also be done manually for full control.