How to get an array of sampler2D into a fragment shader?

Hi. What is the best (easiest and most backward-compatible) way to get an array of ‘sampler2D’ textures into a fragment shader?

I have an old nVidia GTX 460 and the method must work on this card.

My program does the Depth Peeling algorithm by binding the depthbuffer of the previous Depth Peeling render pass and it binds a screenbuffer (sampler2D) that will contain the current Depth Peeling layer.

So I have an array of (up to ~25) screenbuffer textures (in the C++ code) which contain the peeling layers, and I want to access any of those textures in a single shader.

Thank you.

A GTX 460 is still a Fermi architecture with pure GL 4.x support. That’s not old.

The correct solution is to use a single 2D array texture. You can use glFramebufferTextureLayer to attach specific layers of the texture to the FBO.

Thank you for the reply. I’ll check that out. And greetings from my GTX 460, it is amused you call it ‘not old’ :slight_smile: