I’ve encountered this bug many times in the past, but never taken the time to nail it down. The bug is this: flats created by CardMaker (and perhaps other flats as well?) are lit differently based on other objects in the world moving on and off screen. More recently I’ve seen this behavior simply from other objects moving around, and not actually going off screen.
This bug is only exhibited in OpenGL mode (and I’ve only tested on Windows), although DirectX seems to have its own problems with lighting.
Here’s some sample code:
import math
import direct.directbase.DirectStart
from direct.showbase.ShowBaseGlobal import *
class World( DirectObject.DirectObject ):
def __init__( self ):
base.mouseInterfaceNode.setPos( 0, 20, -2 )
base.setBackgroundColor( Vec4( 0 ) )
self.accept( "f9", base.screenshot )
self.teapot = loader.loadModelCopy( "teapot" )
self.teapot.reparentTo( render )
cm = CardMaker( "cm" )
self.card = NodePath( cm.generate() )
self.card.setScale( 4, 1, 4 )
self.card.setPos( -2, 0, 0 )
self.card.reparentTo( render )
self.ambientLight = AmbientLight( "ambientLight" )
self.ambientLight.setColor( Vec4( 0.2, 0.2, 0.2, 1.0 ) )
self.ambientLightNodePath = render.attachNewNode( self.ambientLight.upcastToPandaNode() )
self.directionalLight = DirectionalLight( "directionalLight" )
self.directionalLight.setColor( Vec4( 0.5, 0.5, 0.5, 1 ) )
self.directionalLightNodePath = render.attachNewNode( self.directionalLight.upcastToPandaNode() )
self.directionalLightNodePath.setHpr( -40, -50, 0 )
self.pointLight = PointLight( "pointLight" )
self.pointLight.setColor( Vec4( 0.5, 0.5, 0.5, 1 ) )
self.pointLightNodePath = render.attachNewNode( self.pointLight.upcastToPandaNode() )
self.pointLightNodePath.setPos( -5, -5, 3 )
render.setLight( self.ambientLightNodePath )
render.setLight( self.directionalLightNodePath )
render.setLight( self.pointLightNodePath )
taskMgr.add( self.circleTask, "circleTask" )
def circleTask( self, task ):
self.teapot.setPos( 10.0*math.sin( task.time ), 10.0*math.cos( task.time ), 0 )
return Task.cont
world = World()
run()
When running the code, the square is lit more brightly when the teapot moves past the right edge of the screen:
and is lit more darkly when it is not past the right edge of the screen:
I’m not sure why it only happens based on the right edge. I’ve seen it occur at other times when objects have gone off other sides of the screen.
This occurs for both the PointLight and the DirectionalLight (you can comment each out independently).
Anyone have any ideas?