Sign in to follow this  

Model blending with background

This topic is 3849 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 am using Direct3D's teapot model for testing alpha blending with the following blend states: SrcBlend = DestColor DestBlend = 0 which means that FinalColor = Source * Dest colors. The problem is that in the teapot some parts are being blended with other parts of the same teapot, which were rendered first. For example, the part of the teapot where you hold it (called handle?), is blended with the body itself and causes ugly artifacts. Are there any ways to solve this? Maybe by somehow using stenciling?

Share this post


Link to post
Share on other sites
Hi there.
We can solve this problem using the stencil buffer. We set the stencil test to only accept pixels the first time they are rendered. That is, as we render the blending pixels to the back buffer, we mark the corresponding stencil buffer entries. Then if we attempt to write a pixel to an area that was already been rendered to(marked in the stencil buffer) the stencil test will fail. this way we can prevent writting overlapping pixels and therefore avoid double blending artifacts.

Share this post


Link to post
Share on other sites
I've done the stencil testing as you said and there are no blending artifacts, but there is a serious problem with the depths. When I allow only the first pixel to be written, if that pixel was rendered by a part of the model that would be later be overriden by another part that is closer, now this isn't happening since it won't even get to the z-test after it fails the stencil test.
So what I see is this:

Share this post


Link to post
Share on other sites
Depth peeling gives you pixel-perfect order-independent transparency, however it requires you to render your scene multiple times. Depending on just how many transparent objects you're rendering and how complex they are, this might or might not be something you want to do (talk about generic advice).

Share this post


Link to post
Share on other sites

This topic is 3849 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