Sign in to follow this  
biohaz

component based objects, render lists, material systems, batching how to combine?

Recommended Posts

I didn’t know if game programming, or graphics or direct x forum was best, but since this question spans them all, I guess game programming would be the best. This isnt a question on what these things are, but how to combine them together. Ok, here is the issue I have been contemplating (been busy, so progress is really slow). Anyways, I have an object created, say I request a “fountain” object. The fountain contains a render component for a model. Say upon instancing, it instances a geometry class that deals with meshes and knows how to render them. Now, I want to render the screen so I go down the hierarchy of the scenegraph (in a component) and it determines that it is visible (relative to the world). Ok, easy enough call that geometry class to render and it should render. Now I want to add in another Fountain, relative to another object
World -> fountain 1
      ->house -> fountain 2
Now, how can these be batched if I have to render with the position. Do I just store the position temporarily when checking if it is visible and then can batch, or should it be done another way? Now throw in a material system and how do you batch with that? Perhaps I am going about the render wrong. Currently I am designing a base geometry class (with a virtual render() function) and then I can derive TriStrip/TriList and Meshes from that. Then they are registered to the render manager (which really just checks to see if the object is visible). -> So, basically how do you include a flexable format system (knows how to deal with different formats of geometry data – mesh, tristrip, ect) with a material system (for reflections, render to texture, ect), a scenegraph and batching in a hierarchy within a manager type class? Thanks a ton – gotta get a format that seems like it will work well, and I seem to have run out of ideas at the moment. Hopefully the question makes sense.. its late.

Share this post


Link to post
Share on other sites
Short answer (as in google it), event managers. Every thing in your game/engine fires of an event, witch is read by an event manager, then sent to the proper subsystem (even listener). As I said google it, or buy Game Coding Complete second edition, witch will explain everything about event managers witch is exactly what you need :)

Share this post


Link to post
Share on other sites
Quote:
Now, how can these be batched if I have to render with the position. Do I just store the position temporarily when checking if it is visible and then can batch, or should it be done another way? Now throw in a material system and how do you batch with that?


I also use a component-based SG in my setup. But use a separat structure for rendering - a render queue. A visitor traverse the SG tree and collects geometry components and adds instances of that into the render queue. you could also query for a position and material component during traversal and set the transformation matrix and shader for a renderable geometry instance.

the renderqueue then sorts the instances and renders it. minizing VB and shader changes.

Share this post


Link to post
Share on other sites
So, you have a render list that stores pointers to the render components. from there, it is sorted upon geometry type, position, then material type?

Then do you have your geometry in dervied classes so they specialize in a certian type of data (tristrip/mesh/ect) and each instance has a render() to do it?

Share this post


Link to post
Share on other sites
I think the idea is that every (visible) object in the game world has a render() method, but it doesn't actually render the object; instead it adds a collection of simple renderable shapes (quads, tris, simple meshes maybe) to a render manager. This means the render manager can collect up all the things to be rendered, without needing to care about what is from which object, and render it in the most efficient order (generally sorted by shader or texture).

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