lighting problem

Started by IZACIZAC, January 20, 2014, 11:12:09 PM

Previous topic - Next topic

IZACIZAC

Hi, I have a textured model and a light in my scene

level.compileAndStrip();
l = new Light(world);
l.setAttenuation(800);
l.setIntensity(200, 200, 200);

my light follows my camera
l.setPosition(camera.cam.getPosition());



I found though that because I was using one single poly for a huge wall, when I went near the center the wall lost all light, presumably because of how vertex lighting works, no light reached any of the corners.



So I split my wall into several individual peices (seperated by the beams running either way). attenuation is set to -1 in this screenshot. The result was fine for the middle parts, but the bottom and top row seem to be working the opposite way? Points nearest the camera, and so light source, are darkest?

(Also, does JPCT triangulate models when you load one in?)

EgonOlsen

That's also caused by the way in which vertex lighting works. It calculates the light's intensity based angle between the vertex normal and the vector from the vertex to the light. The vertex normal is usally calculated when calling build() based on the average of the surface normals of adjacent faces. Depending on the structure of the mesh, this can look sub-optimal in some cases. If you have normals assigned (or calculated) in your modelling program, you can export as OBJ and set http://www.jpct.net/doc/com/threed/jpct/Config.html#useNormalsFromOBJ to true before loading the file. That will skip jPCT's own calculation and use the normals from the file instead.

Edit:

QuoteAlso, does JPCT triangulate models when you load one in?
Nope, it doesn't.

IZACIZAC

#2
Oh I see, thanks. Importing then re-exporting from Blender gave it perfect normals