Managing viewport and Projection Aspect Ratio for Render to Texture

Started by
0 comments, last by deavik 18 years, 3 months ago
Hi all - I'm currently making some rather large upgrades to my older framework, and I'm experimenting with rendering to textures in anticipation of adding shader support and working with full screen post processing effects. (blurs, glows, etc) So far, I've been able to get the basics working, but I'm running into problems as I approach full screen textures. I run at 1024x768 on an ATI Radeon 9700 Mobile. Here's what I'm doing right now: 1) I specify the size of the texture I want to render to - this is important if I want to force the rendering to be of a lower resolution. But it's also problematic, because as far as I know, I'm restricted to power of two textures (Do they have to be square?) 2) I set the viewport to that size, then render the screen (using the Projection matrix I would use for rendering normally) 3) I then bind the buffer texture and call glCopyTexImage2D, passing in the size of the texture again 4) Then I render out to the texture to a full screen quad. When I render a texture that's 2x2, 4x4, 16x16, etc, up to 512x512, I get mostly what I expect, a blurry, low res version of the original scene. (maybe stretched?) I'm a little worried about distortion of the image here, caused by changing aspect ratios. If I leave the projection matrix alone, then I render the objects as if the aspect ratio was 4x3, then the first viewport Xform squishes it horizontally to 1x1, then the second viewport Xform(when I render it to the screen) restretches it, as I understand it. Should I change the projection matrix to a 1x1 aspect ratio first, or will that screw things up? When I look at the screens side by side, I can tell they're different, but I don't know which one is "correct." They both look pretty good, though. Also, when I want to go to screen resolutions, it seems I need to render to 1024x1024, which seems wasteful of memory or worst case causes clipping problems (since the screen is only 1024x768). If I try setting everything up for 1024x768, it runs crazy slow - due to the power of two texture limitation, I imagine. Does anyone have any input on these two issues? Something tells me I'm missing something large here, since the way D3D handles Render to Texture seems to bypass all of these issues with no problem. How do you guys manage rendering to textures in your apps? Thanks in advance for any help!
...
Advertisement
To answer one question of yours:
Quote:Original post by Stoic
... Do they have to be square? ...

No, just power of two width and height.

This topic is closed to new replies.

Advertisement