Hi everyone. I'm trying to create a picture-in-picture effect. The idea is to render the scene twice, once on the normal framebuffer, and then again on a smaller texture. I'll do some visual effects to the smaller texture (as well as render some extra stuff) and the idea is to let the player look through a “magic window” that can reveal hidden things.
I could accomplish this by rendering it full size and clipping to the target area, but because I need to glRead the texture's pixels for other reasons, I want to use a smaller texture for speed.
The intended effect is something like this:
My problem: I cannot for the life of me make the render on the smaller texture match 1:1 with the full-size framebuffer image. I've tried lots of kludges, they all come with some price to pay, such as a slightly different perspective, or the image fading into the fog on the texture, even.
The data I have to play with:
- Resolution of the big render
- Resolution of the smaller texture
- World/View/Project matrices from the big render
- Viewport from the big render
- The XY coordinate that I want to “pan” to on the smaller texture.
How can I rearrange all these to produce a projection matrix for the smaller render that is zoomed and scaled to match the big one?