From 89f4e716794e9a1cf105af6e4f5a0f7ec373afc4 Mon Sep 17 00:00:00 2001 From: Dmitriy Romanov Date: Wed, 28 Mar 2018 18:54:33 +0300 Subject: Fix Collada material roughness import function Fixes NaN roughness in Godot when hardness in Blender is set to more than 255. Also corrects dependency: more hardness = more roughness (it says shininess, but it actually is hardness). --- editor/import/editor_import_collada.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 863b13cbd7..89db0191ee 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -480,7 +480,7 @@ Error ColladaImport::_create_material(const String &p_target) { } } - float roughness = Math::sqrt(1.0 - ((Math::log(effect.shininess) / Math::log(2.0)) / 8.0)); //not very right.. + float roughness = - Math::sqrt(1.0 - ((Math::log(effect.shininess) / Math::log(2.0)) / 9.0)) + 1; material->set_roughness(roughness); if (effect.double_sided) { -- cgit v1.2.3 From 3b29e85257d68b5ce4834aa756a5d1fc62dd82c7 Mon Sep 17 00:00:00 2001 From: Dmitriy Romanov Date: Thu, 29 Mar 2018 12:47:24 +0300 Subject: Fix Collada material roughness import function 2 Fix minus space. --- editor/import/editor_import_collada.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 89db0191ee..2a2fd4ef8a 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -480,7 +480,7 @@ Error ColladaImport::_create_material(const String &p_target) { } } - float roughness = - Math::sqrt(1.0 - ((Math::log(effect.shininess) / Math::log(2.0)) / 9.0)) + 1; + float roughness = -Math::sqrt(1.0 - ((Math::log(effect.shininess) / Math::log(2.0)) / 9.0)) + 1; material->set_roughness(roughness); if (effect.double_sided) { -- cgit v1.2.3 From 0e844f6c91dfc421c573c6ab784e2a96903413e3 Mon Sep 17 00:00:00 2001 From: Dmitriy Romanov Date: Sat, 31 Mar 2018 12:50:03 +0300 Subject: Fix Collada material roughness import function 3 Improved readability and further tweaking of function --- editor/import/editor_import_collada.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 2a2fd4ef8a..282da239cc 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -480,7 +480,7 @@ Error ColladaImport::_create_material(const String &p_target) { } } - float roughness = -Math::sqrt(1.0 - ((Math::log(effect.shininess) / Math::log(2.0)) / 9.0)) + 1; + float roughness = (512.0 * (1.0 - Math::sqrt(1.0 - ((Math::log(effect.shininess) / Math::log(2.0)) / 9.0)))) / 503.0; material->set_roughness(roughness); if (effect.double_sided) { -- cgit v1.2.3 From 0812468d0508f04a3890054774668391b27759a4 Mon Sep 17 00:00:00 2001 From: Dmitriy Romanov Date: Tue, 3 Apr 2018 22:05:13 +0300 Subject: Fix Collada material roughness import function 4 Made import conversion linear. --- editor/import/editor_import_collada.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 282da239cc..c1e897a04c 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -480,7 +480,7 @@ Error ColladaImport::_create_material(const String &p_target) { } } - float roughness = (512.0 * (1.0 - Math::sqrt(1.0 - ((Math::log(effect.shininess) / Math::log(2.0)) / 9.0)))) / 503.0; + float roughness = (effect.shininess - 1.0) / 510; material->set_roughness(roughness); if (effect.double_sided) { -- cgit v1.2.3