Is it possible to make a 2D "clip plane"?


I need a “mask”-like transparent object to hide a model parented to aspect2d. Basically, an object that will hide what’s behind it on the aspect2d scene, but still show what’s on render. I want to use a Sequence to reveal more and more of the object underneath the mask (with scale intervals), but I’ve no idea how to make this mask. Is it possible?

I’ve tried transparent DirectGUI elements, cull bins, clip planes, etc but to no avail.


If I understood correctly, it should be possible to use a clip plane for this; perhaps this post of mine could help.

Another possibility could be to use a ScissorEffect, as in the following code:

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
from direct.interval.IntervalGlobal import LerpScaleInterval, Sequence

class Panda3DApp(ShowBase):

    def __init__(self):

        cm = CardMaker("square")
        cm.set_frame(-1., 1., -1., 1.)
        square_node = cm.generate()
        square = self.aspect2d.attach_new_node(square_node)
        scissor_controller = self.aspect2d.attach_new_node("scissor_controller")
        square.set_scissor(scissor_controller, Point3(-1., 0., -1.), Point3(1., 0., 1.))

        scale1 = (1., 1., .01)
        lerp_interval1 = LerpScaleInterval(scissor_controller, 1., scale1)
        scale2 = 1.
        lerp_interval2 = LerpScaleInterval(scissor_controller, 1., scale2)
        self.sequence = Sequence(lerp_interval1, lerp_interval2)

app = Panda3DApp()

Note that I’m not entirely sure if a scissor region is supposed to be controlled like this, but it seems to work.

If I understand the problem correctly, then you might have success with stencil rendering. Basically you would clear the stencil mask to 0x00, render your object and set the stencil mask to 0x01, then after rendering that, you show the scene using a StencilTestAttrib. I don’t have an example handy though.

Another possibility is to render your scene to a FBO, and attach the rendered scene to your object.
EDIT: Added a snippet for that: