• Advertisement
Sign in to follow this  

Models with alpha channels

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

So I am aware that when rendering models with alpha channels, you have to sort through the positions and render from closest to furthest. However, I also noticed that a polygon with an alpha channel will also obstruct the other other pieces of a same model. The question is, do you also have to sort through each polygon in a model and render those from closest to furthest as well? -Chris

Share this post


Link to post
Share on other sites
Advertisement
Actually as I understand it you have it backwards. To alpha blend correctly (unless you are using a simple add op) you need to sort from back to front. When you are rendering without alpha you may want to sort from front to back so that pixels are removed from the pipeline as soon as possible by the z-buffer. The reason that you sort oppsite when using alpha is so that pixels that should be blended don't removed early.

Share this post


Link to post
Share on other sites
Like turnpast wrote, you must render non-opaque triangles back-to-front. As you noticed, you can't just sort models because you might see part of a model through itself, so you still must sort individual triangles.

Now, modern hardware does some rejection based on Z-values for opaque pixels, so opaque triangles should be rendered front-to-back (but its not required).

Generally, rendering goes like this: opaque triangles are sorted (or roughly sorted or not sorted) front-to-back and rendered. Then non-opaque triangles are sorted back-to-front and rendered. Also, since the non-opaque triangles are drawn last and are presorted, Z-write is turned off and that may speed up rendering.

Share this post


Link to post
Share on other sites
Obviously, sorting all of the triangles in a mesh is both ugly and gonna kick your performance to its knees... so one possible hack is to render all of the backface triangles first and then render all of the frontface triangles second. it's not perfect but the results are good enough in some cases [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Ok, maybe I'm being stupid... but is it possibly that you have backface culling on?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement