Skip to content
This repository was archived by the owner on Sep 14, 2023. It is now read-only.

Commit 658a67a

Browse files
author
Jifeng
committed
fix transparency problem if dissolve value set to 0;
package version to 1.0.1
1 parent ee84f27 commit 658a67a

5 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/Obj23dTiles/Obj23dTiles.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<RepositoryUrl>https://github.com/arcplus/ObjConvert</RepositoryUrl>
1313
<Copyright>Copyright © Arcplus 2018</Copyright>
1414
<Description>Convert wavefront obj file to 3d tiles, which can be used in cesium</Description>
15+
<Version>1.0.1</Version>
1516
</PropertyGroup>
1617

1718
<PropertyGroup Condition="'$(TargetFramework)'=='net45'">

src/Obj2Gltf/Converter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@ private Gltf.Material GetDefault()
437437
{
438438
AlphaMode = AlphaMode.OPAQUE,
439439
Name = "default",
440-
EmissiveFactor = new double[] { 1, 1, 1 },
440+
//EmissiveFactor = new double[] { 1, 1, 1 },
441441
PbrMetallicRoughness = new PbrMetallicRoughness
442442
{
443-
BaseColorFactor = new double[] { 1, 1, 1, 1 },
443+
BaseColorFactor = new double[] { 0.5, 0.5, 0.5, 1 },
444444
MetallicFactor = 0.0,
445445
RoughnessFactor = 0.0
446446
}
@@ -462,7 +462,7 @@ private int AddMaterial(WaveFront.Material mat)
462462
AlphaMode = AlphaMode.OPAQUE
463463
};
464464
var alpha = 1.0;
465-
if (mat.Dissolve != null)
465+
if (mat.Dissolve != null && mat.Dissolve.Factor > 0)
466466
{
467467
gMat.AlphaMode = AlphaMode.BLEND;
468468
alpha = mat.Dissolve.Factor;

src/Obj2Gltf/Gltf/Material.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class Material
4343
/// The emissive color of the material.
4444
/// </summary>
4545
[JsonProperty("emissiveFactor")]
46-
public double[] EmissiveFactor = new double[] { 0, 0, 0 };
46+
public double[] EmissiveFactor { get; set; } // = new double[] { 0, 0, 0 };
4747
/// <summary>
4848
/// The alpha rendering mode of the material.
4949
///
@@ -105,6 +105,6 @@ public class PbrMetallicRoughness
105105
/// * A value of 1.0 means the material is completely rough.
106106
/// * A value of 0.0 means the material is completely smooth.
107107
[JsonProperty("roughnessFactor")]
108-
public double RoughnessFactor { get; set; }
108+
public double RoughnessFactor { get; set; } = 0.9;
109109
}
110110
}

src/Obj2Gltf/Obj2Gltf.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<RepositoryUrl>https://github.com/arcplus/ObjConvert</RepositoryUrl>
1414
<Copyright>Copyright © Arcplus 2018</Copyright>
1515
<Description>Convert wavefront obj file to gltf/glb file</Description>
16+
<Version>1.0.1</Version>
1617
</PropertyGroup>
1718

1819
<PropertyGroup Condition="'$(TargetFramework)'=='net45'">

src/Obj2Gltf/WaveFront/MtlParser.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,17 @@ public void Dispose()
166166
_reader.Close();
167167
}
168168
}
169+
/// <summary>
170+
/// Translate the blinn-phong model to the pbr metallic-roughness model
171+
/// Roughness factor is a combination of specular intensity and shininess
172+
/// Metallic factor is 0.0
173+
/// Textures are not converted for now
174+
/// </summary>
175+
/// <param name="color"></param>
176+
/// <returns></returns>
177+
public static double Luminance(Color color)
178+
{
179+
return color.Red * 0.2125 + color.Green * 0.7154 + color.Blue * 0.0721;
180+
}
169181
}
170182
}

0 commit comments

Comments
 (0)