Help with setting up off screen buffer

I am attempting to create an off screen buffer to create a glowing effect. I plan on applying a shader to certain nodes on an offscreen buffer and compositing the camera for the off screen buffer with the main camera.

    winX =
    winY =
    self.dr =

    winprops = WindowProperties.size(,
    fbprops = FrameBufferProperties()
    self.buffer = base.graphicsEngine.makeOutput(
        base.pipe, "depth buffer", -100,
        fbprops, winprops,
    self.depthTex = Texture()
    self.colorTex = Texture()

        GraphicsOutput.RTMCopyRam, GraphicsOutput.RTPDepth)

    self.bufferCam = base.makeCamera(self.buffer, scene=render)

    self.filters = FilterManager(self.buffer, self.bufferCam)
    self.quad = self.filters.renderSceneInto(colortex=self.colorTex, depthtex=self.depthTex)
    self.quad.setShader(Shader.load(Shader.SL_GLSL, "sders/vertex.glsl", "sders/fragment.glsl"))
    self.quad.setShaderInput("tex", self.colorTex)
    self.quad.setShaderInput("dtex", self.depthTex)

how do I make the buffer render every frame? Also how can I view the buffer for debugging purposes? I have enabled show-buffers in the prc data. Any help is greatly appreciated!

In fact, the buffer is already being rendered every frame.

Use a convenient tool for this.

Ah, I see you have created your own window, this method will not suit you, you can assign a self.depthTex texture to any mesh, or use:


I see, ‘BufferViewer’ seems very helpful.
I’m assuming that calling ‘WindowProperties’ creates a new window?

How can I set up the buffer without creating a new window? I would like to be able to use ‘BufferViewer’

Sorry, I didn’t pay attention to the flag. If you haven’t created your own window after all, then this should work.

from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowProperties, FrameBufferProperties, GraphicsPipe, Texture, GraphicsOutput

class MyApp(ShowBase):

    def __init__(self):

        scene = loader.loadModel("models/environment")

        winprops = WindowProperties.size(,

        fbprops = FrameBufferProperties()

        self.buffer = base.graphicsEngine.makeOutput(base.pipe, 
                                                     "depth buffer",

        self.display_region = self.buffer.makeDisplayRegion()
        self.display_region.setActive(True) =
        self.depthTex = Texture()

        self.buffer.addRenderTexture(self.depthTex, GraphicsOutput.RTMCopyTexture, GraphicsOutput.RTPDepth)

        self.accept("v", base.bufferViewer.toggleEnable)

app = MyApp()
#self.accept("v", base.bufferViewer.toggleEnable) # work 
base.bufferViewer.toggleEnable() # not work 

Interestingly, the call itself does not work without binding to the event key. Does anyone remember how it used to be?

1 Like

I don’t remember offhand–but it could simply be that it only works after some aspect of initial startup has been completed.

In particular, I note that the buffer-viewer also seems to work if run via a “doMethodLater” call with a duration of 0–thus running pretty much as soon as may be, but after initial startup. Like so:

    taskMgr.doMethodLater(0, self.mew, "mew")
def mew(self, task):

However, under such circumstances, the variable(show-buffers true) in the configuration file is useless. I doubt that this is the intended behavior.

1 Like