Logical Lighting

Hi. For some reason, when I set up a directional light, my Actor stays bright on one side and dark on the other side. This is not logical according to light. If the Actor is bright on the front side and then turn around to face the other direction, the Actor’s back side should now be the bright side, since it is facing into the light.

I don’t know if this is a Panda problem or maybe some of my settings in the blender file were wrong before exporting (don’t thing so though). This is not an ambient light issue either. I’ve tried re-parenting the light to different things, but no avail.

I’ve tried adjusting the angle of the light…everything. What’s even more strange, is the fact Roaming Ralph does it right. Little Ralph looks like he’s receiveing light correctly. I have the same light codes and everything, but no logical object lighting.

Sounds like a normals issue to me. Or maybe you have doubles on your model?

No. I recalculated Normals and removed all doubles. None.

Can you upload a demo model?

I wonder if Faces that share UV cords would cause such a problem?

Nope. Tested this too.

I’m thinking it’s an angle of light issue, but I’ve tried all kinds of Vec setttings. The reason I say this is because, when the Actor bends forward, the light actually brightens the backside of the Actor; but when standing up straight, the Actor’s back is dark again…and seems dark no matter which way I face it, unless it’s bending foward or something.

I can tell the angle of the Actor’s back when bending foward works with the angle of the light…that’s why it gets lit up…then.

People in real-life don’t look black on one side, then light on the other side. Lol. I might have to use an old 3-point light method and forget about it. Doesn’t look like I’m going to solve this one.

When you attach the light node, did you attach it to render or to the actor
I mean:

#not dl=actor.attachNewNode(dl)

#not actor.setLight(dl)

Be sure that you didn’t reparent it to actor orelse the light node will be a child node to it and follows actor in rotation and position

D_A_M_H’s observation is the relevant one here–what you describe is precisely what happens when you parent the light to the actor. In this case, the light is rigidly attached to the actor, as if it were on a pole that’s attached to his waist, so wherever he turns, the light turns with him, and always illuminates the same side of him.

However, let me clarify an important detail:

#not dlnp=actor.attachNewNode(dl)

This is good advice: you generally want the lights parented to render, not to the actor. The node that the lights are parented to is the node that controls where the lights are positioned.

#not actor.setLight(dl) 

This is irrelevant in this case: the node that you call setLight() on has nothing to do with the position of the light. Instead, this controls the node(s) on which the light has an effect. But still, for most intuitive purposes, you do generally want to use render.setLight(), because you expect a light to illuminate everything in the world, not just specific objects.


Oh, so you actually parented it to the actor? If you want your node to be illuminated by a light, you should use node.setLight(lightname)
Since every actor should be child or child of child of render, you can do render.setLight(lightname)
parenting has nothing to do with it.

Also, directional lights have no position, in case that was why you parented it to the actor.

No, I reparented to render

directionalLight = DirectionalLight('directionalLight')
        directionalLight.setColor(Vec4(0.8, 0.8, 0.8, 1))
        directionalLight.setDirection(Vec3(-180, -45, -135));
        directionalLightNP = render.attachNewNode(directionalLight)

I think it’s just that one directional light isn’t going to get you that out door sunny world look. I did a test where I made a point light of small radius move around my Actor. The Actor changed shading according to the light’s position around it, so that proves it’s not a modeling issue.

This also tells me light will create logical shading in an indoor setting where you have point lights or spot lights setup. The issue is the out door world lighting. Directional lights are made just for that, at least in other Engines I’ve used.

Panda’s directional lights doesn’t seem to fill the ambience around things with light well, and only brightens some surfaces when they are facing on an angle which causes a direct strike by the light.

Things look much more “outdoors”, light wise, when I use the old 3 point light tech.

In the end…I guess no free graphic Engine is perfect.

Panda’s directional light map one-to-one with OpenGL’s directional light, or DirectX’s directional light, or any other engine’s directional light. It models a light that is infinitely far away, but otherwise illuminates according to the same rules as a point light. It’s true it doesn’t illuminate the back side of surfaces at all, but then neither does a point light; that’s what an ambient light is for.

I don’t know what troubles you’re having with your model’s transform not changing the light’s direction. There’s nothing special about a directional light (as opposed to any other light) that would make it ignore a transform. Can you write a simple program that demonstrates the problem you are seeing and post it here?

Do you use ambient lights?
Do you use per pixel lightning?
posting sample code will really help.

Yeah, I use Amb light. Amb Light just makes it so that dark areas aren’t pitch black.
Any object that faces light in real life become brighter on that side (the facing side). This is poorly done in the Panda Engine and it’s evident without argument.

Play the free MMORPG called Perfect World. That Engine does it right. (as well as a lot of them)

The old 3 point lighting tech used by CG artists seem to work well for outer environments, so I’m using that. Too much Amb Light tends to make things look un-real. :slight_smile:

To answer the other question, the issue is the same with per-pixel or not.

its not done in Panda, its done in OpenGL and DirectX, panda simply checks what renderer you chose and runs the corresponding OpenGL or DirectX commans. So I have no idea what you mean. This isnt evident because you havent posted sample code and models as we asked, so the argument continues. I know with my code i have no problem with Directional lights.

Play the free MMORPG called Perfect World.  That Engine does it right. (as well as a lot of them)

Just about any OpenGL or DirectX game without shaders does it the same.