Register renderables every frame?

Started by
14 comments, last by PAndersson 11 years, 9 months ago
What are you registering/deregistering items with? Is this equivalent to adding objects to a "will be rendered" list?

I rebuild my "objects to be rendered" list from scratch every frame, and throw it away at the end of the frame. There's no longstanding registration/link between renderable objects and the renderer.

Culling/collecting 2000 renderables, updating their state, sorting them on multiple conditions, and then executing the D3D commands required to draw them, takes about half a millisecond...
Advertisement

Only moving objects will register and unregister with the quad- or oc- tree, and this is done every frame, but insertion should be instantaneous, and the same quad- or oc- tree can be used for multiple subsystems, from graphics to collision detection.
I guess that's implementation-dependent. The physics API I use does not allow that natively. Just pointing out.

Previously "Krohm"

There is no physics API able to return a list of visible items? O_O

Peace and love, now I understand really what it means! Guardian Angels exist! Thanks!


In the past, I've used std::multimap to sort things by their material, where materials consist of a pair of shaders, and a list of textures.

For a small game, the multimap solution (with a predicate based on the shader ID and then the texture ID's ) is plenty fast.


There's no longstanding registration/link between renderable objects and the renderer.


There is a better way this can be done which takes advantage of temporal coherence.
In my system, objects register just the information needed for sorting to a render queue (this part is standard in every rendering system). The objects will often register this data in the same order every frame since I am walking the octree (etc.) the same way every time.

This data is not sorted directly.
The render queue class responsible for sorting this data instead sorts indices into this data.
This improves sort bandwidth since I am only copying 32-bit values instead of structures, but it also allows temporal coherence.

The indices are not cleared every frame. If more objects appear, the indices for those objects are added to the end of the otherwise sorted indices.
If there are fewer objects, the indices are reset back to 0 1 2 3, etc.
And if the number of objects is the same the indices are left as-is.

Then an insertion sort is done over the indices.
In most cases the indices will already be in sorted order or at least very close, so this system outperforms quick sort and merge sort in virtually all situations.


This basically provides a way to submit objects to the render queue in any order, and as long as that order is mostly consistent then you can take advantage of temporal coherence.

I also keep multiple render queues. One for each shadow-casting light (shadow maps), one for opaque objects in the main render, one for alpha objects in the main render, etc.



There is no physics API able to return a list of visible items? O_O

Just because spatial partitioning schemes can be used to accelerate rendering does not mean that is all they can do.
In fact the actual system is completely unrelated and disconnected to/from rendering. When you “query” an octree for a list of objects within some kind of bounding area, the octree has no idea why you are asking for that list or what you intend to do with it. If you intend to use it as “a list of things in view” then fine. If you intend to use it as “a list of things that could potentially be in contact with a given object” then fine.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

The thing is, adding and removing stuff to a list is not that big a deal, buy you are asking the wrong question, the right question is:

Is performing visivility tests from each object more efficient than from a bigger container that has them?
So thats where it gets tricky, you have to do both, the big containers will perform more wide spectrum tests, like is camera on room A, then send room A to render and not the rest.
Then the stuff within the room must be tested against the camera frustrum, its really more efficient to give the frusturm a list and have it test all those objects than the other way around, plus its very hard for an object to test its own occlusion, in the end, you'll probably conclude that its GENERALLY the best way to go to test from bigger containers than from each object at a time.
Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272



What are you registering/deregistering items with? Is this equivalent to adding objects to a "will be rendered" list?

I rebuild my "objects to be rendered" list from scratch every frame, and throw it away at the end of the frame. There's no longstanding registration/link between renderable objects and the renderer.

Culling/collecting 2000 renderables, updating their state, sorting them on multiple conditions, and then executing the D3D commands required to draw them, takes about half a millisecond...


This is exactly what I meant, and since I most likely will use less than 2000 different objects I doubt my implementation will perform worse. Visibility culling of entire can be done by the registration stage, ie by storing them in a quad/oct-tree and only requsting objects in visible cells to register.

This topic is closed to new replies.

Advertisement