Sign in to follow this  

Game architecture question.

This topic is 4105 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

Hello, I'm facing a problem right now with the way I handle my objects for the rendering. Basicaly here is what I'm doing for static objects : I have a collection of objects. An object for me is just a collection of Vertex and Indices, with properties (Texture, render states, ...). An object can be very "huge" and contains thousand of vertices. But also be quite tiny. At the creation of the "Big static vertex/index buffer" : I sort the various object by Texture, states, ... and then I will sent their data to the Vertex/index Big buffer. Then after I do this to render all the objects :
foreach Object in ObjectCollection
{
     if (Object.Status == PreviousObject.Status) 
     {
        Increment in a variable the number of vertex to render at once
     }else{
        // The status of the current object is diff from the previous one --> call a Draw
        Set the various corresponding object States (Textures, states, ...)
        Draw indexed primitive following the Incremented variables (that keep a trace of the number of vertex to draw at once)
     }
}



It's mainly something like this. The problem I have is that as soon as the number of object grow up, the cpu time needed to do the (Object.Status == PreviousObject.Status) raise a lot (30% of the time spend on a scene rendering). How do you managed this comparaison ? I have created a specific structure to store the object states. Something like this :
struct ObjectStates{
    public int TextureID;
    public int MaterialID;
    public int RenderState1;
    public int RenderState2;
    ...
    public boolean IsEqualTo(ObjectStates Object2Compare){
         if (this.TextureID != Object2Compare.CompareTextureID) return false;
         if (this.MaterialID!= Object2Compare.MaterialID) return false;
         if (this.RenderState1!= Object2Compare.RenderState1) return false;
         If ...
         return true;
    }
}



How would you handle this object state comparaison without making the CPU performances go down ? Tx ou for your help !

Share this post


Link to post
Share on other sites
Don't worry about performance hits on simple comparisions like that. What slows the program down is rendering and complex mathematical calculations, like those used for physics engines. Computers these days are blazingly fast.....

Share this post


Link to post
Share on other sites
Quote:
Original post by Rob Loach
Don't worry about performance hits on simple comparisions like that. What slows the program down is rendering and complex mathematical calculations, like those used for physics engines. Computers these days are blazingly fast.....


The wise man speaks wisely.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The processing of sorting/filtering assets for better rendering efficiency (to prevent repeated render state changes and texture stream changes) is usually insignificant as compared to the losses by slower rendering.

If you havent considered it, you might use a LOD (level of detail) scheme that draws a simplified version of a complex object the further away it is (so as to not have the overhead of drawing detail that is too small to see).

Likewise a frustum filter to eliminate all the scenery and object outside of the view (as a presetp to other culling methods...)

Share this post


Link to post
Share on other sites
Tx you for your help !

I was wondering, in general how many different visible "objects" are you able to managed at the same time ?

In fact I'm working on cards rendering system, are are the result up to now :

description of your image

description of your image

You will see that I was crazy : I was considering every letter from the text as an independant object. After 5 cards I already had 1.000 scene objects ... :D
After grouping them into one scene Object, the result are really better ! :D
The big difficult part as been the text rendering system that will automaticaly fit to the containing defined triangle and the possibility the add symbol in the text itself ! :)

Tx you !

Share this post


Link to post
Share on other sites

This topic is 4105 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.

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