Render to multiple textures and Shaders

Hello everybody,

I was using FBO to render to texture (RTT) with only one target (a single color attachment). In order to process the image rendered, I was using shaders. It was obvious to me that a fragment program was executed for each pixels of the target.

Now, I want to use multiple targets ability of the RTT pipeline and shaders (by binding multiple color attachments to a single FBO and specifying which shader output target is linked with each attachment). But, the previous idea is going wrong here, if I use different sized targets...

How many shaders run when I render to different sized target and how pixels are accessed in this case? (for instance, a target is 64X32 and another is 256*64)

How does it work???

Thanks,

Arkh

How many shaders run when I render to different sized target and how pixels are accessed in this case?

You’re way overthinking this.

When you render to an FBO that has multiple images bound to it, it works exactly like you’re rendering to an FBO with only one image bound to it. Nothing is stretched or shrunken. Triangles are not scan converted for different images and different resolutions, and the fragment shader is only executed once per sample.

The only difference is that the maximum viewport area is the intersection of the widths and heights of all of the active images. So, in your example, if you have a 64x32 image and a 256x64 image, you can only ever render to a 64x32 region of both images. You can’t cause any of the pixels outside of this region to change. Not unless you unbind the smaller texture.

In ASCII art, if you have these two images:


---  |----|
|3|  |6x3 |
|x|  |----|
|6|
| |
---

If you attach them to an FBO, the maximum viewport you can set is:


---
| | 3x3
---

The smaller dimension of both.