I am making a game for a class at school using Panda 3D, and one part of our level is outside in a grassy area, supposed to be sunny, etc. I am having some trouble on how to simulate the light, so it is sunny outside, just how you would picture it on a sunny day… I keep messing around with what the manual gives but to no avail… does anyone have any samples/experience with this?
# ambient light
self.ambientLight = AmbientLight( "ambientLight" )
# set the numbers here for Red, Green, Blue for light color
self.ambientLight.setColor( Vec4( 0.7,0.7, 0.7, 1 ) )
# add ambient light
self.lightAttrib = self.lightAttrib.addLight( self.ambientLight )
# sun light
self.directionalLight = DirectionalLight( "sunLight" )
# set the numbers here for Red, Green, Blue for light color
self.sunLight.setColor( Vec4( 2, 2, 2, 1 ) )
# set the direction the sun light shines in
self.sunLight.setDirection( Vec3( 1, 1, -2 ) )
# add sun light
self.lightAttrib = self.lightAttrib.addLight( self.sunLight )
Thanks for the excellent examples. FYI, the LightAttrib interface is deprecated; you should try to migrate to using the new interface instead. The new interface just uses NodePath.setLight() to enable a particular light, and doesn’t mess around with LightAttribs at all, e.g.: