Sign in to follow this  

Scene graph design w/ multiple cameras

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

I want to use the same scene graph to render a scene from multiple angles, using different Camera objects (which are passed in as an argument in the scene's Render function). The camera object contains projection & view matrices and a viewport. This is all great, until I get to the visiblity culling portion of my design. I plan on having a "SpatialNode" which would contain a pointer to a list of ALL entities in the level. When the scene graph is updated (the Update() function is called on every node), the SpatialNode will determine which entities in the level are visible, and store those in a seperate linked list. Then, on every call to Render(Camera*) and Pick(Camera*), only the visible entities will be rendered or picked. This will work fine with one camera, but if I want to render the main scene, and then a smaller inset scene from a different viewpoint, the lists of visible entities will change. I would have to call Update() multiple times for each camera (possibly even prior to every Render() and Pick() call), but I would like to only call it once per camera. Any thoughts? Feel free to ask me to clarify anything. Thanks! - Mike

Share this post


Link to post
Share on other sites
As a quick summary:

I want to minimize the number of visilibity culling tests per frame when rendering/picking a scene from multiple angles. What are some good ways to implement this in a scene graph?

- Mike

Share this post


Link to post
Share on other sites
Do you have your camera in the scene graph as well? This is great for having cameras automatically follow object etc.

I don't understand the problem - you have a spatial node for each camera (probably connected to the camera, as it will need to know the view volume for culling), and you call update() on each of these once per frame. This equates one spatial node update() per camera per frame, whis is what you want?

One thing though; you will want to update your spatial nodes last; otherwise your culling will be out of sync, if movement occurs in the update() of the other nodes.

Share this post


Link to post
Share on other sites
Quote:
Original post by doctorsixstring

I want to minimize the number of visilibity culling tests per frame when rendering/picking a scene from multiple angles. What are some good ways to implement this in a scene graph?

- Mike


You mentioned that the visibility changes with the camera location/orientation. To minimize the number of visibility culling tests for multiple angles, it is sufficient to minimize the number of visibility culling tests for a single angle. The scene exists in the world independently of where you place the camera, so you want to make certain that your SpatialNode world bounding volumes are updated *once*, regardless of how many camera you have. Then do the drawing multiple times. A hierarchical organization of SpatialNodes should be designed to cull out entire subtrees--this is where you minimize the visibility testing (node is culled, no reason to attempt culling its children).

Share this post


Link to post
Share on other sites
Quote:
Original post by Brian Sandberg
Do you have your camera in the scene graph as well? This is great for having cameras automatically follow object etc.

I don't understand the problem - you have a spatial node for each camera (probably connected to the camera, as it will need to know the view volume for culling), and you call update() on each of these once per frame. This equates one spatial node update() per camera per frame, whis is what you want?


Actually, no. My current design has no camera nodes. Each call to Render() or Pick() would take a pointer to a Camera object as an argument. This camera is then used when traversing the scene graph.

My problem is that I want multiple cameras viewing the exact same scene. I would rather keep my scene graph as simple as possible and not introduce multiple parents (i.e. the spatial node has multiple parents, each being a camera).

I definitely see the advantage of using a camera node which would then be attached to an entity in the level (specifically the player's ship). However, my current design has ALL entities (mobile ships, planets, missiles, etc.) stored in an octree, which is referenced by the SpatialNode. This includes the player's ship entity. How should I attach the camera to the player's ship in this case? Should the player's ship not be stored in the SpatialTree?

Quote:
Original post by Brian Sandberg
One thing though; you will want to update your spatial nodes last; otherwise your culling will be out of sync, if movement occurs in the update() of the other nodes.


Good point - I'll make sure I follow this.

Share this post


Link to post
Share on other sites
My problem is not really one of coding or concepts - I already have those down. My problem is more of a software-engineering problem (maybe the thread should be moved to that forum?).

I could make things easy and just update the list of visible entities every time Render() or Pick() is called. However, wouldn't this lead to excessive visibility tests when I process screen picking?

Thanks for the replies so far!

- Mike

Share this post


Link to post
Share on other sites
Isn't the issue that what you call a SpatialNode really shouldn't be an independent node, but a part of the camera? The way I see it, it contains information about what is visible to a specific camera.

What do you store in your scene graph? (which normally IS a tree; no need for multiple parents or cycles) Do you have transformation nodes, which was what I was referring to when talking about attaching the camera to an object; the camera would then have the same parent transformation as the object. If you want the camera to move around the object (but still follow it), just insert an extra transformation node.

Share this post


Link to post
Share on other sites
Quote:
Original post by Brian Sandberg
What do you store in your scene graph?


My current scene graph is pretty simple, and is just as you describe. I have the Scene class which stores a tree of SceneNodes. The SceneNode class is an interface for TransformNodes and GeometryNodes. I also have SkyNodes (for storing a skybox/skysphere) and LightNodes (which aren't really implemented, yet).

I could just skip this problem, for now, and perform a visibility test for each call to Scene->Render() and Scene->Pick(). Since there will only be one call to Render() for each camera, and the Pick() function will probably only be called once every few seconds (whenever the player clicks on the screen), this may not be a bad option.

- Mike

Share this post


Link to post
Share on other sites

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