Jump to content
  • Advertisement
Sign in to follow this  
JasonAshman

help with alpha blending from front to back

This topic is 2563 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 im writing a 2d game engine on direct x 9. and all is going well, well it was.

I am implementing a system that sorts sprites by texture and renders them all out at once so a texture is only done in a single draw call even if there are a billion sprites on there (i will probably cap it...).
either way before i have even finished that i ran into a problem of alpha blending only working when i render in the correct order (back to front). i had it working properly when i would use dx3dsprite (or whatever the class is) and even when i stopped using them and only had the sprite->begin(enum for alpha blending that i forgot) before anything was rendered it will still work, but if i remove that it doesnt alpha blend correctly.

does anyone have any experience with alpha blending and can help me out with this. id post some code samples but i have nfi where to begin on this. thanks in advance :)

Share this post


Link to post
Share on other sites
Advertisement
Are you asking if it's possible to get correct results with an incorrect sorting order, or are you asking what you should do to achieve a correct sorting order?

Share this post


Link to post
Share on other sites

Are you asking if it's possible to get correct results with an incorrect sorting order, or are you asking what you should do to achieve a correct sorting order?


i want to render out of order and achieve a correct result. as i said if i turn on the dx3dsprite class, and not use it, it works fine, but i turn it off and i cant get it to work and id rather not have any references to it in my code

Share this post


Link to post
Share on other sites

[quote name='Hodgman' timestamp='1323328755' post='4891728']
Are you asking if it's possible to get correct results with an incorrect sorting order, or are you asking what you should do to achieve a correct sorting order?


i want to render out of order and achieve a correct result. as i said if i turn on the dx3dsprite class, and not use it, it works fine, but i turn it off and i cant get it to work and id rather not have any references to it in my code
[/quote]

Consider two sprites, the front one is completely opaque and the back one is transparent. If you process out of order it is possible that you will see the transparent one. The logic to prevent that scenario is probably going to be more expensive than sorting.

Share this post


Link to post
Share on other sites

[quote name='kotmfu' timestamp='1323330252' post='4891731']
[quote name='Hodgman' timestamp='1323328755' post='4891728']
Are you asking if it's possible to get correct results with an incorrect sorting order, or are you asking what you should do to achieve a correct sorting order?


i want to render out of order and achieve a correct result. as i said if i turn on the dx3dsprite class, and not use it, it works fine, but i turn it off and i cant get it to work and id rather not have any references to it in my code
[/quote]

Consider two sprites, the front one is completely opaque and the back one is transparent. If you process out of order it is possible that you will see the transparent one. The logic to prevent that scenario is probably going to be more expensive than sorting.
[/quote]

the problem is i want to batch render out a texture atlas worth of sprites, and i cant do that if i render by z location. sorting isnt the problem, im currently sorting by texture.

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!