• entries
    154
  • comments
    388
  • views
    163790

Blending and picking

Sign in to follow this  

192 views

Hello!
It has been a while since my last post but that does not mean I have not been busy. The last few days I have been updating the rendering routines for transparent objects. They can now be rendered on top of each other without causing wrong drawing order. I have split up the map objects into two lists, opaque and transparent objects. The first list is sorted by texture and rendered using alpha testing. The second list is sorted by its position on the map. OpenGL, or any other 3D API for that matter, can not sort blended objects - no z-buffer information. I use a fairly simple equation to calculate the sorting value:

sortValue=zpos*1000;
sortValue+=xpos;
sortValue+=ypos;

I could take into account the size of the object too but I think this will do for my purposes. This allows for such wonderful things as layering of water tiles with white smoke puffs above and below it: (woho!)


I have also been redesigning the picking routine. It is not finished yet but when it is, it should speed up the picking/selection of objects a great deal. I will not be relying on glReadPixels any more :-)
Sign in to follow this  


4 Comments


Recommended Comments

Quote:
Original post by sphair
How do you plan to implement picking without glReadPixels?


I will use ray triangle intersection tests to see which polygon the user has picked. This will have the draw-back that the selection will not be pixel perfect, it will only be possible to pick box shapes (other shapes are also possible but unnecessary due to that my graphics are boxed-based). It will on the other hand make it possible to pick transparent objects (like water surfaces) without first toggling the blend mode. The benefits outweighs the drawbacks I think. I will also benefit from the frame time that glReadPixels eats. =)

Share this comment


Link to comment

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