Custom Voxel Types

Modified on Fri, 04 Feb 2022 at 10:06 PM

Voxel Play allows you to create "Custom Voxels". These are voxel definitions that can take an existing prefab and instantiate the prefab in the scene. You can use custom voxels to add half-blocks or bigger items, like doors.


Note: if you want to customize the default voxel materials, also check the Overriding Materials section.


To define a custom voxel just select "Custom" in the Render Type:



Custom Voxels are great to:

- Use voxels of different shapes.

- Create interactive objects (like doors).

- Place objects that can have custom scripts.


To create a custom voxel just select "Custom" as render type (check the screenshot above) and assign a prefab to the Model field.

Although the prefab can use any material, it's recommended to use one of the following provided "factory" materials (duplicate them before assigning to the prefab):

- VP Model VertexLit

- VP Model Texture

- VP Model Texture Alpha

- VP Model Texture Double Sided

- VP Model Texture Cutout

- VP Model Texture BumpMap

- VP Model Texture Triplanar

These materials can be found in the Resources/VoxelPlay/Materials folder.


Specify which material will be used by the custom voxel. You can select from the dropdown if the custom voxel should use the material attached to the prefab or if VP should use one of the factory materials (like VP Model Texture). If you override the prefab material, VP will preserve any texture, color or normal map of the previous material (if the prefab had a material).


You can also assign an offset, scale and rotation (as well as a random offset and rotation, great for vegetation). It's recommended that the prefab root has scale = 1,1,1 and position/rotation set to zero, and use the offset, scale and rotation properties of the voxel definition instead. However, you can choose any local position, rotation or scale for children objects of the prefab.



Advanced options for Custom Voxels


- Opaque: the amount of lighting that's reduced when crosses this custom voxel. Custom voxels should have an opaque value less than 15, otherwise they will be rendered in fully black (no light). You can leave this value to 0 in most cases.

- OccludesTop / Bottom / Forward / Back / Left / Right: must be true if the custom voxel has a face that occludes completely the adjacent voxel in that direction. This setting can be used to optimize rendering of custom voxels when they are used to fill terrain for example an will prevent rendering of fully surrounded custom voxels.

- GPU Instancing: enable this option to make VP use DrawMeshInstanced API to massively render the custom voxels. Any existing MeshRenderer component on the prefab will be disabled. It's very recommended to enable this option.

- Compute Lighting: improves the colors of the vertices of the gameobject based on the environment lighting (smooth lightning). Results vary depending on the prefab shape. This option is expensive so use it with care, especially if the custom voxel is placed massively.

- Cast / Receive Shadows: if the instances should cast or receive shadows.

- Create GameObject: when a custom voxel has GPU instanced option enabled, by default VP won't instantiate the prefab. However if you have custom scripts or need to create the gameobject, enable this option (in any case VP will still render the geometry using DrawMeshInstanced).

- Generate Collider: generates a cubic collider and merges it with the chunk. This option is much faster than using a collider in the prefab but is limited to cubic shape. If you use this option, make sure your prefab doesn't contain a collider.

- Generate NavMesh: adds navigation data to the chunk for this prefab assuming a cubic shape. This option is useful to make walkable terrain for mobs using custom voxels for example.


Both GenerateCollider and GenerateNavMesh should be used when you don't need to create an actual gameobject for the prefab by using the "Create GameObject" option. Along GPU instancing, it allows you to use any kind of material and shapes while preserving the cubic-based interaction in the world.



Creation of a custom voxel:




Example of Door creation:



Custom voxel with LOD and material override option:





Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article