Skip to content

Commit 8c45822

Browse files
committed
Improve materials
- alpha cutoff should now be done automatically - support unshaded faces (only Hyogamon)
1 parent 01fa038 commit 8c45822

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/GLTF.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ template<> TexCoord myMax(TexCoord& a, TexCoord& b)
157157
void GLTFExporter::buildAssetEntry()
158158
{
159159
model.asset.version = "2.0";
160-
model.asset.generator = "DW1ModelConverter v1.0";
160+
model.asset.generator = "DW1ModelConverter v1.1";
161161
}
162162

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

375375
mat.doubleSided = mode.isDoubleSided;
376376
if (!mode.hasTranslucency)
377-
mat.alphaMode = "OPAQUE";
377+
{
378+
mat.alphaMode = "MASK";
379+
mat.alphaCutoff = 0.1f;
380+
}
378381
else
379382
{
380383
tinygltf::Value::Object extras;
381384
extras.emplace("blendMode", std::to_string(mode.mixtureRate));
382385
mat.extras = tinygltf::Value(extras);
383386
mat.alphaMode = "BLEND";
384387
}
388+
389+
if(mode.type == MaterialType::NO_LIGHT)
390+
{
391+
tinygltf::Value unlit;
392+
mat.extensions["KHR_materials_unlit"] = unlit;
393+
}
385394

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

0 commit comments

Comments
 (0)