Display Region Sorting

I am trying to render a weapon model as part of my HUD, using a new display region with a new camera. Here’s my code:

self.m_HudDR = base.win.makeDisplayRegion()

self.m_HudCamera = NodePath(cam)

self.m_HudScene = NodePath('HUD Scene')


My weapon model gets reparented to self.m_HudScene. This is where I TRY to change the region sorting, but I get the most confusing results.


Region 1 seems to be the main camera.
Region 2 seems to be the 2d render area.
Region 2’s sort won’t go higher than 10. Only if I set the hud region to 10 does it get rendered over region 1, but then it also renders over my GUI.
I say ‘seems to be’ because I’ve found that there’s about 7 regions, including my hud region, with getNumDisplayRegions().

Anyone have any ideas or a different approach? I’ve tried camera masks and bins with no luck.

I’m betting your problem is the depth buffer. If you don’t clear the depth buffer on your new display region, then everything you draw there won’t be visible if it appears to be “behind” the stuff in the main display region.



Incidentally, you should certainly be able to change the sort order of render2d. You can check which DisplayRegion you’re looking at by calling dr.getCamera().


Hmmm, I did read about setClearDepthActive in the manual, should have tried it, but it could have been explained better. The manual says clearDepthActive.

Anyway, it worked, thanks.