Materials
Learn all about using materials on voxels!
Using landscape materials
The fastest way to get started with materials in the plugin is to reuse existing landscape materials.
Create a new Voxel Landscape Material Collection
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-21e7816ea0e78548b46c7b1b90360be0375c01e2%252FjlYwcW2fRS.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=92cf2c&sv=1)
Assign your landscape material to the Material property:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-8364b21dc2f82c7128060b04aeb7c4bfcad57466%252F2020-10-17-18-42-07-UE4Editor-Win64-DebugGame_q22sLPpY9Y.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=a61adf9b&sv=1)
This popup should appear, click Fix Now. This will replace the layer blend nodes in your material by ones compatible with both Unreal Landscapes and voxels.
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-1d0e8ebe891597772b414d3664430535cf185900%252FbNANaRtm61.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=7d1af8b3&sv=1)
On your voxel world, switch to Multi Index and set the collection to the one we just created
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-f3bc5dca3e23f8395e20af562f9dbf6c14e4c711%252F2020-10-17-18-44-01-UE4Editor-Win64-DebugGame_o2bWUlV8kr.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=c91e81c0&sv=1)
You should now see your material on your voxel world!
You can now follow the Painting section of Multi Index Materials!
Use Cases
Colored Material
If you just want your material to be a flat color, you need to use the RGB material config, and set Voxel Material to either:
M_VoxelMaterial_Colors if you want flat shading:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-374b2876710c46890f0cd6111ef87c89b7734d3f%252FTqmYOBN.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=48176133&sv=1)
M_VoxelMaterial_Colors_NormalShading if you want a normal shading:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-2ef07d3240b1493754d909a51372d49ca51a0251%252F2j0fAxA.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=ac897ce9&sv=1)
Single Material
If you want your entire world to have a single material, use the RGB material config and set Voxel Material to your material.
Up to 5 smoothly blended materials
If you want to blend a maximum of 5 materials on your entire world, you can use a 5 way blend.
To do so, set your material config to RGB. Then, create a material instance like Examples/Materials/Quixel/MI_VoxelQuixel_FiveWayBlend_Inst'.
To paint, use the Five Way Blend mode:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-ea6f934187fcb3e7b7c1b70f9369110aa695965e%252FXLdENOn.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=73fa9a5e&sv=1)
Up to 256 materials with no blending
If you want to have up to 256 materials with no blending between them, use the Single Index material with a Voxel Basic Material Collection.
Set your voxel world material config to Single Index
Create a new Voxel Basic Material Collection and set your Voxel World Material Collection to it:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-6fff1ed75b435ee28662d1d09d85069d99d9357b%252Fa4bf13S.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=f0419824&sv=1)
Fill it up with materials:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-7dc77dc07f74f2d98c6a2c11fabadf90154512c5%252FFlMDay0.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=55db5427&sv=1)
To paint a material, use the Single Index paint mode
This mode is most useful with the Cubic mode:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-df83f1944d0ce493835ed2a4de4ec3b03d12fd39%252FhpHYxRd.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=6efb6818&sv=1)
Behind the scenes, the voxel meshes are split into multiple sections to render each material.
Because of this, don't paint too many different indices too close to each others, or your draw call count will explode.
Up to 256 materials with max 4 materials blended per voxel
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-4f88b3b67e6d345faf72b5022db66199ce58b42d%252FXW4o2g3.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=61028114&sv=1)
UV
Main UV channel
There are three UV modes:
Global UVs: U = Global Position X and V = Global Position Y. Useful to quickly test materials without adding some triplanar projection to them, but has issues if your voxels aren't all more or less facing up.
Pack WorldUp in UVs: pack the world generator up vector in the UVs. You can recover it like that:
X = U
Y = V
Z = sqrt(1 - U*U - V*V)
Additional UV channels
The plugin also stores additional UV channels in voxel materials. By default, 2 channels are stored. This can be changed in C++ using VOXEL_MATERIAL_ENABLE_UVX in Voxel\Source\Voxel\Public\VoxelUserDefinitions.h
.
UV channels can be set in voxel graphs using the following nodes:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-9e7b9ffa12bca33cfd566abe6e990a47a3262e85%252FxJSvwCZ.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=94ea2d82&sv=1)
In C++, use SetUV_AsFloat
. You can then read the values in your material using:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-46eab7dabe384b6794ddc6f0b61ee691efcc25c5%252FZC0BxgP.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=448d3a50&sv=1)
Normal
There are three normal modes:
No Normal: no normal are computed except on the chunk borders where they are needed for the transvoxel transitions.
Gradient Normal: use the density field gradient to compute the normal. If it doesn’t look good, try to divide the output value your world generator by 5, or use the Set High Resolution Value node in voxel graphs: as the voxel values are clamped between -1 and 1, this allows you to gain some precision that would be lost by the clamping. Relatively expensive if you have a complex world generator.
Mesh Normal: compute the normal from the triangles, unless on the chunk borders where gradient normal are used because mesh normal aren’t the same for different chunks.
Tessellation
Tessellation is automatically computed if the material is tessellated.
Tricky details
Tangent Space Normals
Does not apply to Cubic!
Voxel meshes do not have tangents. As such, you can't use Tangent Space Normals. Since these are on by default, you need to disable them in all the materials you will be using on the voxel world:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-2573de6e9573df544507fd1839eae8ceb1e6128c%252FM7CylJT.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=8531e330&sv=1)
Additional Data Channels
Single Index only uses the Alpha channel to store the index. You can store a RGB color in the remaining vertex colors.
Voxel Graph Usage
Use the Set Single Index/Add Multi Index/Set Color/Set UV nodes. These nodes are "smart": based on the material config used, they will only set the relevant fields.
Material Collection Helper
As it can be hard to know which material collection index corresponds to which material, you can use:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-15478a82cf51751374f88d098a8d059298f82462%252FEBo7eui.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=ec7ebe17&sv=1)
This will return the index of that material in the active voxel world Material Collection.
C++ Usage
In C++, you can use the FVoxelMaterialBuilder located in VoxelMaterialBuilder.h. First call SetMaterialConfig on it, and then the various edit function (AddMultiIndex etc), and finally Build.
FVoxelMaterialBuilder Builder;
Builder.SetMaterialConfig(EVoxelMaterialConfig::MultiIndex);
Builder.AddMultiIndex(0, 0.5f);
Builder.AddMultiIndex(1, 0.2f);
Builder.AddMultiIndex(2, 0.7f);
Material = Builder.Build();
Dithering
If you want your chunks to dither properly when changing LOD, you need to set your material Blend Mode to Masked:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-b5d66f0691e4118072a63855d30f4774558fbc4a%252FhvJTe9V.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=4c7d7214&sv=1)
and plug the Voxel Opacity material function into the opacity mask output:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-b258c6ac8cd84491b8291cd4b8ef8f97f9534e26%252F9wm6Fcb.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=e019a9b7&sv=1)
Using a different material on sides/top/bottom in Cubic Mode
You might want to use a different material depending on the face in cubic mode.
To do so, tick One Material Per Cube Side in the advanced section of your voxel world Materials category:
![](https://docs.voxelplugin.com/~gitbook/image?url=https%3A%2F%2F4275809322-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FO4LAZ8J6QCpYVrmxy1j0%252Fuploads%252Fgit-blob-fdab0fcbf5397fc0222dd3db3da29f7e795eb7e3%252FE9rmutU.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=3fa6cfe7&sv=1)
Then you'll need to do a bit of math:
Tops will have the material with index 3 x Index
Sides will have the material with index 3 x Index + 1
Bottoms will have the material with index 3 x Index + 2
So for instance, say you want to have:
On material index 0 : Grass on top, Dirt on sides and Rock on bottom
On material index 1 : Sand on top, Gravel on sides and Rock on bottom
Then you need to use the following indices in your material collection:
Index 0 : Grass
Index 1 : Dirt
Index 2 : Rock
Index 3 : Sand
Index 4 : Gravel
Index 5 : Rock
Last updated