Accessing image2D from image2DArray

660 Views Asked by At

I am asking probably a simple question.I have a texture array (GL_TEXTURE_2D_ARRAY) of image2D textures.I access the array in a fragment shader via image2DArray.How do I get an access to the images of the array? imageLoad() has a param for layer number? I have read here and here ,but failed to figure out how it's done.

The thing is that if I access it like this:

void main(void)
{

color = vec4(imageLoad(output_image, ivec3(gl_FragCoord.xy,0) ).xyzw) / 255.0;
}

That is, third number of texture coords is texture layer index.I am getting texture's output onto the screen but it becomes static (doesn't move with cam movement) and displaced.

UPDATE:

Ok,it was my fault.I was referencing wrong texture object.Yes, the third coordinate of ivec3 in imageLoad should target texture array layer index.

0

There are 0 best solutions below