Skip to content

Instantly share code, notes, and snippets.

@MineClever
Created October 6, 2022 08:18
Show Gist options
  • Save MineClever/4349cb312e946979392467ab2190bc00 to your computer and use it in GitHub Desktop.
Save MineClever/4349cb312e946979392467ab2190bc00 to your computer and use it in GitHub Desktop.
it seems PBR material data is exported to the fbx file regardless of the warning message on the export process.
// Ref to :https://forums.autodesk.com/t5/fbx-forum/pbr-materials/td-p/7418493
FbxSurfaceMaterial* material = fbxNode.GetMaterial(materialIndex);
const FbxProperty topProp = material->FindProperty("3dsMax", false);
if (topProp.IsValid())
{
const FbxProperty props = topProp.Find("Parameters", false);
if (props.IsValid())
{
auto getTex = [&](std::string propName) -> const FbxFileTexture*
{
const FbxFileTexture* ptr = nullptr;
const FbxProperty texProp = props.Find((propName + "_map").c_str(), false);
if (texProp.IsValid())
{
const FbxProperty useProp = props.Find((propName + "_map_on").c_str(), false);
if (useProp.IsValid() && !useProp.Get<FbxBool>()) {
// skip this texture if the _on property exists *and* is explicitly false
return nullptr;
}
ptr = texProp.GetSrcObject<FbxFileTexture>();
}
return ptr;
};
const auto* albedoMap = getTex("base_color");
const auto* roughnessMap = getTex("roughness");
const auto* metalnessMap = getTex("metalness");
const auto* normalMap = getTex("bump");
const auto* emissiveMap = getTex("emit_color");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment