TSpace setting for MikkT tangent generation (#2386)
* Added TSpace method setting which is only visible for MikkT generation. * Fixed a bug with generating tangents for blend shapes. * Renamed tangent space into generation method. * Some code cleaning Signed-off-by: Benjamin Jillich <jillich@amazon.com>
This commit is contained in:
@@ -26,13 +26,22 @@ namespace AZ
|
||||
{
|
||||
TangentsRule::TangentsRule()
|
||||
: DataTypes::IRule()
|
||||
, m_tangentSpace(AZ::SceneAPI::DataTypes::TangentSpace::MikkT)
|
||||
{
|
||||
}
|
||||
|
||||
AZ::SceneAPI::DataTypes::TangentSpace TangentsRule::GetTangentSpace() const
|
||||
AZ::SceneAPI::DataTypes::TangentGenerationMethod TangentsRule::GetGenerationMethod() const
|
||||
{
|
||||
return m_tangentSpace;
|
||||
return m_generationMethod;
|
||||
}
|
||||
|
||||
AZ::SceneAPI::DataTypes::MikkTSpaceMethod TangentsRule::GetMikkTSpaceMethod() const
|
||||
{
|
||||
return m_tSpaceMethod;
|
||||
}
|
||||
|
||||
AZ::Crc32 TangentsRule::GetSpaceMethodVisibility() const
|
||||
{
|
||||
return (m_generationMethod == AZ::SceneAPI::DataTypes::TangentGenerationMethod::MikkT) ? AZ::Edit::PropertyVisibility::Show : AZ::Edit::PropertyVisibility::Hide;
|
||||
}
|
||||
|
||||
void TangentsRule::Reflect(AZ::ReflectContext* context)
|
||||
@@ -43,20 +52,29 @@ namespace AZ
|
||||
return;
|
||||
}
|
||||
|
||||
serializeContext->Class<TangentsRule, DataTypes::IRule>()->Version(3)
|
||||
->Field("tangentSpace", &TangentsRule::m_tangentSpace);
|
||||
serializeContext->Class<TangentsRule, DataTypes::IRule>()->Version(4)
|
||||
->Field("tangentSpace", &TangentsRule::m_generationMethod)
|
||||
->Field("tSpaceMethod", &TangentsRule::m_tSpaceMethod);
|
||||
|
||||
AZ::EditContext* editContext = serializeContext->GetEditContext();
|
||||
if (editContext)
|
||||
{
|
||||
editContext->Class<TangentsRule>("Tangents", "Specify how tangents are imported or generated.")
|
||||
->ClassElement(Edit::ClassElements::EditorData, "")
|
||||
->Attribute("AutoExpand", true)
|
||||
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
|
||||
->DataElement(AZ::Edit::UIHandlers::ComboBox, &AZ::SceneAPI::SceneData::TangentsRule::m_tangentSpace, "Tangent space", "Specify the tangent space used for normal map baking. Choose 'From Fbx' to extract the tangents and bitangents directly from the Fbx file. When there is no tangents rule or the Fbx has no tangents stored inside it, the 'MikkT' option will be used with orthogonal tangents of unit length, so with the normalize option enabled, using the first UV set.")
|
||||
->EnumAttribute(AZ::SceneAPI::DataTypes::TangentSpace::FromSourceScene, "From Source Scene")
|
||||
->EnumAttribute(AZ::SceneAPI::DataTypes::TangentSpace::MikkT, "MikkT")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
|
||||
->Attribute("AutoExpand", true)
|
||||
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
|
||||
->DataElement(AZ::Edit::UIHandlers::ComboBox, &AZ::SceneAPI::SceneData::TangentsRule::m_generationMethod, "Generation Method", "Specify the tangent generation method. Choose 'From Source Scene' to extract the tangents and bitangents directly from the source scene file. When there is no tangents rule or the source scene has no tangents stored inside it, the 'MikkT' option will be used.")
|
||||
->EnumAttribute(AZ::SceneAPI::DataTypes::TangentGenerationMethod::FromSourceScene, "From Source Scene")
|
||||
->EnumAttribute(AZ::SceneAPI::DataTypes::TangentGenerationMethod::MikkT, "MikkT")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
|
||||
->DataElement(AZ::Edit::UIHandlers::ComboBox, &AZ::SceneAPI::SceneData::TangentsRule::m_tSpaceMethod, "TSpace Method",
|
||||
"TSpace generates the tangents and bitangents with their true magnitudes which can be used for relief mapping effects. "
|
||||
" It calculates the 'real' bitangent which may not be perpendicular to the tangent. "
|
||||
"However, both, the tangent and bitangent are perpendicular to the vertex normal. "
|
||||
"TSpaceBasic calculates unit vector tangents and bitangents at pixel/vertex level which are sufficient for basic normal mapping.")
|
||||
->EnumAttribute(AZ::SceneAPI::DataTypes::MikkTSpaceMethod::TSpace, "TSpace")
|
||||
->EnumAttribute(AZ::SceneAPI::DataTypes::MikkTSpaceMethod::TSpaceBasic, "TSpaceBasic")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, &TangentsRule::GetSpaceMethodVisibility);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,12 +45,17 @@ namespace AZ
|
||||
SCENE_DATA_API TangentsRule();
|
||||
SCENE_DATA_API ~TangentsRule() override = default;
|
||||
|
||||
SCENE_DATA_API AZ::SceneAPI::DataTypes::TangentSpace GetTangentSpace() const;
|
||||
SCENE_DATA_API AZ::SceneAPI::DataTypes::TangentGenerationMethod GetGenerationMethod() const;
|
||||
SCENE_DATA_API AZ::SceneAPI::DataTypes::MikkTSpaceMethod GetMikkTSpaceMethod() const;
|
||||
|
||||
static void Reflect(ReflectContext* context);
|
||||
|
||||
protected:
|
||||
AZ::SceneAPI::DataTypes::TangentSpace m_tangentSpace; /**< Specifies how to handle tangents. Either generate them, or import them. */
|
||||
AZ::SceneAPI::DataTypes::TangentGenerationMethod m_generationMethod = AZ::SceneAPI::DataTypes::TangentGenerationMethod::MikkT; /**< Specifies how to handle tangents. Either generate them, or import them. */
|
||||
|
||||
// MikkT specific settings
|
||||
AZ::Crc32 GetSpaceMethodVisibility() const;
|
||||
AZ::SceneAPI::DataTypes::MikkTSpaceMethod m_tSpaceMethod = AZ::SceneAPI::DataTypes::MikkTSpaceMethod::TSpace;
|
||||
};
|
||||
} // SceneData
|
||||
} // SceneAPI
|
||||
|
||||
Reference in New Issue
Block a user