Lighting problem on 2 Object3D side by side

Started by Pignic, November 15, 2012, 10:40:55 AM

Previous topic - Next topic

Pignic

Hello,

I have a strange light effect when I place two objects side by side as in this image :



My light source :

final Light sun = new Light(world);
sun.setIntensity(50, 55, 60);
sun.setDiscardDistance(3000);
sun.setPosition(new SimpleVector(500, 500, 2700));


My config of lights :

Config.lightMul = 1;
Config.fadeoutLight = false;
world.getLights().setRGBScale(Lights.RGB_SCALE_2X);
world.setAmbientLight(131, 138, 154);
world.getLights().setOverbrightLighting(Lights.OVERBRIGHT_LIGHTING_DISABLED);


What I put on all the objects to have a lighting effetc :

wall.build();
wall.setSpecularLighting(true);
wall.setLighting(Object3D.LIGHTING_ALL_ENABLED);


On this image, there are 6 objects : 3 angles and 3 walls.

Can anyone help me or tell me if I forgot some parameters ?

Thanks and best regards.

EgonOlsen

That's normal behaviour. Lighting is based on the vertex normals, which are based on an average of the surface normals of adjacent polygon of the same object. For example:



As you can see, the two normals n1 and n2 point in different directions. If you move these objects closer together, the difference in lighting that this causes will be noticable. See that n1 points towards the light, i.e. the vertex will be lit pretty well, while n2 points to the side, which makes that vertex less bright.
You can minimize this effect by increasing the polygon count of the objects. You can also try to model the objects in a modeller with different normals assigned and use the beta version of jPCT, which supports loading of normals from OBJ format. However, this might help in the case shown above but it won't in your case, because you can combine the objects in so many different ways that it's impossible to setup the normals in a way that they always fit.
I would go with more polygons first and see if it looks good enough.