assimp-net icon indicating copy to clipboard operation
assimp-net copied to clipboard

Is there a EmbededTexture property from which I can get the texture image reference ?

Open citystrawman opened this issue 5 years ago • 2 comments

have an issue when I tried to read texture image information using AssimpNet.

The fbx file that I tried to read has 10 embedded textures and has no external textures: texture screenshot

according to the information from assimp, the embedded textures are referenced from materials using strings like "*0", "*1" as the texture paths.

However, among the 12 materials in my fbx file, some them have texture paths like "..\buildings.fbm\6M4P000O.JPG" which corresponds to the image file name

As for the first scenario which has strings like "*0", "*1", I can find corresponding texture by using the number as the reference to Textures, but for the second scenario, I could not find the corresponding file name from Textures because in AssimpNet, the EmbeddedTexture has no such property

But according to assimp, which is the base of assimpnet, from its texture.h file, I found that it has a property called mFilename and from this property we could get the texture's image file name; assimp texture.h

I am wondering if AssimpNet should include filename into EmbededTexture properties so that we could find the correct reference if the filepath contains the filename rather than number.

citystrawman avatar Jul 15 '19 09:07 citystrawman

I am currently running into this issue as well since .GLB's embed the textures im having a hard time understanding how to associate a texture to a mesh material. The meshIndex will be 0 or 1 and all the file names are *0 *1 its very confusing.

Edit:

So i have been looking at this for a bit over the last few days. It appears though mind you im working thru this at the moment myself that asterick filename *0 ect actually represents or points to the Textures[0] indexs.

Using the method on the material equates to the same index.
var texdata = scene.GetEmbeddedTexture(tfilename); Were the tfilename is the *0 or *1 ect filename.

I have been running tests to verify behavior. I will post pics as well later on for clarity further down.

// some console output directly at the time when the texture is loaded.

      MaterialTextureIndex 0  Type Diffuse  fileName: *0   Compressed Texture Saved to File LOADED....
      MaterialTextureIndex 1  Type Diffuse  fileName: *0   Compressed Texture Saved to File LOADED....
      MaterialTextureIndex 4  Type Emissive  fileName: *3   Compressed Texture Saved to File LOADED....
      MaterialTextureIndex 6  Type Normals  fileName: *2   Compressed Texture Saved to File LOADED....
      MaterialTextureIndex 8  Type Lightmap  fileName: *1   Compressed Texture Saved to File LOADED....
      MaterialTextureIndex 10  Type Unknown  fileName: *1   Compressed Texture Saved to File LOADED....

This particular model has one mesh and here you can see the output for the model itself on the mesh. The console output separately displays the material for that mesh and what textures have non null maps (actually loaded to the model) and how they correspond to the previously outputed indexs loaded and shown.

Particularly note the loaded maps for this mesh material.

__________________________
scene.Meshes[0] meshes_1.meshes_4.meshes_3.meshes_2.meshes_0
 FaceCount: 15914
 VertexCount: 10244
 Normals.Count: 10244
 Bones.Count: 0
 MaterialIndex: 0

 MorphMethod: None
 HasMeshAnimationAttachments: False
 UVComponentCount.Length: 8
   mesh.UVComponentCount[0] : int value: 2
 TextureCoordinateChannels.Length:8
 TextureCoordinateChannelCount:1
   mesh.TextureCoordinateChannels[0]  count 10244


    __________________________

    Loaded maps for this mesh.

    textureDiffuse *0
    textureEmissiveMap *3
    textureLightMap *1
    textureNormalMap *2
    textureUnknown *1

