Hello, I have a problem when I try to use shadows and buffers contemporaneously. I have the following code (here there are code and assets if you want to reproduce):
import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import Spotlight
class World( DirectObject ):
def __init__( self ):
base.disableMouse()
camera.setPos( 0, -20, 2 )
self.accept( 'mouse1', self.destroyAndCreate )
render.setShaderAuto()
self.create()
def create( self ):
self.rootNode = render.attachNewNode( 'rootNode' )
self.light = self.rootNode.attachNewNode( Spotlight( 'Spot' ) )
self.lightNode = self.light.node()
self.lightNode.setShadowCaster( True, 1024, 1024 )
self.light.setPos( -20, -20, 20 )
self.light.lookAt( 0,0,0 )
self.rootNode.setLight( self.light )
loader.loadModel( 'teapot' ).reparentTo( self.rootNode )
self.buffer = base.win.makeTextureBuffer( 'Buffer', 512, 512 )
self.camNP = base.makeCamera( self.buffer )
self.camNP.reparentTo( self.rootNode )
def destroy( self ):
self.lightNode.setShadowCaster( False )
self.rootNode.removeNode()
base.graphicsEngine.removeWindow( self.buffer )
def destroyAndCreate( self ):
self.destroy()
self.create()
w = World()
run()
This is a simple program which shows the problem. This shows a teapot and when the user clicks it should reload the scene. The problem is that at the beginning the illumination works, but, after the click, the teapot becomes completely black. My objective is to get the illumination working also after the destruction and recreation of the scene.
Another strange thing is that, when I click, on the console it prints the character d.
Note that if I remove the shadows or the buffer (the buffer in this example is useless, but in my larger application I need it) it works.
Where am I wrong? Thank you!