linear algebra - OpenGL Depth Calculation for Bounding Boxes -


i´m writing opengl app uses transparency/translucency algorithms based on depth ordering.

my first approach calculates bounding box center distance camera objects, realized 1 bounding box can closest camera other, center farthest.

the orientation of boxes can different axis aren't aligned.

enter image description here

how can calculate correctly bounding box distance camera?

the best approximation can done sorting objects using farthest obb point z-component in camera space (the point highest/lowest z-component in camera space depending on handedness) , hence comes name z-sorting. can use squared distance fine.

remember when issuing draw commands need render 1 of them first (you can't draw them partially unless break each of them separate objects.

in case object1 should drawn first, , notice has farthest point along camera axis.

the algorithm in nutshell:

  • transform each bounding box points camera space.
  • find farthest point along camera z axis point each box. become depth key each bounding box
  • sort boxes using depth keys found.
  • draw objects front.

p.s. yet think of case might fail that's why said approximation.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -