Best approach for Direct3D...
Hi all,
I''m working on a 3D engine for a RPG.
The game map is cell based, each cell can be one of a different number of 3D models.
The question is, which is the most efficient way to handle this for the Direct3D API ?
I currently have 1 vertex buffer per cell which is within the "stage" area. The "stage" is the area of cells which are visible from the current viewpoint. Meshes of the respective models (from a model library) are copied into the stage cell vertex buffer as they come onto the stage. Models consist mostly of 1 texture each, and about 1000-1500 vertices each. The vertex buffer is in video RAM. This means that at any time there are around 170-200 vertex buffers, a selection of which could contain the same mesh geometry.
I have to do some per model effects such as materials and lighting, and you have to bear in mind that the same model in different cells could have different properties.
So at present, I have to make several RenderState changes per model, and also 1 separate call to the API to render each model. The total number of models which make up a scene would be around 170.
I would also like to take advantage of HW T&L.
Does anyone have any suggestions on how this could be done better, or more efficiently ? I would really like to get the frame rate up again !!
Any ideas would be much appreciated
Andrew
For each frame to render, scan which cells are going to be visible and build a list of polygons by material. Render each material group in succession. This is the only way I know to keep the state changes to the absolute minimum.
Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
Yep, generally the best plan.
You can improve on it with some "temporal coherence" knowledge though - if your game isn''t updating everything every frame, things like the lists Jim describes can be left calculated until they actually change, same for things like dynamic buffers etc.
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
You can improve on it with some "temporal coherence" knowledge though - if your game isn''t updating everything every frame, things like the lists Jim describes can be left calculated until they actually change, same for things like dynamic buffers etc.
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Thanks for those replies
The problem I see is that since each model is in it''s own vertex buffer, there needs to still be 1 Render call per cell, no matter if I build a sorted vertex list by material or not.. is this normal, or should I aim for fewer render calls ?
Agreed, if I build a sorted vertex list by material then this will keep the renderstate changes down, but I did actually start off doing this, with all models in 2 or 3 large vertex buffers, instead of 170 separate ones. This then required 1 Render call per texture basically. The performance was not as good as making 170 Render calls (1 per model) without the sorting. I suppose the overhead of doing all the sorting etc dragged it down..
I''ll play with it a bit more... it has to be more efficient to render in a texture/material sorted fashion..
Thanks again
Andrew
The problem I see is that since each model is in it''s own vertex buffer, there needs to still be 1 Render call per cell, no matter if I build a sorted vertex list by material or not.. is this normal, or should I aim for fewer render calls ?
Agreed, if I build a sorted vertex list by material then this will keep the renderstate changes down, but I did actually start off doing this, with all models in 2 or 3 large vertex buffers, instead of 170 separate ones. This then required 1 Render call per texture basically. The performance was not as good as making 170 Render calls (1 per model) without the sorting. I suppose the overhead of doing all the sorting etc dragged it down..
I''ll play with it a bit more... it has to be more efficient to render in a texture/material sorted fashion..
Thanks again
Andrew
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement