Author Topic: avoiding depth sort /transparency issues on a merged object  (Read 691 times)

Offline majestik_m00se

  • byte
  • *
  • Posts: 6
    • View Profile
avoiding depth sort /transparency issues on a merged object
« on: March 09, 2012, 08:50:21 pm »
Hi,

First of all, thanks for your help previously with my earlier navigating-a-sphere questions.  I got it to work, the help I got from Egon and others on this board was very useful!

So, now I am playing around with .3ds models, and I loaded some low-poly trees into my world. they consist of a half-dozen or so quads, with an alpha 'leaf' texture applied to them (so only the leafy part shows), and a trunk, which is another low-poly mesh but with a standard, non-alpha texture applied to it.

To this point I have been using a variant of the model loader code from the JPCT wiki, that loads the sub-objects of the .3ds file and merges them into one Object3D.    The problem I've been having is that the leaves on the tree have z-ordering issues, where they pop in front of and in back of the tree trunks as you change camera perspective etc.  I have tried various values for sort depth and transparency, but since both the leaves and trunk are merged into a single object, I don't think it really solves the problem.

I suspect I might need to keep the leaves and trunk as separate objects, and apply different sort depths and transparency settings to each, but I wanted to see what people thought.  If I do that, it will double the number of tree-related objects, I don't know if that has a perf impact if there are a large number of trees.   I assume if I did that, I'd make one the child of the other or something so rotations/translations will move everything together ? (sorry,  im a bit of a newbie to 3D engine mechanics)

  I'm also assuming that I can't get away with setting sort order and transparency on the sub-objects before I merge them (ie, an Object3D can only have one value for each of these attributes.)  Along those lines, if there is some other kind of thing I should experiment with on the merged object to get my leaves to settle down, I'm interested! :-)

Thanks!


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11746
    • View Profile
    • http://www.jpct.net
Re: avoiding depth sort /transparency issues on a merged object
« Reply #1 on: March 09, 2012, 09:00:06 pm »
Yes, the best option is to split them into separate objects. Transparent objects are sorted per object...like the painter's algorithm does it. But this sorting is never perfect and depending on the viewing angle, it may lead to sorting flaws. Splitting trunks and leaves will solve this problem.