Skip to main content
gamedev.net
🔒 Locked

Camera conundrum

Started by Scythen Oct 17, 2005 at 2:03 PM 1 replies 400+ views
Original Post
Scythen
Scythen
I’m redesigning the relation between cameras, viewports, and render targets in an engine and I thought I had a great system until now. This is an architecture question so an overview is required before I can ask my question. First, all cameras use normalized coordinates that are mapped to what ever viewport the camera is used to render to. So, a camera with a window rect of (0,0,1,1) would render to the whole viewport, where (.25, .25, .5, .5) would render to a window in the center of a viewport. Quite striate forward I thought. Viewports represent areas of render targets and are also set up using normalized coordinates but they also contained real coordinates for the target they are associated with. When cameras are used with viewports, the cameras window rect is relative to the viewports rect on the target. Now the problem, before going to normalized coordinates the aspect ratio was a function of the camera windows width and height but now, the camera doesn’t have enough information to calculate the aspect ratio without a viewport. I definitely don’t want to require a viewport be passed to all functions that could need to update internal dirty transforms so I’m left with storing the aspect ratio as a separate value. It seems that this could get ugly if the aspect ratio of the underlying viewport is different than the cameras aspect ratio. Say a camera is used to rendered to two targets, one 100x100 pixels and another 100x200 pixels. Unless the cameras aspect ratio is explicitly set to match the targets it’s not going to render correctly. What’s worse is someone could use a cameras aspect ratio or projection matrix for some computation and not know the aspect ratio is off. My question is, does this system sound reasonable or does it make more sense to use real pixel coordinates? [Edited by - Scythen on October 17, 2005 7:09:55 PM]
dimebolt
dimebolt
Quote:
Original post by Scythen
First, all cameras use normalized coordinates that are mapped to what ever viewport the camera is used to render to. So, a camera with a window rect of (0,0,1,1) would render to the whole viewport, where (.25, .25, .5, .5) would render to a window in the center of a viewport. Quite striate forward I thought.


Why does a camera have a window rectangle? It seems that you are having viewport (in the OpenGL interpretation of the word) functionality in your camera. Can you explain why you need a camera to be a subsection of a viewport, which in turn can be a subsection of its render target? Your implementation of the viewport sounds almost identical to my own (and therefore quite sane :). But I restrict my cameras to containing projection info.

Tom
Scythen
Scythen
That’s a good question.

Thinking about it now it doesn’t make sense at all because I can get the same effect by simply using two overlapping (or not) view ports. Another problem your question has brought to my attention is the render order of cameras. My render targets store view ports in a tree for render order but Viewports have no way to order the cameras. I guess I should abandon the whole camera view port thing and just force cameras to have either a pointer to a Viewport or in the case where there is no associated Viewport their own rect info.

Topic Locked

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

Sign in to reply to this topic.