Sign in to follow this  
StanIAm

Meshloader split vertices for materials

Recommended Posts

StanIAm    208

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
StanIAm    208

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
Zaoshi Kaba    8434

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
StanIAm    208

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this