Add support for importing material emissive and roughness from fbx file

#2153
This commit is contained in:
Wojtek Figat
2024-02-23 17:46:27 +01:00
parent a72d20e3ca
commit 01d123b099
7 changed files with 91 additions and 76 deletions

View File

@@ -622,9 +622,21 @@ bool MaterialSlotEntry::UsesProperties() const
Emissive.TextureIndex != -1 ||
!Math::IsOne(Opacity.Value) ||
Opacity.TextureIndex != -1 ||
Math::NotNearEqual(Roughness.Value, 0.5f) ||
Roughness.TextureIndex != -1 ||
Normals.TextureIndex != -1;
}
float MaterialSlotEntry::ShininessToRoughness(float shininess)
{
// https://github.com/assimp/assimp/issues/4573
const float a = -1.0f;
const float b = 2.0f;
const float c = (shininess / 100) - 1;
const float d = b * b - (4 * a * c);
return (-b + Math::Sqrt(d)) / (2 * a);
}
ModelLodData::~ModelLodData()
{
Meshes.ClearDelete();

View File

@@ -356,6 +356,12 @@ struct FLAXENGINE_API MaterialSlotEntry
int32 TextureIndex = -1;
} Opacity;
struct
{
float Value = 0.5f;
int32 TextureIndex = -1;
} Roughness;
struct
{
int32 TextureIndex = -1;
@@ -364,6 +370,7 @@ struct FLAXENGINE_API MaterialSlotEntry
bool TwoSided = false;
bool UsesProperties() const;
static float ShininessToRoughness(float shininess);
};
/// <summary>