Strange Point Light Behavior

I am currently working on a small game.
I have a room with a point light.
There seems to be two issues with it.

  1. Walls (not floor tiles) that are far away from the point light are as bright as the center of the point light.
  2. When activating inverse-square law lighting the point light (attenuation’s 3rd vector value !=0) deactivates completely and displays as if I didn’t add it at all.

The lighting gets initialized in here:

def light(self):
    # Create Ambient Light
    ambientLight = AmbientLight("ambientLight")
    ambientLight.setColor((0.1, 0.1, 0.1, 1))
    ambientLightNP = self.render.attachNewNode(ambientLight)       
    self.lightModel = self.loader.loadModel(self.basedir + "/rsc/models/light.bam")
    self.lightModel.setPos(32, 32, 32)

    plight = PointLight("plight")
    plight.setColor((0.5, 0.5, 0.5, 1))
    plight.setAttenuation((1, 0, 1))
    plnp = self.lightModel.attachNewNode(plight)

And I when adding the models I change the texture like this:

self.model.setTexture(self.model.find texture_stage('*'), self.texture, 1)

Not sure if this makes a difference but it’s the only non standard change I apply to my models.

Hmm, I’m not sure, but I like to set attenuation on point lights like this:

p_light.set_attenuation((0.5, 0, 0.0000005))

1 Like

Thanks for the quick repy.
Your exact values didn’t help with problem 1.
However after a bit of try and error with the values I found out that (0.5, 0, 0.00005)
fixes both problems.
Seems I misunderstood how the attenuation values effect the light.
Especially since the tutorial suggests using (1, 0, 1).

1 Like

The format of set_attenuation is set_attenuation(constant, linear, quadratic) in coefficients. Not sure if that helps you understand better what’s going on. My impression is that the manual info on this is more theoretical than practical.

1 Like

With regards to this problem, I think that this stems from two things:

  1. The fact that there was no attenuation
  2. The angles involved.

Without attenuation, the light has full intensity regardless of distance.

Now, one might then expect a similar spread of light on any surface. However, the final light-value on a given surface is a function not only of attenuation, but also of angle with the surface. The closer to ninety degrees (i.e. directly “into” the wall), the higher the value; the closer to zero degrees (i.e. a glancing contact), the closer the value is to zero.

Furthermore, the closer a point is to a surface, the more quickly the angles become close to zero. As a result, a nearby surface–like your floor, I imagine–receives only a small spot. Conversely, a distance surface, having similar angles across a large area, receives a large region of high light-values.

When attenuation is in effect, this isn’t all that useful, as distance also decreases light-value. But without that, the only thing affecting that value is angle, and so distant walls end up brighter than floors just a few steps away.

1 Like