Updates to KHR_materials_unlit

This commit is contained in:
Robert Long 2018-01-18 18:34:10 -08:00
parent e742f066c2
commit 782862a4d5
2 changed files with 25 additions and 5 deletions

View File

@ -852,6 +852,9 @@ ModelData *Raw2Gltf(
diffuseTex.get(), diffuseFactor, specGlossTex.get(), specularFactor, glossiness));
}
TextureData *normalTexture = simpleTex(RAW_TEXTURE_USAGE_NORMAL).get();
TextureData *emissiveTexture = simpleTex(RAW_TEXTURE_USAGE_EMISSIVE).get();
std::shared_ptr<KHRCommonMats> khrComMat;
if (options.useKHRMatCom) {
float shininess;
@ -908,16 +911,33 @@ ModelData *Raw2Gltf(
std::shared_ptr<KHRCmnConstantMaterial> khrCmnConstantMat;
if (options.useKHRMatCmnConstant) {
khrCmnConstantMat.reset(new KHRCmnConstantMaterial());
normalTexture = nullptr;
// Set fallback parameters
pbrMetRough.reset(new PBRMetallicRoughness(nullptr, Vec4f(0.0f, 0.0f, 0.0f, 1.0f), 0.0f, 0.0f));
emissiveTexture = nullptr;
emissiveFactor = Vec3f(0.00f, 0.00f, 0.00f);
Vec4f diffuseFactor;
std::shared_ptr<TextureData> baseColorTex;
if (material.info->shadingModel == RAW_SHADING_MODEL_PBR_MET_ROUGH) {
RawMetRoughMatProps *props = (RawMetRoughMatProps *) material.info.get();
diffuseFactor = props->diffuseFactor;
baseColorTex = simpleTex(RAW_TEXTURE_USAGE_ALBEDO);
} else {
RawTraditionalMatProps *props = ((RawTraditionalMatProps *) material.info.get());
diffuseFactor = props->diffuseFactor;
baseColorTex = simpleTex(RAW_TEXTURE_USAGE_DIFFUSE);
}
pbrMetRough.reset(new PBRMetallicRoughness(baseColorTex.get(), nullptr, diffuseFactor, 0.0f, 1.0f));
khrCmnConstantMat.reset(new KHRCmnConstantMaterial());
}
std::shared_ptr<MaterialData> mData = gltf->materials.hold(
new MaterialData(
material.name, isTransparent,
simpleTex(RAW_TEXTURE_USAGE_NORMAL).get(), simpleTex(RAW_TEXTURE_USAGE_EMISSIVE).get(),
normalTexture, emissiveTexture,
emissiveFactor * emissiveIntensity,
khrComMat, khrCmnConstantMat, pbrMetRough, pbrSpecGloss));
materialsByName[materialHash(material)] = mData;

View File

@ -30,7 +30,7 @@ using json = nlohmann::basic_json<workaround_fifo_map>;
static const std::string KHR_DRACO_MESH_COMPRESSION = "KHR_draco_mesh_compression";
static const std::string KHR_MATERIALS_COMMON = "KHR_materials_common";
static const std::string KHR_MATERIALS_CMN_CONSTANT = "KHR_materials_cmnConstant";
static const std::string KHR_MATERIALS_CMN_CONSTANT = "KHR_materials_unlit";
static const std::string KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS = "KHR_materials_pbrSpecularGlossiness";
static const std::string extBufferFilename = "buffer.bin";