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

Discarding Pixels

Started by arithma Sep 11, 2006 at 4:14 AM 4 replies 1.4k views
Original Post
arithma
arithma
How can I discard pixels from being draw in the pixel shader.. For example, in the displacement demo of DX10 (the one with the displaced fish), they need to discard pixels that when raytraced, hit nothing.
sirob
sirob
The HLSL clip instrict, and the ASM texkill instruction cancel rendering of a pixel in the PS, if any component of their parameters is less than 0.

Hope this helps.
Sirob Yes.» - status: Work-O-Rama.
blaze02
blaze02
I simply return the color float4(0, 0, 0, 0). With alpha blending on, the pixel does nothing to the scene.
edwinnie
edwinnie
hi blaze!

I am wondering if alpha blending can be used to discard pixels that were previously discarded by the depth test. For example, in Depth Peeling.

I am trying to get it to work but I have not gotten it right yet (possibly due to the fact that I seldom use alpha blending). Any suggestions would be appreciated.

I am using an fx file and outputting to a R32F texture.
AlphaBlendEnable = true;SrcBlend = One;DestBlend = One;BlendOp = Add;//depth peeling pseudocodehalf currentDepth = ...;half previousDepth = ...;if(currentDepth <= previousDepth)   currentDepth = 0.0;return half4(currentDepth,0,0,0);
blaze02
blaze02
I haven't worked with pixel shaders too much... at least nothing complicated. If you are going to use alpha blending, you need to set the source blend to something less than one. I'm not sure of the pixel shader flag, but SrcAlpha is the most common (the blending factor is equal to the sources alpha channel).

I don't understand what you mean, "discard pixels that were previously discarded"? Why would you want to discard something twice?
As long as Z-buffering is enabled, I'm pretty sure your pixel shader does not even "receive" pixels that were discarded by the depth buffer. I think the algorithm requires that you turn off the depth buffer, but leave the ZWriteEnable on so at least you know the current depth of the pixel. Something like that I'm guessing. Wish I could help more. G'luck.
edwinnie
edwinnie
Ah my confusion in explaining my problem. Basically, I am using depth peeling for now. Depth Peeling requires a discard of a pixel if the current depth is found to be less than or equal to a reference depth (meaning there are 2 sets render passes).

So I was wondering if instead of using the 'discard' keyword, which is currently used in Depth Peeling, if alpha or color blending can be used instead.

thx!
Edwin

Topic Locked

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

Sign in to reply to this topic.