Multipe Render Targets

Hi all!

I’m new around here, and I’m also new to Panda3D. In the short I’ve been using this engine, I must say I’m quite impressed.

I was wondering if it’s possible to have multiple render targets in Panda3D. I’ve read the manual’s filter manager section, but that is just one part of what I’m looking for.

What I need to do is to return different colors, from a fragment shader, to different buffers. Right now my fragment shader returns a color using the variable o_color, so I was wondering if o_color1, o_color2…o_colorn (where n is the maximum number of MRT’s the video card supports) exist in Panda3D.

The effect I’m trying to achieve is the “accumulation of a mask”. That is modifying a texture that is being passed to the fragment, and that in some way the texture retains its value the next time it is passed as parameter to the same fragment shader.

Thank you very much,

Yes, this is very well possible in Panda. It just means you need to attach a render target to RTPAuxRgba0, RTPAuxRgba1, etc., and have an output (o_anything) in your pixel shader bound to semantic COLOR1, COLOR2, etc.

The Fireflies sample program is a fine example of MRT - take a look at it.

Thanks for the answer!

I’ve been playing around with off-screen buffers by looking at the fireflies example as pro-rsoft suggested.

I’m creating the buffer by calling base.graphicsEngine.makeOutput. Then I’m adding a render texture to the buffer in RTPAuxRgba0.

Aftewards, in the fragment shader, I’m declaring “out float4 o_maskColor : COLOR1”, and returning “o_maskColor = float4(1.0f, 0.0f, 0.0f, 1.0f);”

I’m using the buffer viewer and I can see that the render target apparently has been created, since I can see how calls to setClearColorActive() affect one of the buffers being displayed. What I can’t figure out is why “o_maskColor = float4(1.0f, 0.0f, 0.0f, 1.0f);” in my fshader, is not affecting the buffer in question.

What can I be doing wrong?

Does the main buffer, the buffer to which semantic COLOR0 applies, counts as RTPAuxRgba0? I mean, should I attach my render texture to RTPAuxRgba1 instead of RTPAuxRgba0? (I already tried this, but still nothing draws to my off-screen buffer).


I was up last night struggling with my ludum dare entry. Didn’t finish it but I did get the auxillary RGBA buffer working thanks to the hints from this thread. The following should be the minimum amount of code needed to start and use auxillary buffer. Did you put props.setAuxRgba(1) in your offscreen buffer creation code? Thats what was tripping me up last night. To output to AuxRgba0, the output has to be to COLOR1, it doesn’t matter if your first colour output goes to COLOR0 or COLOR.

class Shader:
    '''Manages the setup of the shadow shader'''

    def __init__(self):
        self.shadowBuffer = self.createOffscreenBuffer(2, 1024, 1024, True)
        self.shadowScene = Texture()
        self.shadowTest = Texture()
        self.shadowBuffer.addRenderTexture(self.shadowScene, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor)
        self.shadowBuffer.addRenderTexture(self.shadowTest, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba0)

        # Setup shader/scene here

    def createOffscreenBuffer(self, sort, xsize, ysize, auxrgba=False, engine=None):
        winprops = WindowProperties.size(xsize,ysize)
        props = FrameBufferProperties()
        if auxrgba:
        if engine:
            return engine.makeBuffer(, "offscreen buff", sort, xsize, ysize)
        return base.graphicsEngine.makeOutput(
            base.pipe, "offscreenBuffer",
            sort, props, winprops,