__________________________

    Materials scene.MaterialCount 1



    __________________________
    Material[0]
    Material[0].Name default
    GetAllMaterialTextures Length 12


    Material[0]   IsPBRMaterial False  PBR Assimp.Material+PBRMaterialProperties  PropertyCount 60
    Material[0]   PBR.HasTextureBaseColor False  PBR.HasTextureEmissionColor False  PBR.HasTextureMetalness False
    Material[0]   PBR.HasTextureNormalCamera False  PBR.HasTextureRoughness False
    Material[0]   HasColorDiffuse True  HasColorAmbient False  HasColorSpecular False
    Material[0]   HasColorReflective False  HasColorEmissive True  HasColorTransparent False
    Material[0]   ColorAmbient:{R:0.2 G:0.2 B:0.2 A:1}  ColorDiffuse: {R:1 G:1 B:1 A:1}  ColorSpecular: {R:0 G:0 B:0 A:1}
    Material[0]   ColorReflective:{R:0 G:0 B:0 A:1}  ColorEmissive: {R:0 G:0 B:0 A:1}  ColorTransparent: {R:0 G:0 B:0 A:1}
    Material[0]   HasTransparencyFactor: False  TransparencyFactor: 0  HasOpacity: False  Opacity: 1  HasShininess:True  Shininess:0  HasReflectivity: False  Reflectivity 0
    Material[0]   HasTwoSided: True  IsTwoSided: False  HasBlendMode:False  BlendMode:Default  HasShadingMode: False  ShadingMode:None  HasBumpScaling: False
    Material[0]   HasTextureDiffuse True  HasTextureAmbient False  HasTextureAmbientOcclusion False  HasTextureSpecular False
    Material[0]   HasTextureNormal True  HasTextureHeight False  HasTextureDisplacement:False  HasTextureLightMap True
    Material[0]   HasTextureReflection:False  HasTextureOpacity False  HasTextureEmissive:True

    Material[0].TextureSlot[0]   TextureIndex: 0  Type: Diffuse  Operation: Multiply  Flags: 0  Mapping: FromUV  Blendfactor: 0   Filepath: *0
    Material[0].TextureSlot[1]   TextureIndex: 1  Type: Diffuse  Operation: Multiply  Flags: 0  Mapping: FromUV  Blendfactor: 0   Filepath: *0
    Material[0].TextureSlot[2]   TextureIndex: 0  Type: None  Operation: Multiply  Flags: 0  Mapping: FromUV  Blendfactor: 0   Filepath:
    Material[0].TextureSlot[3]   TextureIndex: 0  Type: None  Operation: Multiply  Flags: 0  Mapping: FromUV  Blendfactor: 0   Filepath:
    Material[0].TextureSlot[4]   TextureIndex: 0  Type: Emissive  Operation: Multiply  Flags: 0  Mapping: FromUV  Blendfactor: 0   Filepath: *3
    Material[0].TextureSlot[5]   TextureIndex: 0  Type: None  Operation: Multiply  Flags: 0  Mapping: FromUV  Blendfactor: 0   Filepath:
    Material[0].TextureSlot[6]   TextureIndex: 0  Type: Normals  Operation: Multiply  Flags: 0  Mapping: FromUV  Blendfactor: 0   Filepath: *2
    Material[0].TextureSlot[7]   TextureIndex: 0  Type: None  Operation: Multiply  Flags: 0  Mapping: FromUV  Blendfactor: 0   Filepath:
    Material[0].TextureSlot[8]   TextureIndex: 0  Type: Lightmap  Operation: Multiply  Flags: 0  Mapping: FromUV  Blendfactor: 0   Filepath: *1
    Material[0].TextureSlot[9]   TextureIndex: 0  Type: None  Operation: Multiply  Flags: 0  Mapping: FromUV  Blendfactor: 0   Filepath:
    Material[0].TextureSlot[10]   TextureIndex: 0  Type: Unknown  Operation: Multiply  Flags: 0  Mapping: FromUV  Blendfactor: 0   Filepath: *1
    Material[0].TextureSlot[11]   TextureIndex: 0  Type: None  Operation: Multiply  Flags: 0  Mapping: FromUV  Blendfactor: 0   Filepath:

Conclusions from this test appear to show that there is some ambiguity in what is happening here.

More then one diffuse texture is typically listed for a material loaded. However the same diffuse texture is actually pulled in (index 0) twice to the same texture. Aka there is a redundant load.

Also the texture index *1 is also loaded twice and placed into two separate textures. The Lightmap texture and the Unknown texture.

The emissive map appears to just be a bump or normal map.

    __________________________

    Loaded maps for this mesh.

    textureDiffuse *0
    textureEmissiveMap *3
    textureLightMap *1
    textureNormalMap *2
    textureUnknown *1

AssimpTextureLoadingOutput

One other note this is a .glb file and even ones that say they are pbr never seem to denote the pbr property bool true in the material at least i haven't found one yet.

willmotil avatar Mar 19 '20 02:03 willmotil

This issue is fixed in the 5.0 version of assimp, where a FilePath property does exist on EmbeddedTextures and TextureSlots always contain the filepath instead of a *-path.

Still, for those using this version, has there been a workaround for this?

ComradeVanti avatar Oct 30 '20 06:10 ComradeVanti