Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / DEPTH_TEXTURE_FORMAT_NV question Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

May 16, 2005, 09:28 AM


is there an OpenGL ARB extension doing the same as this nvidia extension or another clever way to do shadow mapping with two pass only with ARB ? The sample on codesampler ( ) says that only NVidia hardwares are supported at the moment for this shadow mapping method.




May 16, 2005, 11:38 PM

There is no ARB extension allowing for rendering directly to a depth texture. It is a curious omission, but at the moment the only way to render to a depth texture on non-NV cards is to create the texture using a depth format and then use CopyTexSubImage2D to extract the depth buffer from a render context.

If performing the copy is unacceptable, then another way is to use a floating-point texture (which can be rendered to directly on many cards) in place of the depth texture. You will need a fragment program to store the depth values to this texture, and another fragment program to read them back and perform the comparison manually, as well as any filtering.


May 17, 2005, 08:24 AM


thanks for your answer.



May 17, 2005, 09:24 AM

Also something that EXT_framebuffer_object is going to change. If it only were here already ...


May 17, 2005, 10:09 AM

As I wanted to stay with pbuffer, I've tried the CopyTexSubImage2D solution.

After a few changes in the codesampler code, it runs now without _NV extensions, but it seems that the CopyTexSubImage2D from a pbuffer (256 * 256 pixel) to a depth texture is really slow : the sample now runs at something like 5 fps when it was just smooth before...

The next strange thing is that if I render the shadow map directly in the framebuffer (and not in the pbuffer) and do the CopyTexSubImage2D from it, it runs smooth again ??

Am I missing something ?




May 18, 2005, 12:42 AM

That is very odd. I have a shadowmap demo that renders to a pbuffer (512x512), and then does a CopyTexSubImage2D to the depth texture, and it works fine (50fps) on my Radeon 9600. Which card are you using?


May 18, 2005, 01:53 AM

I'm using a geforce4 Ti 4600.

Do you need to define some special features for the pbuffer ?

here are the parameters I am using :

for the choose pixel format

  2.     int pf_attr[] =
  3.     {
  4.         WGL_SUPPORT_OPENGL_ARB, TRUE,       // P-buffer will be used with OpenGL
  5.         WGL_DRAW_TO_PBUFFER_ARB, TRUE,      // Enable render to p-buffer
  6.         WGL_BIND_TO_TEXTURE_RGBA_ARB, TRUE, // P-buffer will be used as a texture
  7.         WGL_RED_BITS_ARB, 8,                // At least 8 bits for RED channel
  8.         WGL_GREEN_BITS_ARB, 8,              // At least 8 bits for GREEN channel
  9.         WGL_BLUE_BITS_ARB, 8,               // At least 8 bits for BLUE channel
  10.         WGL_ALPHA_BITS_ARB, 8,              // At least 8 bits for ALPHA channel
  11.         WGL_DEPTH_BITS_ARB, 16,             // At least 16 bits for depth buffer
  12.         WGL_DOUBLE_BUFFER_ARB, FALSE,       // We don't require double buffering
  13.         0                                   // Zero terminates the list
  14.     };

and for the create pbuffer ARB :

  2.     int pb_attr[] =
  3.     {
  4.         WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB,                // Our p-buffer will have a texture format of RGBA
  5.         WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB,                  // Of texture target will be GL_TEXTURE_2D
  6.         0                                                            // Zero terminates the list
  7.     };

and the creation of the texture is done with :




May 20, 2005, 02:59 AM

That looks pretty much the same as the pbuffer parameters I use.

If you want to take a look at my shadow mapping demo, it's available for download on my website (go to OpenGL Demos and scroll down):


May 21, 2005, 06:27 AM

thanks Reedbeta,

I'll have a look at it at work, at home, my geForce2 doesn't support most of the extension required...


This thread contains 9 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.