Skip to content

Module: SVO Voxelizer

ninlilizi edited this page Apr 6, 2020 · 16 revisions

Usage

Instantiation

// Instantiate SVO Tree
SVO = ScriptableObject.CreateInstance<NKLI.Nigiri.SVO.Tree>();
SVO.Create(attached_camera, max_depth, max_nodes, mipmap_queue_length);

// Instantiate voxelizer
voxelizer = new NKLI.Nigiri.SVO.Voxelizer(SVO, emmissive_intensity, shadow_strength, occlusion_gain, gi_area_world_size);

Destruction

// Dispose voxelizer
voxelizer.Dispose();

// Destroy SVO
NKLI.Nigiri.Helpers.DestroyScriptableObject(ref SVO);

Voxelize scene

// Update voxelization parameters
voxelizer.UpdateParameters(emmissive_intensity, shadow_strength, occlusion_gain);

// Voxelize scene
voxelizer.VoxelizeScene(_sample_count, position_texture, lighting_texture, lighting_texture2, mask_buffer);

// Split nodes
voxelizer.SplitNodes();

Variables

attached_camera - Main camera
max_depth - Default max depth of the tree
max_nodes - Maximum nodes to store [Calculate VRAM as: (max_nodes * 16)Bytes]
mipmap_queue_length - Starting size of mipmap queue [Recommend: RenderTex(width * height)]
emmissive_intensity - Emissive lighting intensity
shadow_strength - Strength of shadows
occlusion_gain - Ambiant occlusion gain
gi_area_world_size - World space axis length of GI area

API

Properties (Read-Only)

NKLI.Nigiri.SVO.Tree.MaxDepth - Default, max tree depth
NKLI.Nigiri.SVO.Tree.RAM_Usage - Estimation of allocated RAM
NKLI.Nigiri.SVO.Tree.VRAM_Usage - Estimation of allocated VRAM
NKLI.Nigiri.SVO.Tree.Runtime_Thread_Split - Execution time of node split worker thread
NKLI.Nigiri.SVO.Tree.Runtime_Thread_Mipmap - Execution time of node mipmap worker thread
NKLI.Nigiri.SVO.Tree.Buffer_SVO_ByteLength - Byte length of SVO buffer
NKLI.Nigiri.SVO.Tree.SplitQueueMaxLength - Current size of split queue buffer
NKLI.Nigiri.SVO.Tree.MipmapQueueMaxLength - Current size of the mipmap queue buffer
NKLI.Nigiri.SVO.Tree.SplitQueueSparseCount - Number of node splits waiting to be processed
NKLI.Nigiri.SVO.Tree.MipmapQueueSparseCount - Number of mipmaps waiting to be processed
NKLI.Nigiri.SVO.Tree.AbleToSplit - Are there nodes waiting to be processed?
NKLI.Nigiri.SVO.Tree.AbleToMipmap - Are there mipmaps waiting to be processed?

Required files

C#

Scripts/NKLI.Nigiri.SVO.cs
Scripts/NKLI.Nigiri.SVO.Helpers.cs
Scripts/NKLI.Nigiri.SVO.SVONode.cs
Scripts/NKLI.Nigiri.SVO.Voxelizer.cs
Scripts/NKLI.Nigiri.Helpers.cs
Scripts/NKLI.Nigiri.Tools.MainThreadDispatcher.cs

Shaders

Resources/NKLI_Nigiri_SVOVoxelizer.compute
Resources/NKLI_Nigiri_SVOVoxelizer_Functions.cginc
Resources/NKLI_Nigiri_SVOSplitter.compute
Resources/NKLI_Nigiri_SVOMipmapper.compute
Resources/NKLI_Nigiri_SVONode.cginc
Resources/NKLI_Nigiri_MortonOrder2D.cginc

Clone this wiki locally