Skip to content

Commit

Permalink
Merge pull request #78621 from RevoluPowered/add-emission-strength-su…
Browse files Browse the repository at this point in the history
…pport-to-gltf

Add support for GLTF extension KHR_materials_emissive_strength
  • Loading branch information
YuriSizov committed Jul 12, 2023
2 parents 55b74c7 + 83f2fce commit e185934
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/gltf/gltf_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3808,6 +3808,13 @@ Error GLTFDocument::_parse_materials(Ref<GLTFState> p_state) {
material->set_shading_mode(BaseMaterial3D::SHADING_MODE_UNSHADED);
}

if (pbr_spec_gloss_extensions.has("KHR_materials_emissive_strength")) {
Dictionary emissive_strength = pbr_spec_gloss_extensions["KHR_materials_emissive_strength"];
if (emissive_strength.has("emissiveStrength")) {
material->set_emission_energy_multiplier(emissive_strength["emissiveStrength"]);
}
}

if (pbr_spec_gloss_extensions.has("KHR_materials_pbrSpecularGlossiness")) {
WARN_PRINT("Material uses a specular and glossiness workflow. Textures will be converted to roughness and metallic workflow, which may not be 100% accurate.");
Dictionary sgm = pbr_spec_gloss_extensions["KHR_materials_pbrSpecularGlossiness"];
Expand Down Expand Up @@ -7461,6 +7468,7 @@ Error GLTFDocument::_parse_gltf_extensions(Ref<GLTFState> p_state) {
supported_extensions.insert("KHR_materials_pbrSpecularGlossiness");
supported_extensions.insert("KHR_texture_transform");
supported_extensions.insert("KHR_materials_unlit");
supported_extensions.insert("KHR_materials_emissive_strength");
for (Ref<GLTFDocumentExtension> ext : document_extensions) {
ERR_CONTINUE(ext.is_null());
Vector<String> ext_supported_extensions = ext->get_supported_extensions();
Expand Down

0 comments on commit e185934

Please sign in to comment.