AmbientLight strange behavior


When adding AmbientLight, I don’t see the colors of the object, they appear only when using a different color source. The same AmbientLight effect appears only on the shaded side of the object.
This is not entirely correct, because when we add AmbientLight we should get uniform coverage.

from direct.showbase.ShowBase import ShowBase

from panda3d.core import DirectionalLight, AmbientLight, LVector4

class Light(ShowBase):

    def __init__(self):
       , -10, 0)
        '''dlight = DirectionalLight('dlight')
        dlight.setColor(LVector4(1.0, 1.0, 1.0, 1))
        dlnp = render.attachNewNode(dlight)
        dlnp.setHpr(0, -60, 0)
        alight = AmbientLight('alight')
        alight.setColor(LVector4(0.2, 0.2, 0.2, 1))
        alnp = render.attachNewNode(alight)

        self.cube = loader.loadModel("cube")
        self.cube.setColor(LVector4(1, 0, 0, 1))

        self.sphere = loader.loadModel("sphere")
        self.sphere.setColor(LVector4(0, 1, 0, 1))

demo = Light()

sphere.egg.pz (106.2 KB)

cube.egg.pz (375 Bytes)


The diffuse color of a material will show up under normal lights, the ambient color of the material will show up under ambient lights.

To avoid this behaviour, set your ambient color to the same as your diffuse color in your material, or specify the base color instead (which affects ambient and diffuse).


The problem is that I did not use the material for export.


I honestly do not understand the work of the panda lately. I checked this code for 1.8.0, and a miracle occurred.


Looks like a bug. Panda disables lighting if only an ambient light is present. I’ll fix this for 1.10.1, which should be released soon.