From 8b7b95e39e8b05f367905e85a0ebc17082d38464 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Molteni Date: Wed, 12 Jun 2024 15:04:27 -0300 Subject: [PATCH] feat: PiXYZ culling (#136) --- .github/workflows/test-lod-conversion.yml | 4 ++-- DCL_PiXYZ/PXZClient.cs | 1 + .../PXZRemoveHiddenPartOccurences.cs | 20 +++++++++++++++++++ DCL_PiXYZ/Utils/PXZEntryArgs.cs | 4 ++-- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 DCL_PiXYZ/PiXYZWorflow/PXZRemoveHiddenPartOccurences.cs diff --git a/.github/workflows/test-lod-conversion.yml b/.github/workflows/test-lod-conversion.yml index 5aaf7604..abe07e80 100644 --- a/.github/workflows/test-lod-conversion.yml +++ b/.github/workflows/test-lod-conversion.yml @@ -14,10 +14,10 @@ jobs: include: - lodLevelsToTest: ["500", "3"] files: "QmTpsFiaJVPv5mU6ERBzkDcZ39Lyq9sEfiLw9Ep3VQAFgK_3.fbx" - sizes: "1880064" + sizes: "1413120" - lodLevelsToTest: ["7000;3000;1000;500", "0"] files: "QmTpsFiaJVPv5mU6ERBzkDcZ39Lyq9sEfiLw9Ep3VQAFgK_0.fbx QmTpsFiaJVPv5mU6ERBzkDcZ39Lyq9sEfiLw9Ep3VQAFgK_1.fbx QmTpsFiaJVPv5mU6ERBzkDcZ39Lyq9sEfiLw9Ep3VQAFgK_2.fbx QmTpsFiaJVPv5mU6ERBzkDcZ39Lyq9sEfiLw9Ep3VQAFgK_3.fbx" - sizes: "48934912 7024640 2895872 1880064" + sizes: "48934912 2572288 1708032 1413120" steps: - uses: actions/checkout@v2 diff --git a/DCL_PiXYZ/PXZClient.cs b/DCL_PiXYZ/PXZClient.cs index 9aae985f..ece84936 100644 --- a/DCL_PiXYZ/PXZClient.cs +++ b/DCL_PiXYZ/PXZClient.cs @@ -207,6 +207,7 @@ private async Task ConvertScene(PXZConversionParams pxzParams, SceneConversionPa if (pxzParams.LodLevel != 0) { modifiers.Add(new PXZDeleteByName(".*collider.*")); + modifiers.Add(new PXZRemoveHiddenPartOccurrences()); modifiers.Add(new PXZDecimator(sceneConversionInfo.SceneImporter.GetSceneBasePointer(), pxzParams.DecimationType, pxzParams.DecimationValue, pxzParams.ParcelAmount, pathHandler)); modifiers.Add(new PXZMergeMeshes(pxzParams.LodLevel)); diff --git a/DCL_PiXYZ/PiXYZWorflow/PXZRemoveHiddenPartOccurences.cs b/DCL_PiXYZ/PiXYZWorflow/PXZRemoveHiddenPartOccurences.cs new file mode 100644 index 00000000..a62584c9 --- /dev/null +++ b/DCL_PiXYZ/PiXYZWorflow/PXZRemoveHiddenPartOccurences.cs @@ -0,0 +1,20 @@ +using UnityEngine.Pixyz.API; +using UnityEngine.Pixyz.Scene; + +namespace DCL_PiXYZ +{ + public class PXZRemoveHiddenPartOccurrences : IPXZModifier + { + public void ApplyModification(PiXYZAPI pxz) + { + pxz.Core.SetModuleProperty("Algo", "DisableGPUAlgorithms", "True"); + //We use low quality settings, since this modifier is used only for far away lods. + //For more info, check https://www.pixyz-software.com/documentations/html/2024.2/sdk/manual/functions/deleteoccluded.html?q=Occluded + OccurrenceList hiddenOccurrences = pxz.Algo.FindOccludedPartOccurrences(new OccurrenceList(new uint[] + { + pxz.Scene.GetRoot() + }), 256, 2, 30, true); + pxz.Scene.DeleteOccurrences(hiddenOccurrences); + } + } +} \ No newline at end of file diff --git a/DCL_PiXYZ/Utils/PXZEntryArgs.cs b/DCL_PiXYZ/Utils/PXZEntryArgs.cs index b3e60ea0..957b385b 100644 --- a/DCL_PiXYZ/Utils/PXZEntryArgs.cs +++ b/DCL_PiXYZ/Utils/PXZEntryArgs.cs @@ -11,7 +11,7 @@ public PXZEntryArgs() DefaultSceneLodManifestDirectory = Path.Combine(Directory.GetCurrentDirectory(), "scene-lod-entities-manifest-builder/"); } - [Option("sceneToConvert", Required = false, Default = "0,0", HelpText = "The scene coordinate to convert")] + [Option("sceneToConvert", Required = false, Default = "5,19", HelpText = "The scene coordinate to convert")] public string SceneToConvert { get; set; } [Option("defaultOutputPath", Required = false, HelpText = "Output path for all files (LODs and Downloads)")] @@ -20,7 +20,7 @@ public PXZEntryArgs() [Option("defaultSceneLodManifestDirectory", Required = false, HelpText = "Path to the manifest project")] public string DefaultSceneLodManifestDirectory { get; set; } - [Option("decimationValues", Required = false, Default = "7000", HelpText = "Triangle max count per lod level. Separate each leavel by a ;") ] + [Option("decimationValues", Required = false, Default = "7000;500", HelpText = "Triangle max count per lod level. Separate each leavel by a ;") ] public string DecimationValues { get; set; } [Option("startingLODLevel", Required = false, Default = 0, HelpText = "Starting LOD level to generate. Modifiers depend on this value") ]