• Advertisement
Sign in to follow this  

Meshloader split vertices for materials

This topic is 1586 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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 ???

Edited by StanIAm

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

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 ??

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement