PDA

View Full Version : Issue in using depth texture for VTF



starstar
10-14-2008, 05:20 AM
Viedio card Geforce 7300,Winxp OS
1.How to generate floating point depth texture using FBO?

2.Even so,does the genertated floating point depth texture can be used for VTF?
Because I know only the GL_RGBA32F_ARB or GL_LUMINANCE32F_ARB texture format can be used for VTF.

appreciate any answers

k_szczech
10-14-2008, 08:16 AM
It's stated in VTF specs, that the only texture format acceptable is 32-bit float and you must use GL_NEAREST filtering.
I'm using GL_RGB32F_ARB format.

If you want to render depth buffer to such texture, then I suggest you create FBO with standard depth render buffer attached, and this texture attached to clor output. Then simply use fragment shader that stores depth as, let's say, red component in this texture.

Note that you also need a GPU that supports VTF. Your GeForce is enough, since all GeForces support it since GeForce 6.
Radeons (at least the ones withoud unified shader architecture) will not support VTF.

Jackis
10-14-2008, 02:18 PM
Little remarks.

If you have G80 or higher (it doesn't suit you though, you have G70 GPU), you can access any texture you want in any of shader stages.

starstar
10-17-2008, 01:05 AM
Thanks k_szczech and Jackis
I change my Viedio card to Geforce 8600
I use NV_depth_buffer_float to generate floating point depth texture.

glGenTextures(1, &shadowTextureID);
glBindTexture(GL_TEXTURE_2D, shadowTextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);


glGenFramebuffersEXT(1, &framebufferID);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferID);

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F_NV, 1024, 1024, 0,GL_DEPTH_COMPONENT,GL_FLOAT , NULL);

glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT , GL_TEXTURE_2D, shadowTextureID, 0);

glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);

GLenum fboStatus = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (fboStatus != GL_FRAMEBUFFER_COMPLETE_EXT)
{
fprintf(stderr, "FBO Error!\n");
}
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
the floating depth texture is correct.Does the texture can be used for VTF?

Jackis
10-17-2008, 01:57 AM
Surely, why not? Your filtering and clamping is ok.
Just fetch from it, and you should get normalized depth in .X component of result vector.