public static void TestSVOCompaction() { NaiveCreator creator = new NaiveCreator(); List <int> nodes = new List <int>(); List <uint> attachments = new List <uint>(); Node root = new Node(new Vector3(1, 1, 1), 1, 1, false); creator.BuildTree(root, 1, SampleFunctions.functions[(int)SampleFunctions.Type.Sphere], 3); creator.CompressSVO(root, nodes, attachments); string output = "NaiveCreator SVO Compaction Test\n"; output += "Original Hierarchy:\n" + root.StringifyHierarchy() + "\n\n"; output += "Compressed:\n"; for (int i = 0; i < nodes.Count; i++) { int normal = (int)(attachments[i * 2 + 1] >> 16); output += "CD: " + new ChildDescriptor(nodes[i]) + ", Normal: v" + Vector3.Normalize(NaiveCreator.decodeRawNormal16(normal)) + ", " + Convert.ToString(normal, 2).PadLeft(16, '0') + "(" + normal + ")\n"; } Debug.Log(output); }
void UpdateMasterOctree() { RT.CS.NaiveCreator creator = new RT.CS.NaiveCreator(); RT.CS.Node sOctree = octree.ExtractSparseOctree(); int sphereIndex = 10000; RT.SVOData data = creator.Create(sOctree, x => sphereIndex); raytracingMaster.SetSVOBuffer(data); Debug.Log("Num child descriptors: " + data.childDescriptors.Count); string log = "SVO Trunk: \n"; log += "Compressed:\n" + string.Join("\n", data.childDescriptors.ConvertAll(code => new RT.CS.ChildDescriptor(code))) + "\n\n"; string path = Application.dataPath + "/trunkSVO.log"; System.IO.File.WriteAllText(path, log); RT.SVOData sphereData = creator.Create(SampleFunctions.functions[1], 4); raytracingMaster.SetSVOBuffer(sphereData, sphereIndex); }
private void SetSVOBuffer() { Debug.Log("Setting svo buffer..."); RT.CS.NaiveCreator creator = new RT.CS.NaiveCreator(); RT.SVOData data = creator.Create(SampleFunctions.functions[(int)sampleType], maxLevel); _svoBuffer = new ComputeBuffer(data.childDescriptors.Count, 4); _svoAttachmentsBuffer = new ComputeBuffer(data.attachments.Count, 4); // Print SVO /* string output = "\n"; * for(int i = 0; i < data.childDescriptors.Count; i++) { * int normal = (int)(data.attachments[i*2 + 1] >> 16); * output += "CD: " + new RT.CS.ChildDescriptor(data.childDescriptors[i]) + "\n"; //, Normal: v" + Vector3.Normalize(RT.CS.NaiveCreator.decodeRawNormal16(normal)) + System.Convert.ToString(normal, 2).PadLeft(16, '0') + "(" + normal + ")\n"; * } * * GUIUtility.systemCopyBuffer = output;*/ _svoBuffer.SetData(data.childDescriptors); _svoAttachmentsBuffer.SetData(data.attachments); }