mirror of
https://github.com/open-goal/jak-project
synced 2026-07-07 22:22:21 -04:00
custom models: better error for invalid envmap material (#3784)
When a material in Blender has its IOR level changed to anything other than the default value of 0.5, the `KHR_materials_specular` extension is applied during the glTF export, which is what we use to check for envmaps in custom models. If an envmap is undesired, but the IOR value was accidentally changed, the program would assert during model processing if there is no metallic roughness texture attached to the material. Since this is an easy mistake to make and is hard to spot, this adds a better error message for such cases.
This commit is contained in:
@@ -680,6 +680,28 @@ EnvmapSettings envmap_settings_from_gltf(const tinygltf::Material& mat) {
|
||||
return settings;
|
||||
}
|
||||
|
||||
bool material_has_envmap(const tinygltf::Material& mat) {
|
||||
return mat.extensions.contains("KHR_materials_specular");
|
||||
}
|
||||
|
||||
bool envmap_is_valid(const tinygltf::Material& mat, bool die) {
|
||||
if (material_has_envmap(mat) && mat.pbrMetallicRoughness.metallicRoughnessTexture.index < 0) {
|
||||
std::string error = fmt::format(
|
||||
"Material \"{}\" has specular property set, but is missing a metallic roughness texture! "
|
||||
"Check "
|
||||
"that the Specular IOR level for the material is at the default of 0.5 if this is "
|
||||
"unintended.",
|
||||
mat.name);
|
||||
if (die) {
|
||||
lg::die(error);
|
||||
} else {
|
||||
lg::error(error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<int> find_single_skin(const tinygltf::Model& model,
|
||||
const std::vector<NodeWithTransform>& all_nodes) {
|
||||
std::optional<int> skin_index;
|
||||
|
||||
Reference in New Issue
Block a user