Recuding calls to Draw(Indexed)Primitive

Started by
3 comments, last by Plerion 14 years, 1 month ago
Hey there Im facing some problems with rendering complex objects in my scene. Those objects are built from several textureunits. Lets say we have an average of 10 units per model. As in a single scene there may be up to 100 models this results in up to 1000 calls to DrawIndexPrimitive (they all are ID3DXMesh). As you can imagine this is pretty bad for the FPS. Does anyone of you know an algorithm or something to reduce this huge amount of calls? Greetings
Advertisement
Well, the only real options are:
1. Combine several textures into one larger texture
2. Cull invisible meshes
3. Sort so you draw all meshes using texture A, then all using texture B, etc.

#1 sounds simplest.
Yes, #1 sounds good as i am already doing #2 as good as possible. Is there a way to combine some textures during runtime? This is neccessary because the textures i use are already existing and i dont want to supply them all with my program.
Quote:Original post by Plerion
Yes, #1 sounds good as i am already doing #2 as good as possible. Is there a way to combine some textures during runtime? This is neccessary because the textures i use are already existing and i dont want to supply them all with my program.
What do you mean they already exist?

It's possible to do at runtime, but it's a bit of a pain to do. You'll need to:
1. Create a new large texture
2. Go through each texture the mesh uses and copy them into the larger texture
3. Lock the attribute and vertex buffer of the mesh
4. Update the texture coordinates in each vertex to correspond to the new coordinates
5. Unlock the AB and VB
It means that its an extension to an existing game and so all the textures are from this game and i cannot ship all the textures with the program (nor do i really want to).

So i think this will be the only way. But that should be possible i guess. I will start implementing that.

This topic is closed to new replies.

Advertisement