PDA

View Full Version : How to get an array of sampler2D into a fragment shader?



JasonRay
01-13-2016, 12:25 PM
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.

Alfonse Reinheart
01-13-2016, 01:48 PM
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 (https://www.opengl.org/wiki/Array_Texture). You can use glFramebufferTextureLayer to attach specific layers of the texture to the FBO.

JasonRay
01-14-2016, 09:20 AM
Thank you for the reply. I'll check that out. And greetings from my GTX 460, it is amused you call it 'not old' :)