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

Commit

Permalink
fix transparency problem if dissolve value set to 0;
Browse files Browse the repository at this point in the history
package version to 1.0.1
  • Loading branch information
Jifeng committed Dec 7, 2018
1 parent ee84f27 commit 658a67a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Obj23dTiles/Obj23dTiles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<RepositoryUrl>https://github.com/arcplus/ObjConvert</RepositoryUrl>
<Copyright>Copyright © Arcplus 2018</Copyright>
<Description>Convert wavefront obj file to 3d tiles, which can be used in cesium</Description>
<Version>1.0.1</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net45'">
Expand Down
6 changes: 3 additions & 3 deletions src/Obj2Gltf/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,10 @@ private Gltf.Material GetDefault()
{
AlphaMode = AlphaMode.OPAQUE,
Name = "default",
EmissiveFactor = new double[] { 1, 1, 1 },
//EmissiveFactor = new double[] { 1, 1, 1 },
PbrMetallicRoughness = new PbrMetallicRoughness
{
BaseColorFactor = new double[] { 1, 1, 1, 1 },
BaseColorFactor = new double[] { 0.5, 0.5, 0.5, 1 },
MetallicFactor = 0.0,
RoughnessFactor = 0.0
}
Expand All @@ -462,7 +462,7 @@ private int AddMaterial(WaveFront.Material mat)
AlphaMode = AlphaMode.OPAQUE
};
var alpha = 1.0;
if (mat.Dissolve != null)
if (mat.Dissolve != null && mat.Dissolve.Factor > 0)
{
gMat.AlphaMode = AlphaMode.BLEND;
alpha = mat.Dissolve.Factor;
Expand Down
4 changes: 2 additions & 2 deletions src/Obj2Gltf/Gltf/Material.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Material
/// The emissive color of the material.
/// </summary>
[JsonProperty("emissiveFactor")]
public double[] EmissiveFactor = new double[] { 0, 0, 0 };
public double[] EmissiveFactor { get; set; } // = new double[] { 0, 0, 0 };
/// <summary>
/// The alpha rendering mode of the material.
///
Expand Down Expand Up @@ -105,6 +105,6 @@ public class PbrMetallicRoughness
/// * A value of 1.0 means the material is completely rough.
/// * A value of 0.0 means the material is completely smooth.
[JsonProperty("roughnessFactor")]
public double RoughnessFactor { get; set; }
public double RoughnessFactor { get; set; } = 0.9;
}
}
1 change: 1 addition & 0 deletions src/Obj2Gltf/Obj2Gltf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<RepositoryUrl>https://github.com/arcplus/ObjConvert</RepositoryUrl>
<Copyright>Copyright © Arcplus 2018</Copyright>
<Description>Convert wavefront obj file to gltf/glb file</Description>
<Version>1.0.1</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net45'">
Expand Down
12 changes: 12 additions & 0 deletions src/Obj2Gltf/WaveFront/MtlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,17 @@ public void Dispose()
_reader.Close();
}
}
/// <summary>
/// Translate the blinn-phong model to the pbr metallic-roughness model
/// Roughness factor is a combination of specular intensity and shininess
/// Metallic factor is 0.0
/// Textures are not converted for now
/// </summary>
/// <param name="color"></param>
/// <returns></returns>
public static double Luminance(Color color)
{
return color.Red * 0.2125 + color.Green * 0.7154 + color.Blue * 0.0721;
}
}
}

0 comments on commit 658a67a

Please sign in to comment.