Glow and display regions

Hey everyone,

This bit of code replicates a problem that occurs in my game, switching back and forth from split screen to single screen. It worked well until I added glow to it. The glow seems to mess up the display regions.

from direct.showbase.DirectObject import DirectObject
import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.filter.CommonFilters import CommonFilters

class World(DirectObject):
    def __init__(self):
        self.accept('space', self.stepScreens)
        self.screens = 1
        self.model = loader.loadModel('model')
    def stepScreens(self):
        if self.screens == 1:
            self.screens = 2
        elif self.screens == 2:
            self.screens = 1
    def addScreen(self):
        #stuff that works
        cam2node = Camera('cam2')
        self.cam2 = NodePath(cam2node)
        self.cam2.setPos(0, 0, 0)
        self.rtop =
        self.rbottom =, 1, 0, 0.5)
        self.rtop.setDimensions(0, 1, 0.5, 1) / float(self.rtop.getPixelHeight()))
        self.cam2.node().getLens().setAspectRatio(float(self.rbottom.getPixelWidth()) / float(self.rbottom.getPixelHeight()))
        #stuff that doesn't
        self.filters = CommonFilters(,
        self.filters.setBloom(blend=(0,0,0,1), desat=0, intensity=1.0, size="small")
        self.filters2 = CommonFilters(, self.cam2)
        self.filters2.setBloom(blend=(0,0,0,1), desat=0, intensity=1.0, size="small")
    def removeScreen(self):
        #stuff that doesn't work
        #stuff that does
        self.rtop.setDimensions(0, 1, 0, 1) / float(self.rtop.getPixelHeight()))
w = World()

To run the code you will need any model (it just has to be named “model”) in the same location as the program. The default camera controls are still enabled, so you can look around and see what is happening.

EDIT: I suppose I should clarify. While running the program, press space to switch from one display region to two display regions. After switching back and forth several times, the display regions start getting messed up.

Has anyone seen something like this before?

Thanks in advance.

I’ve been working on this, but I still haven’t found a solution. Here is a video of what I get:

Does anyone know how to fix this?

It looks like you lost the depth buffer in the bottom DisplayRegion. Maybe you should ensure it is explicitly cleared with self.rbottom.setClearDepthActive(True)?

You also might do better by simply creating two DisplayRegions up front and setting the one active or inactive, instead of constantly destroying and creating them.


Thanks! Got all the problems fixed for now. :smiley:

I think I will probably pursue this approach as a more permenant fix; it seems much simpler and more reliable.