Original Post
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]