Skip to main content
GameDev.net gamedev.net
🔒 Locked

More than one camera?

Started by mrmrcoleman Feb 20, 2005 at 1:16 PM 8 replies 750+ views
Original Post
mrmrcoleman
mrmrcoleman
Hello. I am trying to implement a system whereby I can have more than one viewpoint of a 3d scene on the same screen at once. A good example is the little windows that you used to get in Transport Tycoon where the window show the progress of some vehicle or some such, or when you play split screen multiplayer games on the same PC. How is this achieved? Do I render one part of the screen, then move the camera and render the other? Just some basic pointers are required really! Thanks in advance for any help. Mark Coleman
Dark_Light
Dark_Light
To do this you need to render to target. This will save the scene to a texture.
In your case you would do 2 render stages one rendering to say the left side of the target texture and the other to the right. then you simply copy that texture to the back buffer and your done!

acid2
acid2
You don't need to render to texture. http://www.codesampler.com/dx9src.htm check the viewports demo. Basically, you need to render the scene taking up the whole render space first, then set the viewport to only render into where you want the other camera to render to.

Hth and sorry it's a bit brief :P
circlesoft
circlesoft
You can definetly do it either way. However, I think each is better used in different situations.

Overlayed rendering, where the world is rendered on top of the other render (ie the progress of some vehicle), can best be implemented with render targets. This is because you can render the overlay to a texture, and they render that texture to any place on the screen.

Split-screen rendering (ie multiplayer games), can best be implemented with viewports. This is because the two rendering areas aren't overlapping at all.
mrmrcoleman
mrmrcoleman
Thanks for the help guys. The application is more likely to be using 'windows' from other camera's on top of the normal graphic output, so it looks like render targets are the way forward.

Thanks again.

Mark Coleman
markr
markr
I don't know about DirectX, but I'm pretty sure you'd use the same method as you would in (for instance) openGL.

You can't render to multiple cameras at the same time, you have to render one after the other.

Set the camera parameters up for one camera (including viewport params, like clip region, possibly stencil etc). Then draw your objects.

For each other camera, just do the same thing again. If you're using z-buffering it might be necessary to clear the zbuffer in between (if the regions overlap in the accum. buffer). You'll want to reset the zbuffer params anyway seeing as the different views may want different params.

If you use stencil buffering (if indeed, that's what it's called in DirectX), you can use non-rectangular regions (Example: oval rear-view mirrors)

Mark
Pipo DeClown
Pipo DeClown
Quote:
Original post by circlesoft
You can definetly do it either way. However, I think each is better used in different situations.

Overlayed rendering, where the world is rendered on top of the other render (ie the progress of some vehicle), can best be implemented with render targets. This is because you can render the overlay to a texture, and they render that texture to any place on the screen.

Split-screen rendering (ie multiplayer games), can best be implemented with viewports. This is because the two rendering areas aren't overlapping at all.


Huh? I thought viewports could overlap if you wanted them to, is that not true?
circlesoft
circlesoft
Quote:
Original post by Pipo DeClown
Huh? I thought viewports could overlap if you wanted them to, is that not true?

Perhaps you can, I've never really gone in-depth and tried it. However, render targets seem to be much more suited for window-like rendering. For one, I think it's much easier to deal with rendering a texture, than to deal with setting up viewports and such. Also, if you already have render targets set-up, you can apply some cool post-processing effects.
DrunkenHyena
DrunkenHyena
A viewport is pretty trivial to set up and I would be shocked if it had a significantly lower cost that setting a render target, rendering and then copying.

In general I'd say that viewports are the way to go. If however you do want post-processing or if the small image can be cached (only updated occasionally) then a render target would be a better choice.

A render target is definitely the most flexible choice, but whether it's the right one depends on exactly what you want to accomplish.

Stay Casual,KenDrunken Hyena</FON
darookie
darookie
Quote:
Original post by circlesoft
Quote:
Original post by Pipo DeClown
Huh? I thought viewports could overlap if you wanted them to, is that not true?

Perhaps you can, I've never really gone in-depth and tried it.

You can have overlapping viewports.
It's easier to setup but less flexible than mutliple render targets.
[edit]
Ok. DH already covered that a few seconds earlier [smile]
[/edit]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.