I think that placing your sky-sphere into the “background” bin and disabling depth-writing (as you’re doing in the code-snippet that you posted) is wise–that should reduce issues related to depth and render-order.
So, could we perhaps see the code related to the sphere? Perhaps there’s something being done with it–either in its initial setup or in the logic implemented for it–that will provide a clue…
From what I understand “background” and “fixed” don’t use the depth buffer so you can safely disable depth write and depth test?
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).
If you are too lazy to go through and read the link I have given, then I place the text here.
Okay, could we see the code related to the ball, please? Specifically, any setup applied to it (e.g. loading the model, putting it in a bin, attaching it to “render”, etc.), and any later code that affects how it’s rendered.
Ah, okay–it’s semitransparent. Where transparency is used (outside of a few special cases), render-order will tend to become important: if the transparent object is rendered before something that should appear behind it, its presence in the depth-buffer may prevent that “something” from being rendered, causing whatever’s behind that to be visible.
For this reason, when Panda loads an object with transparency, the object is placed into a specific culling-bin named “transparent”. That bin renders after the default “opaque” bin, and in addition sorts its objects from furthest to nearest.
The result–ideally–is that opaque objects (having been already rendered) correctly appear behind transparent objects, and transparent objects correctly appear behind each other.
(In practice it’s not always that easy, especially with 3D transparent objects, but that’s the basic idea.)
However, your object is, I gather, not transparent when it’s loaded. As a result, it’s presumably placed into the aforementioned default bin–hence rendering issues.
What I suggest, then, is to simply place it into the “transparent” bin yourself.
(Noting that the second parameter to “setBin” is meaningless in the case of the “transparent” bin, despite the fact that it is nevertheless required; just put in whatever value you feel like.)