PDA

View Full Version : Off-screen rendering bigger than current window



Gene78
07-04-2009, 10:49 AM
Sorry if this is obvious. I'm implementing shadow maps in JOGL. My app is likely to run on a huge range of hardware including older stuff. Using the Redbook method of rendering in the back buffer and copying to a depth texture gives a bad result if the current window is smaller than the texture. Apparently the back buffer is maintained at the size of the window. What's the most portable way to draw off-screen into a texture? I can see the docs on FBOs, but how common are they in implementations? Max OS X seems to have a way to set the back buffer size that does not generalizee. Thanks.

yooyo
07-04-2009, 11:00 AM
Render smaller parts and upload parts of texture..
Lets say.. you have 1024x768 window and 2048x2048 depth texture.
Set viewport to 512x512 and render 16 tiles (4 x 4). For each tile adjust projection matrix, render scene and copy part of depth buffer to texture.

This will work, but cost is multiple vertex transformation (16x in this case). But.. this can be fallback in case that hw doesnt support FBO. If hw supports FBO then go that way.

Gene78
07-04-2009, 02:00 PM
Many thanks for the quick response.

I guess another approach that just occurred to me is render the shadow texture with less resolution. If the window is small, the loss of shadow precision probably won't make any difference.

yooyo
07-04-2009, 03:45 PM
Thats true.. if you dont care about shadow quality.

Gene78
07-05-2009, 06:33 PM
I tried sizing the shadow map in reshape() so it's the greatest power of 2 that fits. The shadow quality looks good in my application. I'll use this as the fallback for when FBOs aren't available. Thanks for your help.