Skip to content

Commit

Permalink
Improve materials
Browse files Browse the repository at this point in the history
- alpha cutoff should now be done automatically
- support unshaded faces (only Hyogamon)
  • Loading branch information
SydMontague committed Oct 7, 2023
1 parent 01fa038 commit 8c45822
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/GLTF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ template<> TexCoord myMax(TexCoord& a, TexCoord& b)
void GLTFExporter::buildAssetEntry()
{
model.asset.version = "2.0";
model.asset.generator = "DW1ModelConverter v1.0";
model.asset.generator = "DW1ModelConverter v1.1";
}

std::size_t GLTFExporter::buildPrimitiveVertex(Mesh& mesh, std::vector<Face> faces)
Expand Down Expand Up @@ -374,14 +374,23 @@ int32_t GLTFExporter::buildMaterial(MaterialMode mode)

mat.doubleSided = mode.isDoubleSided;
if (!mode.hasTranslucency)
mat.alphaMode = "OPAQUE";
{
mat.alphaMode = "MASK";
mat.alphaCutoff = 0.1f;
}
else
{
tinygltf::Value::Object extras;
extras.emplace("blendMode", std::to_string(mode.mixtureRate));
mat.extras = tinygltf::Value(extras);
mat.alphaMode = "BLEND";
}

if(mode.type == MaterialType::NO_LIGHT)
{
tinygltf::Value unlit;
mat.extensions["KHR_materials_unlit"] = unlit;
}

mat.pbrMetallicRoughness.baseColorFactor = { 1.0f, 1.0f, 1.0f, 1.0f };
if (mode.type != MaterialType::COLOR) mat.pbrMetallicRoughness.baseColorTexture.index = 0;
Expand Down

0 comments on commit 8c45822

Please sign in to comment.