Some lighting questions

Hi, I just started trying out the lights and I a few issues to ask about.

  1. I created a scene with a model, some ambient light, and a directional light shining on the model. When the model is not moving it looks fine, but when I set a task to spin the model, the lighting on the model flickers as each polygon suddenly switches from non-lit to lit and vice-versa. Is there any way to correct this problem?

  2. Every time I run a scene with lights I get this message:

What does this mean?

  1. I see that in Panda, OpenGL lights are much faster than Direct X lights. Is this because OpenGL has better lighting, or because Panda has better OpenGL support?

  2. At least on my computer, something is wrong with the spot light in the disco light tutorial. In 1.3.2 it looked like it does on the screenshot, but now instead of a smooth circle it’s jagged around the edges, again making the wall polygons obvious.

Is this a bug?

Hard to guess from the description, but this might be a simple problem of not having enough vertices in your model. In general, standard hardware lighting works by computing the lighting equation at each vertex, and then linearly blending the result between the vertices. This means that if your model consists of relatively large polygons with few vertices, the lighting calculation will be relatively inaccurate, and as vertices move toward and away from your light source, the whole thing will tend to flicker.

You are copying old sample code that is using an old, deprecated Panda interface. You should not be creating LightAttribs explicitly any more. Instead, you should use the much simpler nodePath.setLight() interface to turn on a particular light, as described in the manual.

I never heard of that before. OpenGL lights should be fundamentally similar to DirectX lights, though there are subtle differences. It is possible, in a very sparse scene where you are getting many hundreds of frames per second, that you will see a very minor difference between the two appear to get exaggerated into a very major difference because there is nothing else in the scene. (For instance, one might render at 600 fps, and the other at 400, but really you’re only talking about a difference of less than a millisecond.) Is this what’s happening, or are you seeing some real differences?

This sounds like the too-few-vertices problem again. I don’t know about this demo in particular, but we did recently change the formula for calculating the penumbra of a spotlight, to make it more similar between OpenGL and DirectX. It may be that the original demo had been written to look good with the old calculation, but needs to be adjusted to look good with the new calculation. Of course, adding more vertices to the wall might be an even better solution.