Skip to main content
GameDev.net gamedev.net
🔒 Locked

Correct approach to render pixels of a SPECIFIC depth

Started by wiselogi Jul 30, 2011 at 8:03 AM 2 replies 1.1k views
Original Post
wiselogi
wiselogi
Hi,

Well, suppose I have a depth map and just want to render pixels that are on the specific depth of the depth map.


Its not a common depth test, because I might have fragments that are closer to the camera but the depth on the depth map for that screen position is farther.

I thought on this approach:


1.Render Scene

2. At pixel shader consult the depth map, if current fragment depth is within the tolerance, shade and return fragment.

else

clip(-1);

Is this the correct approach, would it work?
Dawoodoz
Dawoodoz
You might get it to work but it would be very slow because the real depth buffer have a quad tree in the hardware for optimizing.
If you are using it for alpha filtered particles, it won't be much slower since soft particles aren't using the real depth buffer either.

Remember that the real depth buffer is not linear when having perspective.
http://www.gamedev.n...dering-shadows/
Promethium
Promethium
Off the top of my head: Fill the depth buffer with the depth map, set depth test to equal. Precision will likely not be good enough though smile.gif
Your proposed method should work, and you get the possibility of making an epsilon test. You might want to look into some techniques for calculating the depth yourself, like in deferred rendering. Like this one or this one.
wiselogi
wiselogi
Yeah, my concern was exactly performance. I know that clip(-1) is quite slow.

About using Equal for depth test, I think that I would miss most pixels because of the precision, wouldnt I?

Well, I was just wondering if there was any performance aware method to do this, but I suppose not right?

Topic Locked

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

Sign in to reply to this topic.