Showing posts with label fbo. Show all posts
Showing posts with label fbo. Show all posts

Sunday, October 25, 2009

Rendering to a depth texture doesn't work

Annoying problem: I want to capture the depth for each fragment and use it for some computation. So, I set up the FBO with a depth texture attached to the depth attachment point. Then I bind the FBO and render the scene. Now the moment of truth: draw a quad that is textured with the depth info.

The quad is completely white. Ok, maybe I'm setting up the texture wrong. Check some examples, tweak things a bit, check some of my old code, everything looks good for another try.

Now the depth texture looks like its full of random stuff. It never gets updated, but the actual scene is updating quite nicely.

What am I doing wrong? *bangs head against wall for an hour or two*

I just needed to to:

glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

before rendering the depth. That's all I was missing.

Thursday, September 24, 2009

Bump mapping




This is the first step in completing assignment #3. The height map was created using difference clouds in photoshop. A fragment shader was written that computes the normal map. This is rendered using a frame buffer object. The normal map is attached to a texture and fed into another shader that lights the models using the normals from the normal map.

In the upper right corner of the scene, the normal map is displayed on a textured quad.