As shown, I want to add fog to the entire scene through cards and textures. But no matter how you set it, the pen cannot show the scene through the card, but the background color of the card. How do I clear the background of the card?
import random
from panda3d.core import *
from direct.directbase import DirectStart
scene = loader.loadModel("scene")
scene.reparentTo(render)
scene.showTightBounds()
mina,minb = scene.getTightBounds()
disVec = minb - mina
center = (mina + minb )*0.5
veilColor = 0.2
imgSize = 32
img = PNMImage(imgSize, imgSize)
img.fill(veilColor)
tex = Texture()
tex.load(img)
cd = CardMaker('square')
cd.setFrame(mina.x, minb.x,mina.y , minb.y)
cd.setColor(1,1,1,0.2)
card = cd.generate()
spuare = render.attachNewNode(card)
#spuare.setTransparency(True)
spuare.setP(-90)
spuare.setPos(0,0,120)
brush = PNMBrush.makeSpot((1,1,1,1), 3, True)
painter = PNMPainter(img)
painter.setPen(brush)
veilTS = TextureStage('')
spuare.setTexture(veilTS, tex)
spuare.setTexGen(veilTS, RenderAttrib.MWorldPosition)
spuare.setTexScale(veilTS, (1/disVec[0],1/disVec[1]))
spuare.setTexOffset(veilTS, -0.5+center[0]/disVec[0], -0.5-center[1]/disVec[1])
panda = loader.loadModel("panda")
panda.setScale(10)
panda.reparentTo(render)
pos = panda.getPos().xy - mina.xy
pos.x /= minb.x-mina.x
pos.y /= minb.y-mina.y
painter.drawPoint(pos.x*img.getXSize(), (1-pos.y)*img.getYSize())
tex.load(img)
base.run()