- April 18, 2012 at 7:04 am #30835
Is it possible to create a depth component only FBO targeting a GL_TEXTURE_CUBE_MAP. What I want to do is to extend my spot light shadow mapper into an omni directional shadow mapper by attaching a cube texture to the FBO instead.
I’m fully aware that I would need to render the scene in 6 passes, one for each side of the cube face since GLES 2 do not have geometry shaders, but that’s ok. There’s still a big win for only one texture unit (samplerCube) when doing the shadow depth tests, instead of 6 different samplers and choosing cube face manually.
I can’t get this to work unfortunately. I get incomplete attachment all the time.Code:glGenTextures(1, &depthTexture);
GLenum target = cubic?GL_TEXTURE_CUBE_MAP:GL_TEXTURE_2D;
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, depthType, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0);
for (int i=0; i<6; i++)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, depthType, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X, depthTexture, 0);
}April 20, 2012 at 12:34 pm #35751
Still haven’t been able to get this working… 🙁 Maybe it’s impossible to render to a cube depth map in GLES2?April 20, 2012 at 11:42 pm #35752
I wrote a wiki article some time ago about using FBOs with the PowerVR OpenGL ES drivers that might help:
Capturing the depth image into a texture requires the
OES_depth_texture extension which was only available beginning with the PowerVR OpenGL ES drivers build from their
Check if the driver you are using has this extension declared.
Regards, ClayApril 22, 2012 at 12:55 pm #35753
I can already capture the depth to a texture2d but not to a texturecubemap target. Is that possible?April 23, 2012 at 10:15 am #35754
Sadly, what your attempting to do is not supported by the current specification for OpenGL ES. If your using GL_DEPTH_COMPONENT then your only option is GL_TEXTURE_2D.
BobBobGardner2012-04-23 11:37:14April 23, 2012 at 6:13 pm #35755
Yeps, so I assumed by now. I’m using an alternative path where I render the depth values into the color channels instead. For 16-bit float precision I choose the OES_HALF_FLOAT format for that. This way I can reuse the cube map for up to 4 light sources at the same time, each using one channel at 16-bit float precision.