Jump to content

  • Log In with Google      Sign In   
  • Create Account


Most efficient way of rendering huge levels?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 gchewood   Members   -  Reputation: 236

Like
0Likes
Like

Posted 22 January 2013 - 01:02 PM

Simple question. Is there any difference in efficiency between rendering a scene (in XNA) of different 100 models as

 

1) 100 different "Model" objects.

2) 100 different meshes within 1 Model object?

 

Thanks in advance.



Sponsor:

#2 TiagoCosta   Crossbones+   -  Reputation: 1879

Like
0Likes
Like

Posted 22 January 2013 - 05:24 PM

It depends on what the models are and where they're positioned, etc

 

100 different "Model" objects should be faster because some of them might not be visible so there's no point in binding vertices and indices of meshes that won't be drawn.

 

If all models are really close (example a car in which all pieces are a different model) then they should probably be stored in a single model because they'll most likely be drawn all together so you just have to bind the vertex and index buffer once.

 

If some of the meshes also use the same material and are close to each other merge them in a single mesh so they're drawn in a single draw call.

 

PS: I'm assuming that the vertices/indices of all meshes inside a model are stored in the same vertex/index buffer (I don't have much experience with XNA).


Tiago Costa
Aqua Engine - my DirectX 11 game "engine" - In development

#3 quiSHADgho   Members   -  Reputation: 325

Like
0Likes
Like

Posted 22 January 2013 - 05:43 PM

I agree with Tiago. Since you are referring to a "huge" level I suppose there is lot of space between the objects. When you are rendering each object independent from the other you can cull them before the render call to save gpu power and also sort them so you can avoid overdraw.

Additionally if you have many instances of one model try to use hardware instancing to save draw calls and state changes.

And yes meshparts share their vertex and indexbuffer in XNA unless they are getting to big.



#4 L. Spiro   Crossbones+   -  Reputation: 12325

Like
3Likes
Like

Posted 22 January 2013 - 06:28 PM

The 2 options you provide are not really related much to the final performance you will get.  Either way you will still need many draw calls each time you have to change materials, textures, shaders, etc.

 

Efficient rendering is a higher-level process and very involved.  You need to keep updated AABB’s for each object and use them for frustum culling, which can be further improved via an oct-tree.

Once you have a list of things you want to draw you need to sort them by shader, texture, and possibly depth in order to reduce the number of redundant state changes.

Then render them in sorted order.  Of course that does no good if you don’t also have a system in place for eliminating redundant state changes.  That is if the same shader is set twice in a row, the second time should be a do-nothing call.

 

If you are really worried about performance, be prepared to put in a lot of effort.

Good luck!  smile.png

 

 

L. Spiro


Edited by L. Spiro, 22 January 2013 - 06:29 PM.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#5 gchewood   Members   -  Reputation: 236

Like
0Likes
Like

Posted 26 January 2013 - 01:26 PM

Sorry, I should've been clearer in explaining that all of the models would be visible at once. I was thinking about grass billboards at the time.
Hardware instancing would probably be the best solution, now I think of it. It's just easier for level-editing if you can group them into bunches of
50 (for example) billboards along a flat plane and then copy and paste to cover the map. I know it's probably better to do grass procedurally,
so I might consider that instead.

Efficient rendering is a higher-level process and very involved. You need to keep updated AABB’s for each object and use them for frustum culling, which can be further improved via an oct-tree.

Once you have a list of things you want to draw you need to sort them by shader, texture, and possibly depth in order to reduce the number of redundant state changes.

Then render them in sorted order. Of course that does no good if you don’t also have a system in place for eliminating redundant state changes. That is if the same shader is set twice in a row, the second time should be a do-nothing call.


Yeah I realised the majority of my work is ahead of me. Was just focusing on this specific problem first.

Thanks for the info people.

Edited by gchewood, 26 January 2013 - 01:34 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS