StandardError in Glow Effect

Hello,

I’m trying to implement a glow effect based on the basic glow effect tutorial. Here’s what I’m getting:

StandardError: Could not find appropriate DisplayRegion to filter.

Here’s the code that causes this error:

def highlightActor(self,actor):
 if (base.win.getGsg().getSupportsBasicShaders() == 0):
  print "Video driver reports that shaders are not supported."
  return
 filters = CommonFilters(base.win, base.camera)
 filters.setBloom(blend=(0,0,0,1), desat=-0.5, intensity=3.0, size="small")

The error is launched from FilterManager.py (C:\Panda3D-1.6.0\direct\src\filter\FilterManager.py):

class FilterManager(DirectObject):

    def __init__(self, win, cam, forcex=0, forcey=0):

        """ The FilterManager constructor requires you to provide
        a window which is rendering a scene, and the camera which is
        used by that window to render the scene.  These are henceforth
        called the 'original window' and the 'original camera.' """

       ...
       ...

        region = None
        for i in range(win.getNumDisplayRegions()):
            dr = win.getDisplayRegion(i)
            drcam = dr.getCamera()
            if (drcam == cam): region=dr

        if (region == None):
            self.notify.error('Could not find appropriate DisplayRegion to filter')
            return False

From what I read in that file, the camera must be used in that window.
Hence I checked my code, and I’m using another camera:

         ######################################################
        # This world uses the default camera base.camera or camera as it is aliased
        # In order to get object picking we have to use this other camera.
        #
        ######################################################
        self.camera = base.makeCamera(base.win)

        self.camera.node().copyLens(base.cam.node().getLens())
        self.camera.node().setActive(0)
        self.camera.reparentTo(self.headNodeOfWorld)

However, using this camera isn’t working either.

Any ideas? Thanks for helping!!!

Try base.cam instead of base.camera. Base.camera is just an ordinary NodePath, while base.cam is the actual NodePath pointing to the Camera instance. In this case, you’ll need the latter.

Actually the problem was something else.

I was calling the filters = CommonFilters(base.win, base.camera) over and over… once I moved that piece of the code to my class’ constructor, it stopped.

However, I still don’t have a glow effect. As far as I can see in the example, I can’t find any place where you link the effect to the scene graph. (Other than the camera in the CommonFilters constructor).

How do I apply a filter to only a model? And, does the model needs to be prepared in advanced, by the modeler or the texture artist?

Thanks!

to only make models of your choice glowable, you need to give the cameras different bitmasks. then telling your glowable nodes to be shown through these bitmasks.

base.cam.node().setCameraMask(BitMask32(1))
glowCamera.node().setCameraMask(BitMask32(2))
model1.hide(BitMask32(2))
model2.showThrough(BitMask32(2))

i didn’t test the code above, but it should work like this

I’m trying this now.

Thanks!

Allright… now something happens.

I get a black screen whenever the glow effect should be displayed.

I’m still looking into that.

EDIT: K, i created a new glowCamera but nothing happens. I don’t understand why there are two cameras.

sorry, i didn’t realize you are working with the basic glow sample.
i don’t know how the commonFilter stuff works…
i used the advanced glow sample.
there, you basically just setup a glowcamera with a shader on it and then the things “seen” by the glowcamera get rendered into a blurred texture which is reparented to render2d.

so you can tell different nodepaths to be seen/not seen by the glowcamera (like in the code above).

Kampfgnu

I switched to the advanced glow example and have made some progress.

I’m now stuck at selecting which of the two trons are going to glow. One of the trons always glow.

I’m attaching my code if anyone wants to test it.

Here’s the link: http://sites.google.com/site/dornad/Home/glow.zip?attredirects=0

Thanks!