diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2024-04-13 11:30:31 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-04-13 11:30:31 +0200 |
| commit | 8e1b50045ad2a991ef8826b7b178ce15b6f25221 (patch) | |
| tree | a4a6e55bd69f1dc058617caf4e73a98d1ae38b30 /modules | |
| parent | 6d5981aad7bbfa5d52213e5bd29c822b939a4f9f (diff) | |
| parent | 659597b29064c683aa5fd790fd2064a0a1296909 (diff) | |
| download | redot-engine-8e1b50045ad2a991ef8826b7b178ce15b6f25221.tar.gz | |
Merge pull request #90554 from bqqbarbhg/fbx-color-fixes
FBX: Fix material colors
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/fbx/fbx_document.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/modules/fbx/fbx_document.cpp b/modules/fbx/fbx_document.cpp index 1dbe4c535a..63766247ee 100644 --- a/modules/fbx/fbx_document.cpp +++ b/modules/fbx/fbx_document.cpp @@ -1080,7 +1080,7 @@ Error FBXDocument::_parse_materials(Ref<FBXState> p_state) { if (fbx_material->pbr.base_color.has_value) { Color albedo = _material_color(fbx_material->pbr.base_color, fbx_material->pbr.base_factor); - material->set_albedo(albedo); + material->set_albedo(albedo.linear_to_srgb()); } if (fbx_material->features.double_sided.enabled) { @@ -1178,7 +1178,11 @@ Error FBXDocument::_parse_materials(Ref<FBXState> p_state) { } // Combined textures and factors are very unreliable in FBX - material->set_albedo(Color(1, 1, 1)); + Color albedo_factor = Color(1, 1, 1); + if (fbx_material->pbr.base_factor.has_value) { + albedo_factor *= (float)fbx_material->pbr.base_factor.value_real; + } + material->set_albedo(albedo_factor.linear_to_srgb()); // TODO: Does not support rotation, could be inverted? material->set_uv1_offset(_as_vec3(base_texture->uv_transform.translation)); @@ -1232,11 +1236,11 @@ Error FBXDocument::_parse_materials(Ref<FBXState> p_state) { if (fbx_material->pbr.emission_color.has_value) { material->set_feature(BaseMaterial3D::FEATURE_EMISSION, true); - material->set_emission(_material_color(fbx_material->pbr.emission_color)); + material->set_emission(_material_color(fbx_material->pbr.emission_color).linear_to_srgb()); material->set_emission_energy_multiplier(float(fbx_material->pbr.emission_factor.value_real)); } - const ufbx_texture *emission_texture = _get_file_texture(fbx_material->pbr.ambient_occlusion.texture); + const ufbx_texture *emission_texture = _get_file_texture(fbx_material->pbr.emission_color.texture); if (emission_texture) { material->set_texture(BaseMaterial3D::TEXTURE_EMISSION, _get_texture(p_state, GLTFTextureIndex(emission_texture->file_index), TEXTURE_TYPE_GENERIC)); material->set_feature(BaseMaterial3D::FEATURE_EMISSION, true); @@ -1266,7 +1270,7 @@ Error FBXDocument::_parse_cameras(Ref<FBXState> p_state) { camera->set_fov(Math::deg_to_rad(real_t(fbx_camera->field_of_view_deg.y))); } else { camera->set_perspective(false); - camera->set_size_mag(real_t(fbx_camera->orthographic_size.y)); + camera->set_size_mag(real_t(fbx_camera->orthographic_size.y * 0.5f)); } if (fbx_camera->near_plane != 0.0f) { camera->set_depth_near(fbx_camera->near_plane); |
