Taking sponza as a test scene
heitaoflower opened this issue · 18 comments
Hi, I recently try to load sponza scene as my test scene.
The scene file consists of two types of media, one is obj mesh file, the other one are images.
however, right now, the iqm tool chain not parser the mtl or usemtl to recognize material texture as the resource id later on.
so in my eyes, I should add some features that support mtl parser for obj format files. because only under this way, we probably gain texture id use you iqm loader.
If necessray I can upload scene files for you.
Please share some idea with me, just cope it once for all.
The only supported model format at the moment is IQM, which is a pretty bare-bones format containing only the vertex data and some material/texture ID/names. If you want to load the sponza scene, I would recommend loading it into blender, and setting the material of each mesh to the texture name.
For example, if a wall is using tex_wall_diffuse.png, you would give it a material with that name, and use the IQM expoter plugin to export the model with material names, and then make sure you store your textures in the texture folder of the engine/game data.
I agree that it's not an ideal solution, but its a pretty compact way to include meta-data like that directly in the model file. An alternative would be to do it in-engine via configs and such, or perhaps even some external level editor that allows you to load a model and apply textures to it/export it with that data.
Thanks for your reply.
For now, I am focusing on add material feature into iqm.
Actually my initial thoughts were to add an extra loader and parser in your iqm module, however, this way will kindly kill the idea and break the original rules of IQM.
so I would like to do some modification with it.
-
Add a new struct of materiallib in which hold a host of material which will be referenced by mesh material idx.
-
Add a new struct of material which defines some normal or common vars, like map_kd something like that, you know that.
-
Add new member field material_lib into a struct of mesh, this will help this mesh to locate accurate material library later.
how do you think about this modification?
look forward to your reply.
I'm not sure I entirely understand to be honest, perhaps just do whatever you want with your fork and I can take a look at that before we do any pull request stuff.
Here is the modification commite log =>
heitaoflower/iqm@2a4032a
for now, only support obj format mesh which is reference external material config info.
I could able to make some minor changes after tomorrow, and organize the code.
Those changes appear to be for the example C++ IQM loader, right?
I will push later on. by the way, I wonder if you can recommend me some tools to utilize lives at ##oodnet/freenode, the way of the web is not very convenient indeed.
You'll need an IRC client for your OS, or use https://webchat.freenode.net/ and join the channel ##oodnet
By the way , I have upload the latest asset of sponza to the master branch .
heitaoflower@7b897ed .
besides above, would you share the original scene file with me?
Unity uses Z as the up-axis, I think. You'll probably just need to rotate your models -90 degrees on the X axis before exporting to fix it, or make the iqm loader swap Y and Z.
Actually, I had tested the iqm demo with the batman mesh file, It is correct, in other words, the presentation is identical with LearnOpenDemo or another demo.
What is the unique when rendering mesh in our engine, could make an educated guess ? are there any juicy details I neglected?
I think you are right, I found a snippet code as below.
epositions.add(Vec4(vkey.attrib[0] < 0 ? Vec3(0, 0, 0) : attrib[0][vkey.attrib[0]].zxy(), 1));
if (vkey.attrib[2] >= 0) enormals.add(attrib[2][vkey.attrib[2]].zxy());
the order of vertex data in iqm was zxy!!
but I have no idea why the author write like this way?
Vec3 zxy() const { return Vec3(z, x, y); }
Vec3 zyx() const { return Vec3(z, y, x); }
Vec3 yxz() const { return Vec3(y, x, z); }
Vec3 yzx() const { return Vec3(y, z, x); }
Vec3 xzy() const { return Vec3(x, z, y); }
Likely due to a lot of the big engines like Unity using Z as their up-axis. It's easy to fix though, either rotate -90 degrees on the X axis before exporting your model, or just swap the Y and Z when you load the model.