Sign in to follow this  

HLSL and depth/alpha question...

This topic is 4353 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got four vertices that represent all four courners of the screen so that when I draw them to the current back buffer it covers the entire buffer area. I've assigned texture coordinates to said vertices 0,0 - 1,0 - 1,1 - 0,1. Standard for a quad tex so that 0,0 us upper left and 1,1 is lower right. these vertices create a drawing plane in the current back buffer at a depth I specify by setting the above vertices z value. (said vertices are TransformedColoredTextured). what I'm doing is the following steps... 1. Render an object to a offscreen texture target. backgound is color (0,0,0,0). 2. Call a draw on my screen corner vertices to kickstart my pixel shader. 3. Directly map samples from the texture tartget to the back buffer. Trying only to copy lit texels. the problem is that when I draw the verts it discards the backbuffer data that's depth is beyond my plane wether I'm passing lit or unlit texels from my sample. Q: is there a way to not draw (discard) certain pixels with my pixel shader? Or is there a fix for this? Thanks, Devin

Share this post


Link to post
Share on other sites
Quote:
Original post by devronious
I've assigned texture coordinates to said vertices 0,0 - 1,0 - 1,1 - 0,1. Standard for a quad tex so that 0,0 us upper left and 1,1 is lower right.

That usually works, but you might want to read the classic "Directly mapping texels to pixels" article - you should really provide offsets if you want things to line up correctly.

Quote:
Original post by devronious
Q: is there a way to not draw (discard) certain pixels with my pixel shader? Or is there a fix for this?

In assembly you can use the texkill instruction, and in HLSL it should be the clip() instrinsic.

Also, you might want to consider turning off Z-writing/Z-testing if you're getting problems there.

hth
Jack

Share this post


Link to post
Share on other sites
Thanks, ya I think if I turn off zenable and draw this plane last with alpha blending on it should work. But I'm going to mess around with texkill too. I think it would be super if I could test a condition and be able to discard the pixel process. Most of my final mapping would be discarded, perhaps this will lead to a performance increase :)

BTW, what does PostProcessing mean? I've heard it talked about and I've studied the vs and ps pipeline, but I'm unclear on this term.

Thanks again,

Devin

Share this post


Link to post
Share on other sites
Quote:
Original post by devronious
BTW, what does PostProcessing mean? I've heard it talked about and I've studied the vs and ps pipeline, but I'm unclear on this term.

It's where you perform some processing after the initial image rendering. What you've described is an example by the sounds of things...

Basically, if you render an image to a texture (be it from 3D objects, or just a composition of general graphics) and then render the texture to the screen using a quad (like you have) but apply a pixel shader (or just regular texture blending effects) that is PostProcessing.

Common examples are tone mapping, blur, depth of field etc..

hth
Jack

Share this post


Link to post
Share on other sites
OK, that makes sense. Yes my effect is that Post Processing Halo example from Nvidia, but I had to create it on my own since theirs was all scripted. And their's was limited to spreading I think 4 texels in each direction, whereas mine is relatively unlimited. It's been a really cool learning experience on pixel and vertex shader programming.

-Devin

Share this post


Link to post
Share on other sites

This topic is 4353 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this