Hi all,
I have a problem with display regions and CommonFilters.
I create two display regions, splitting the screen in two halfs. Then I add a third region and change the dimensions of the second one to get free space for the new one. No problem so far, but if I add a Shader with CommonFilters and change the dimensions of the region after that, it doesn’t seem to have an effect. The new region overlaps the old one. I uploaded an image which shows the problem.
On the left window everything works fine without shaders, on the right window I added a blur shader and somehow the regions are not updated:
Below is the code, which produced the above output. I think I have to tell the CommonFilter object that the regions have changed, but I’m not sure how to do that. I tried it with filters.cleanup, filters.reconfigure and filters.update, but none of them worked.
# -*- coding: utf-8 -*-
from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
from direct.filter.CommonFilters import CommonFilters
class App(ShowBase):
def __init__(self):
ShowBase.__init__(self)
base.camNode.setActive(False) #disable default cam
# add a model to the scene
panda = loader.loadModel("models/panda-model")
panda.reparentTo(render)
panda.setZ(-280)
panda.setY(1300)
# create the first region
region1 = base.win.makeDisplayRegion(0, 0.5, 0, 1)
cam1 = NodePath(Camera('cam1'))
region1.setCamera(cam1)
cam1.reparentTo(render)
# create a second region
region2 = base.win.makeDisplayRegion(0.5, 1, 0, 1)
cam2 = NodePath(Camera('cam2'))
region2.setCamera(cam2)
cam2.reparentTo(render)
# add the filters
filters1 = CommonFilters(base.win, cam1) # for the 1st cam
filters1.setBlurSharpen()
filters2 = CommonFilters(base.win, cam2) # for the 2nd cam
filters2.setBlurSharpen()
# now change the region of the 2nd cam <- and here is the problem
cam2.node().getDisplayRegion(0).setDimensions(0.5, 1, 0.5, 1)
# mabe here I should update the CommonFilter objects
# add a 3rd cam / region
region3 = base.win.makeDisplayRegion(0.5, 1, 0, 0.5)
cam3 = NodePath(Camera('cam3'))
region3.setCamera(cam3)
cam3.reparentTo(render)
# -----------------------------------------------------------------------------
app = App()
app.run()
Any ideas?
thanks in advance,
Carsten
PS: here the link to the CommonFilters Documentation: http://www.panda3d.org/reference/python/class!filter.CommonFilters.CommonFilters