Quote Originally Posted by somboon View Post
I am now succesfully use texture array to store each slice of shadow map (still have't tried geometry cloning) and able to see some improvement in framerate.

But using texture array introduced some design problem.

I have some ping pong blur shader that expect simple texture2d as an input.

Are there anyway can I bind each face of the array as simple texture2d
so that I can continue using those blur shader or I have to write a specified blur shader that take texture array and slice index ?
@somboon
Hi, I know that this post is a bit old, but I have a similar problem. I'm trying to generate each shadowmap on one layer of TEXTURE_2D_ARRAY, but i have some difficulties ! maybe can you help me about that ? To generate shadowmaps, i proceed like that :

void initShadows(GLAutoDrawable drawable)
{
GL2 gl = (GL2)drawable.getGL();

shadow_tex = Buffers.newDirectIntBuffer(1);
gl.glGenTextures(1, shadow_tex);

this.shadow_fbo = Buffers.newDirectIntBuffer(1);
gl.glGenFramebuffers(1, shadow_fbo);


gl.glActiveTexture(GL2.GL_TEXTURE2);

gl.glGenTextures(1, shadow_tex);
gl.glBindTexture(GL2.GL_TEXTURE_2D_ARRAY, shadow_tex.get(0));
gl.glTexParameteri(GL2.GL_TEXTURE_2D_ARRAY, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D_ARRAY, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D_ARRAY, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP_TO_BORDER );
gl.glTexParameteri(GL2.GL_TEXTURE_2D_ARRAY, GL2.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP_TO_BORDER );
gl.glTexParameteri(GL2.GL_TEXTURE_2D_ARRAY, GL2.GL_TEXTURE_COMPARE_MODE, GL2.GL_COMPARE_REF_TO_TEXTURE);
gl.glTexParameteri(GL2.GL_TEXTURE_2D_ARRAY, GL2.GL_TEXTURE_COMPARE_FUNC, GL2.GL_LESS);

gl.glTexParameterfv(GL2.GL_TEXTURE_2D_ARRAY, GL2.GL_TEXTURE_BORDER_COLOR, white, 0);

gl.glTexImage3D(GL2.GL_TEXTURE_2D_ARRAY, 0, GL2.GL_DEPTH_COMPONENT32, (int)shadowTexSizeX, (int)shadowTexSizeY, (int)spotLights.size(), 0, GL2.GL_DEPTH_COMPONENT, GL2.GL_UNSIGNED_BYTE, null);
gl.glBindTexture(GL2.GL_TEXTURE_2D_ARRAY, 0);
gl.glBindFramebuffer(GL2.GL_DRAW_FRAMEBUFFER, this.shadow_fbo.get(0));

gl.glFramebufferTextureLayer(GL2.GL_DRAW_FRAMEBUFF ER, GL2.GL_DEPTH_ATTACHMENT, this.shadow_tex.get(0), 0, 0);

}


and to draw on the light point of view, on each layer of the texture :


gl.glBindFramebuffer(GL2.GL_DRAW_FRAMEBUFFER, shadow_fbo.get(0));
gl.glClear(GL2.GL_DEPTH_BUFFER_BIT);

gl.glColorMask(false, false, false, false);
gl.glDisable(GL2.GL_BLEND);

glFw.pushProjectionMatrix();
glFw.pushViewMatrix();

for(int i=0; i<spotLights.size(); i++)
{
gl.glViewport(0, 0, (int)shadowTexSizeX, (int)shadowTexSizeY);
//last i parameter for the layer of the texture array
gl.glFramebufferTextureLayer(GL2.GL_DRAW_FRAMEBUFF ER, GL2.GL_DEPTH_ATTACHMENT, this.shadow_tex.get(0), 0, i);
.....
//set point of view for each light and draw scene


and, my fragment shader :

uniform sampler2DArrayShadow texShadow;
vec4 shadowCoordinateWdivide = shadowCoord / shadowCoord.w;
float shadow = texture(texShadow, vec4(shadowCoordinateWdivide.xyz, i));
... light calculation ponderate by shadow

is it something wrong ? please help me !