0
\$\begingroup\$

I've imported Blender FBX models in to UE4 before, so I'm aware that some of the material information is saved in the model. How do I go about accessing this in MonoGame?

To be clear, I don't specifically mean textures. I mean the materials that then refer to a given set of textures (colour, normal, etc).

I'm currently parsing the same texture to the HLSL shader for the entire model, however I want to be able to change which texture is parsed based on the material information (or parse all textures to the shader and have it choose, I'm not sure)

EDIT: it would seem this information is saved in the FBX as "LayerElementMaterial"

LayerElementMaterial: 0 {
        Version: 101
        Name: ""
        MappingInformationType: "ByPolygon"
        ReferenceInformationType: "IndexToDirect"
        Materials: 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
                   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,
                   3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
                   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
                   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,
                   2,2,2,2,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
                   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
                   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
                   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,1,1,1,1,

The question still stands, is this information accessible at runtime?

\$\endgroup\$
  • \$\begingroup\$ Most games don't load FBX files at runtime. The FBX file is read at import or build time, then packed into a leaner binary file that better matches the memory/GPU layout the data will have at runtime, and that packed file is what gets included in the built game. This makes loading assets at runtime faster, and the game code smaller since it has to do less file parsing. But it does mean that information gets discarded unless you've extracted it in that pre-process step. Something like that may be going on here. But your runtime model may still be in multiple submesh parts, one per material. \$\endgroup\$ – DMGregory Jan 24 at 12:57
0
\$\begingroup\$

It would seem the only way to do this is to have the vertex colours correspond to a particular material (which wouldn't work as materials are set per face not per vertex) or completely re-write the FBX importer to take materials into account

As far as I can tell it's otherwise impossible

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.