Skip to content

Commit

Permalink
Remmoved unnecessary transparency from merge meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
dalkia committed Feb 22, 2024
1 parent 2ad6b0e commit 19962e2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion DCL_PiXYZ/PXZEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private static async Task RunLODBuilder(string[] args)
string defaultOutputPath = Path.Combine(Directory.GetCurrentDirectory(), "built-lods") ;
string defaultSceneLodManifestDirectory = Path.Combine(Directory.GetCurrentDirectory(), "scene-lod-entities-manifest-builder/");

bool isDebug = false;
bool isDebug = true;

if (args.Length > 0)
{
Expand Down
2 changes: 0 additions & 2 deletions DCL_PiXYZ/PiXYZWorflow/PXZMergeMeshes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public PXZMergeMeshes(int lodLevel)
bakeOption = new BakeOption();
BakeMaps bakeMaps = new BakeMaps();
bakeMaps.diffuse = true;
bakeMaps.opacity = true;
bakeOption.bakingMethod = BakingMethod.RayOnly;
this.lodLevel = lodLevel;
bakeOption.padding = 1;
Expand Down Expand Up @@ -134,7 +133,6 @@ private void AddOcurrences(PiXYZAPI pxz, PackedTree packedTree)
MaterialList material = pxz.Scene.GetMaterialsFromSubtree(packedTreeOccurrence);
//A material will be consider transparent only if it has a single material and its name contains "FORCED_TRANSPARENT" added during the material curation
bool isTransparent = material.list.Length == 1 && pxz.Core.GetProperty(material.list[0], "Name").Contains("FORCED_TRANSPARENT");

if (isTransparent)
transparentsToMerge.AddOccurrence(packedTreeOccurrence);
else
Expand Down
50 changes: 25 additions & 25 deletions DCL_PiXYZ/SceneRepositioner/SceneBuilder/Entities/DCLGLTFMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,33 @@ public DCLGLTFMesh(string src)

public override PXZModel InstantiateMesh(PiXYZAPI pxz, string entityID, uint parent, uint material, Dictionary<string, string> contentTable, SceneConversionPathHandler pathHandler, int lodLevel)
{
if (contentTable.TryGetValue(src.ToLower(), out string modelPath))
if (!contentTable.TryGetValue(src.ToLower(), out string modelPath))
{
bool modelWorkSuccessfull = true;
try
{
ReadSettings readSettings = new ReadSettings(ValidationMode.TryFix);
var model = ModelRoot.Load(modelPath, readSettings);
foreach (var gltfMaterial in model.LogicalMaterials)
{
if (gltfMaterial.Alpha != AlphaMode.OPAQUE && !gltfMaterial.Name.Contains("FORCED_TRANSPARENT"))
gltfMaterial.Name += "FORCED_TRANSPARENT";
}
if (Path.GetExtension(modelPath).Contains("glb", StringComparison.OrdinalIgnoreCase))
model.SaveGLB(modelPath);
else
model.SaveGLTF(modelPath);
}
catch (Exception e)
Console.WriteLine($"ERROR: GLTF {src} file not found in sceneContent");
return PXYZConstants.EMPTY_MODEL;
}

bool modelWorkSuccessfull = true;
try
{
var readSettings = new ReadSettings(ValidationMode.TryFix);
var model = ModelRoot.Load(modelPath, readSettings);
foreach (var gltfMaterial in model.LogicalMaterials)
{
//PXZEntryPoint.WriteToFile($"MODEL FAILED A {modelPath} {e}", "FAILEDIMPORTMODELS.txt");
Console.WriteLine($"ERROR pre-processing GLTF material: {e}");
if (gltfMaterial.Alpha != AlphaMode.OPAQUE && !gltfMaterial.Name.Contains("FORCED_TRANSPARENT"))
gltfMaterial.Name += "FORCED_TRANSPARENT";
}

if (Path.GetExtension(modelPath).Contains("glb", StringComparison.OrdinalIgnoreCase))
model.SaveGLB(modelPath);
else
model.SaveGLTF(modelPath);
}
catch (Exception e)
{
//PXZEntryPoint.WriteToFile($"MODEL FAILED A {modelPath} {e}", "FAILEDIMPORTMODELS.txt");
Console.WriteLine($"ERROR pre-processing GLTF material: {e}");
}
try
{
ReadSettings readSettings = new ReadSettings(ValidationMode.TryFix);
Expand Down Expand Up @@ -118,12 +123,7 @@ public override PXZModel InstantiateMesh(PiXYZAPI pxz, string entityID, uint par
Console.WriteLine($"ERROR: Importing GLTF {src} failed with error {e}");
return PXYZConstants.EMPTY_MODEL;
}
}
else
{
Console.WriteLine($"ERROR: GLTF {src} file not found in sceneContent");
return PXYZConstants.EMPTY_MODEL;
}

}


Expand Down

0 comments on commit 19962e2

Please sign in to comment.