From 4175198d045674b6f5a62600a0e7d188403cebfa Mon Sep 17 00:00:00 2001 From: Filip Lundgren <45687559+ifiddynine@users.noreply.github.com> Date: Sat, 26 Mar 2022 22:33:10 +0100 Subject: [PATCH] Detect Roughness factor exported by Blender Matches the logic used by Blender's own FBX exporter / importer. --- code/AssetLib/FBX/FBXConverter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index 32872108b..d446fd2e9 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -2161,6 +2161,9 @@ void FBXConverter::SetShadingPropertiesCommon(aiMaterial *out_mat, const Propert const float ShininessExponent = PropertyGet(props, "ShininessExponent", ok); if (ok) { out_mat->AddProperty(&ShininessExponent, 1, AI_MATKEY_SHININESS); + // Match Blender behavior to extract roughness when only shininess is present + const float roughness = 1.0 - (sqrt(ShininessExponent) / 10.0); + out_mat->AddProperty(&roughness, 1, AI_MATKEY_ROUGHNESS_FACTOR); } // TransparentColor / TransparencyFactor... gee thanks FBX :rolleyes: