简体   繁体   English

Assimp加载排放图

[英]Assimp Loading Emission Map

I'm using Assimp to load my models and meshes which has been working great until now. 我正在使用Assimp加载我的模型和网格,这些模型和网格到目前为止一直很好用。 I'm trying to load an emission map from a .mtl file generated when I export a .obj file from blender. 我正在尝试从我从blender导出.obj文件时生成的.mtl文件加载发射映射。 It loads the diffuse, normal and specular maps just fine, but for some reason, it doesnt seem to find the emission map in the file at all. 它加载漫反射,法线和高光贴图很好,但由于某种原因,它似乎根本找不到文件中的发射贴图。

Here is the .mtl file: 这是.mtl文件:

# Blender MTL File: 'basiclevel.blend'
# Material Count: 1

newmtl megaGem
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd Textures\gemB_diff.jpg
map_Ke Textures\gemB_emit.jpg
map_Ks Textures\gemB_spec.jpg
map_Bump Textures\gemB_norm.jpg

(I have shortened the file paths as they were long and quite unclear, the diffuse, normal and specular maps load and render just fine) (我缩短了文件路径,因为它们很长而且很不清楚,漫反射,法线和高光贴图加载并渲染得很好)

I am loading the textures like so: 我正在加载纹理,如下所示:

std::vector<glTexture> emissionTextures = loadTextures(
    material,
    aiTextureType_EMISSIVE,
    MAP_TYPE::EMISSION
);
meshTextures.insert(
    meshTextures.end(),
    emissionTextures.begin(),
    emissionTextures.end()
);
if (emissionTextures.size() > 0) {
    meshMaterial.emissionTexture = emissionTextures[0];
}

Where loadTextures() is just a function that gets the texture paths in the mtl file corresponding to the aiTextureType, and either loads them from file or gets them from the cache if they have been loaded before. 其中loadTextures()只是一个函数,它获取与aiTextureType对应的mtl文件中的纹理路径,并从文件中加载它们,或者如果之前已加载它们,则从缓存中获取它们。 Again this is working completely fine for everything except the emission textures. 除了发射纹理之外,这对于除了发射纹理之外的所有东 (Also, excuse the hacky way of checking the length of the vector and grabbing the first one, I need to figure out a nicer way of checking if textures of that type have been loaded in the future). (另外,请原谅检查向量长度和抓住第一个长度的hacky方法,我需要找出一种更好的方法来检查未来是否已加载该类型的纹理)。

I'm thinking that the aiTextureType aiTextureType_EMISSIVE maybe doesnt correspond correctly to the mtl map_Ke tag? 我认为aiTextureType aiTextureType_EMISSIVE可能与mtl map_Ke标签没有正确对应? Which would explain why my ResourceManager doesn't even attempt to load it. 这可以解释为什么我的ResourceManager甚至没有尝试加载它。

Is aiTextureType_EMISSIVE the correct thing I should be checking here? aiTextureType_EMISSIVE是否应该在这里检查? If not, how should I be checking for emission maps in my obj files corresponding material file? 如果没有,我应该如何在我的obj文件中检查相应材料文件中的发射图?

It is a known bug of assimp ( https://github.com/assimp/assimp/issues/804 ) that was resolved. 已经解决了这个已知的assimp错误( https://github.com/assimp/assimp/issues/804 )。 But if you're like me and have an older version, the map_Ke tag isn't mapped to aiTextureType_EMISSIVE . 但是,如果您像我一样并且版本较旧,则map_Ke标记不会映射到aiTextureType_EMISSIVE The solution is to instead use the keyword map_emissive in your .mtl file that assimp recognises for emissive texture (in earlier version, it handles both keywords) 解决方案是在.mtl文件中使用关键字map_emissive ,assimp识别自发光纹理(在早期版本中,它处理两个关键字)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM