Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Unsuspected

Shaders and alpha

This topic is 5158 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 have a problem; whenever I render a texture that has alpha, the stuff that are suppose to be behind it aren''t drawn if they were rendered with a vertex shader. My vertex shader drawn meshes do not properly show when I have an item with an alpha texture in front. For example, if I have a square texture with alpha to make it look like a circle, the alpha for the square just shows that last thing draw WITHOUT a shader in the alpha area. I assume since the vertex shader doesn''t go through the same pipeline, then DX doesn''t know about it so it can''t draw it when there is transparency. It is hard to explain so I hope someone got it Is there a way to fix this?

Share this post


Link to post
Share on other sites
Advertisement
If you are using alpha to completely remove a portion of a texture, then instead of blending the texture with the scene, use alpha testing to prevent from drawing hidden parts. See, the invisible parts still get drawn to z buffer if you are only blending. Alpha testing will prevent those invisible pixels from being drawn to the z buffer.

Share this post


Link to post
Share on other sites
Then you need to either sort the particles by screen z, or disable z writes altogether for the particles.

Share this post


Link to post
Share on other sites
quote:
Original post by Mastaba
Then you need to either sort the particles by screen z, or disable z writes altogether for the particles.


Neither of those work. I already sort them, but it doesn''t matter because the mesh that gets drawn by the vertex shader is not displayed in the alpha areas. Instead, the last thing that was drawn WITHOUT the vertex shader is there.

Although disabling z write fixes that problem, it would always make the circles appear behind the stuff that were drawn with the vertex shader, so it is not a good solution.

Share this post


Link to post
Share on other sites
Two things. First you should use alphatest even when alphablending to eliminate wasted bandwidth writing pixels that don''t change, or don''t change enough to be worthwhile. Set to accept pixels with an alpha greater than 8 (or greater than 0 if you think every last blending edge pixel is important).

Second, your sort isn''t complex enough. What you want is something like the following. First seperate solid objects and alpha-blended objects. Solid objects should be sorted by texture/shader then Z front to back. These should be drawn first. Then you want to draw alpha-blended objects back to front.

This has nothing to do with going through a different pipeline. You''re drawing something close first, filling the Z buffer with a low value. Then you''re attempting to draw something further, and somehow hoping it magically get''s past the Z reject, and further hoping it will somehow be blended, even though the blending has already finished.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!