Skip to main content
gamedev.net
🔒 Locked

Rendering the Z-buffer

Started by treeway Jul 5, 2006 at 8:10 PM 4 replies 850+ views
Original Post
treeway
treeway
Hi Ive got the back buffer rendering to a texture but how do i do the same thing with just the z-buffer? thanks
Kest
Kest
You would probably have to lock it and convert the values from the 0 to 1... to 0 to 255 brightness values as you copy each pixel.

Or did I completely miss your question? You do want to literally render the z buffer, right?
katsh
katsh
i think its impossible that render the contents of z-buffer to the texture.
Kest
Kest
It's not impossible. I would represent far distances with black, and near distance with white. So you could just convert the z buffer values to float modulator 0.0 to 1.0 values, where 0.0 is far away. Then set each channel of the pixel to this multiplied with 255:

int bright = int( z * 255.0 );
*Pixel = D3DCOLOR_RGBA( bright, bright, bright, 255 );

It would be a pretty cool effect. Although you might even be able to cheat and render all of your objects white, and then use black fog stretching over the whole z-buffer distance. If you don't know how to do that, just ignore my ramblings.
katsh
katsh
Quote:
Original post by Anonymous Poster
It is possible to copy the Z-buffer to a texture

really? how?

Quote:
Original post by Anonymous Poster
because this is exactly how modern shadow mapping techniques work.

in my case,i do shadow map using shader.in shader code,i have to calc z-value(it not from "z-buffer of direct3D") with myself.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.