Cubemap depth FBOs?

I get an “FBO configuration unsupported” error. Anything special I should be doing here?:

			glGenFrameBuffersEXT 6,Varptr shadowmap.framebuffer[0]
			For n=0 To 5
				glBindFramebufferEXT GL_FRAMEBUFFER_EXT,shadowmap.framebuffer[n]
				glTexImage2D GL_TEXTURE_CUBE_MAP_POSITIVE_X+n,0,GL_DEPTH_COMPONENT24,shadowmapresolution,shadowmapresolution,0,GL_DEPTH_COMPONENT,GL_UNSIGNED_BYTE,Null
				glFramebufferTexture2DEXT GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_TEXTURE_CUBE_MAP_POSITIVE_X+n,shadowmap.index(),0
				glDrawBuffer GL_FALSE
				glReadBuffer GL_FALSE
				Select glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)
					Case GL_FRAMEBUFFER_COMPLETE_EXT
					Case GL_FRAMEBUFFER_UNSUPPORTED_EXT
						Notify "FBO configuration unsupported",1
						End
					Case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
						Notify "Incomplete FBO attachment.",1
						End
					Default
						Notify "FBO error "+glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT),1
						End
				EndSelect
			Next

I already have “fake cubemap” point light shadows, but the fragment shader for determining the texture coordinates for the lookup uses a crapload of if statements, and a cubemap lookup would be much simpler.

I don’t know that language you’re using but the “Case GL_FRAMEBUFFER_COMPLETE_EXT” without an “End” looks like a fallthrough to “Case GL_FRAMEBUFFER_UNSUPPORTED_EXT”. :confused:

What hardware is this on?
This requires http://www.opengl.org/registry/specs/EXT/gpu_shader4.txt and won’t work prior to GeForce 8.

It’s a GEForce 8800 and there are no code errors.

My 2D cubemap code is like this:

			glTexImage2D  GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT24,shadowmapresolution*4,shadowmapresolution*2,0,GL_DEPTH_COMPONENT,GL_UNSIGNED_BYTE,Null
			glGenFramebuffersEXT 1,Varptr shadowmap.framebuffer[0]
			glBindFramebufferEXT GL_FRAMEBUFFER_EXT,shadowmap.framebuffer[0]
			glFramebufferTexture2DEXT GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_TEXTURE_2D,shadowmap.index(),0
			glDrawBuffer GL_FALSE
			glReadBuffer GL_FALSE
			Select glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)
				Case GL_FRAMEBUFFER_COMPLETE_EXT
				Case GL_FRAMEBUFFER_UNSUPPORTED_EXT
					Notify "FBO configuration unsupported",1
					End
				Case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
					Notify "Incomplete FBO attachment.",1
					End
				Default
					Notify "FBO error "+glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT),1
					End
			EndSelect

Wow, this forum topic is the number one result for a Google search of “OpenGL depth cubemaps”. Why do I sometimes feel like I am the only person in the world using OpenGL?

Google boosts a lot the ranking of recent forum topics. It is even more apparent as the keywords indexed are those you search for… It did this to me too, but it did not last more than a couple of weeks :smiley:

Works for me. I didn’t use mipmapping

also, when I called
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depthtextureID, 0);

it says GL_INVALID_OPERATION which is normal since the depth map is a Cubemap. I used
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X, depthtextureID, 0);

Here is a complete program in BlitzMax which attempts a simple cubemap/FBO initialization. Could you please compare this to the program you wrote and see if anything is different?:

Strict

Framework brl.GLGraphics
Import pub.glew

SetGraphicsDriver GLGraphicsDriver()

Graphics 640,480
glewinit()

Local tex:Int
Local n:Int
Const size:Int=256
Local framebuffer:Int[6]

glgentextures 1,Varptr tex
glbindtexture GL_TEXTURE_CUBE_MAP,tex
glTexParameteri GL_TEXTURE_CUBE_MAP,GL_TEXTURE_MIN_FILTER,GL_LINEAR
glTexParameteri GL_TEXTURE_CUBE_MAP,GL_TEXTURE_MAG_FILTER,GL_LINEAR

For n=0 To 5
	glTexImage2D GL_TEXTURE_CUBE_MAP_POSITIVE_X+n,0,GL_DEPTH_COMPONENT24,size,size,0,GL_DEPTH_COMPONENT,GL_UNSIGNED_BYTE,Null
Next

glGenFrameBuffersEXT 6,framebuffer
For n=0 To 5
	glBindFramebufferEXT GL_FRAMEBUFFER_EXT,framebuffer[n]
	glFramebufferTexture2DEXT GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_TEXTURE_CUBE_MAP_POSITIVE_X+n,tex,0
	glDrawBuffer GL_FALSE
	glReadBuffer GL_FALSE
	Select glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)
		Case GL_FRAMEBUFFER_COMPLETE_EXT
			Notify "FBO is fine."
		Case GL_FRAMEBUFFER_UNSUPPORTED_EXT
			Notify "FBO configuration unsupported",1
		Case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
			Notify "Incomplete FBO attachment.",1
		Default
			Notify "FBO error "+glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT),1
	EndSelect
Next

End

I had made a color cubemap and attached to GL_COLOR_ATTACHMENT0_EXT. It looks like if I don’t create the color cubemap and don’t attach, then I get incomplete FBO.

BTW, I had done this same operation with 2D depth and color texture attached to the FBO. When I rendered to it, the depth texture was all black I think which was obviously wrong. The color texture was ok. I wasn’t using mipmaping. Any ideas?

I don’t know, but it is likely you did something wrong unrelated to the attachment.

I’m really disappointed at how little knowledge there seems to be of this subject. I’m sure I am not the first person to want to use depth cubemaps for shadows.

Some things you could try:

  • Unbind the texture before attaching it to the framebuffer!
  • Do not use GL_LINEAR as filter, but GL_NEAREST.
  • Nitpick: The correct parameter to glDrawBuffer and glReadBufer is GL_NONE, not GL_FALSE (but both are zero anyway).

Neither of thes suggestions changed anything.

I am trying this now, per OC2K’s suggestion:
glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,tex,0,n)

This results in a “Missing FBO Attachment” error rather than an unsupported configuration.

The most recent code I posted now works. I don’t know what drivers and GPU I had installed when it was written, because I switch GPUs several times a day.

I presume the result is most likely due to magic.