setBin help

Yes, but “behind” and “in front of” is not exactly correct. You should really say “before” and “after”. Because of the depth buffer, it’s possible for things to be drawn last, but still appear to be behind other things that were drawn previously. Of course, if you disable the depth buffer, then “behind” and “in front of” is accurate.

That is the purpose of the background bin, so yes.

Do you mean the second parameter to setBin()? That can be any integer. It has nothing to do with the bin’s sort value.

The way it works is: during cull, all objects are grouped in the bin they are assigned to. During draw, all bins are visited in order according to the bin sort number. For each bin, the objects assigned to that bin are drawn in the order specified by the bin type. If the bin type is BT_fixed, this means the objects are drawn in the order according to their setBin() second parameter, with the smaller numbers being drawn first. If the bin type is anything other than BT_fixed, the setBin() second parameter is ignored.

This sentence seems a little confused. The depth buffer has nothing to do with bins, not really. But many people disable the depth buffer for things in the “background” or “fixed” bins, because they want things in these bins to appear behind or in front of the rest of the scene, and they don’t want the depth buffer interfering with that. Note that this trick only works if the items you’re drawing don’t require the use of the depth buffer to draw themselves correctly (i.e. they’re flats or otherwise not self-occluding).

Note that you can also create your own bins, or change the sort values of these default bins, if you want.

David