Light problem


I have some problem with lighting model. I loaded model in panda and look some bad things

So, we have problems with edges of triangles. This is code:

    scene = loader.loadModel("mymodel.egg")

    dlight = DirectionalLight('dlight')
    alight = AmbientLight('alight')
    dlnp = render.attachNewNode(dlight.upcastToPandaNode())
    alnp = render.attachNewNode(alight.upcastToPandaNode())
    dlight.setColor(Vec4(0.8, 0.8, 0.8, 1))
    alight.setColor(Vec4(0.2, 0.2, 0.2, 0.1))
    dlnp.setHpr(-45, -45, 0)

Can you explain me how works directional light? I try many other models with flat textures…

I’m not sure… or maybe even totally wrong… but I think a model like that (very low poly) will always look strange in a per vertex lighting mode. Try per pixel lighting:


Or test your model in pview (hit “L” to enable lighting, and then “P” to turn on per-pixel lighting)

But before you take any advice from me, take a good look at my signature :wink:

try to open it in pview(search the manual or the forums for it)

btw it’s a common issue

Naww, it’s just bad normals. Your model has vertex normals, but you want to have polygon normals (also called face normals) for a model like that. Vertex normals are only appropriate for curved geometry.

The right thing to do is to create the normals properly in your modeling package, but you can also have Panda compute polygon normals with the command-line tool egg-trans:

egg-trans -np -o newmodel.egg mymodel.egg

And then load up newmodel.egg instead.


David, this works. Thanks! And thanks everybody!