Meshloader split vertices for materials

Started by
3 comments, last by StanIAm 10 years, 5 months ago

Hey guys I have a question. I wrote a little meshloader which reads a vertices and indices array from a file and put it directly to the ID3D11Buffer objects which works veery fast ( 500k vertices in about 0.8s) , but without materials.

Well now Im on implementing the material loading stuff and have a problem. When I load a mesh with multiple materials ( for example the sponza model -> I merged all meshes into one mesh with multiple materials) I have a big vertices and indices array. Now I should have a list for every meshpart ( from the big vertices and indices array) with its material infos.So I have to have for every meshpart a startindex number and the number of indices it has, so I can set its material ( shader and textures in direct3D) and render only the indices from startindex - numindices.

Well the problem is now that I use assimp to convert normal 3d objct files to my own format and can't separate or split the mesh into the infos for startindex and numindex for each meshpart with its material.

I don't know if it is possible but I need that for the materials. I can imagine that there is somewhere saved the index fields for each material ??

How can I solve that problem ?

Advertisement

Assimp doesn't join meshes if they have different materials, they'll have separate indices and vertices, you just need to gather them into single buffer.

No I mean I mereged the meshes in Cinema4D to one mesh with multiple materials. Now I have only one mesh when I load it but II cant find out where to start and end rendering with which material.

Are there other libs which can handle that `?

How does the other do that ? I mean when you need more than one texture per mesh ???

They use multiple meshes: ex. house doors, walls, windows, roof are drawn with separate draw calls and texture is changed in between.

If you want to draw it with single call you'll have to merge texture into one (I think that's called texture atlas).

I tried to load these meshes ( I think about 390) into 390 vertex and index buffers so you have the possibility to assign your material per mesh but that was extremly slow ( with 730 Buffers it is understandable..)... How do you do that `? Do you save 2D arrays for vertices and indices ?? then you have per mesh an array of vertices.. and change the buffers memory for each mesh and then draw it ??

This topic is closed to new replies.

Advertisement