Totally weird lighting problem

i have a rootnode, pointlight at 3000/3000/3000. center of my terrain is 0,0, at which point it is 255 "jme units" high. if i add a house (3ds model), the house is tiny.

if i scale it up to a proper size, it's big enough, but it gets reeeaaaaaaly dark. the side that points towards the light source is still brighter than the other side, but what is white at size 1 gets dark grey at size 150. what is happening here?

When you rescale a model, the normals are scaled with it… What you need to do is re-normalize the normals (I know it sounds like a cacophony)

Actually, the default behavior for normals is to auto-renormalize during rendering if the scale is not 1,1,1.  (You can change this behavior if you wanted to with the wonderfully undocumented method SceneElement.setNormalsMode(int))



What is likely happening is that your building is just getting bigger relative to the light.  Try placing a small sphere at the light's location and see if things look 'right'.  You might also try using a directional light instead of a point light (especially if you are using the light as a "sun" or "moon")

how a directionallight works is beyond my imagination. i'm using a point light right now which is pretty far away and it looks good.

I was just wondering, is there a way to change the intensity of the PointLight? The Javadoc doesnt' say much.  :?

overriding the normals mode (even for all children) didn't change anything

I didn't think it would.  After all, as I said, the default behavior is to rescale the normals anyhow.  Again, try a directional light.  Basically it's as if you had a light source infinitely far away in a particular direction.

how can its rays be parallel if i define a point where they are coming from? or do i define a point that is relative to every point of my triangles? (i tried it, didn't solve the problem)



@topic:

while playing around, i notices that sometimes, i'm not sure why and when, but for a short moment (maybe it depends on my position) the lighiting is correct. then, a moment later, it's too dark again. i noticed the same problem with some (milkshape) grass models. also weird: either all or no models are too dark. its as if ther is an invisible light switch.


With directional light you don't define the point it comes from, you define the direction it goes to… in other words, it is a Point what you provide, but think about it as a Vector.

the problem does not appear when simply loading a model in simplegame and rendering it…

could there be one of those updateXY-calls missing?



i don't see any differences betwen my method of rendering and the simplegame ones



found it:

p_spatial.lock();



but why is it wrong to lock my objects, even if they all share the same size? shouldn't i be able to lock a spatial after scaling it without screwing up the lighting?

not locking my spatials in not acceptable (speed-wise). cloning every object and recalculating the normals isn't acceptable as well because of the memory requirements.



when exactly are the normals re-normalized? do i have to do something with my spatials between scaling and locking them?

locking creates a display list.  If you rescale after locking, the normalization portion of the code is not accessed.

so i need create a copy of every model for each size i want to use and lock them instead of sharing one model for everything. ut when exactly are the normals rescaled? when i simply scale and lock a model, they aren't. it seems they have to be rendered once.

if your code is simple as loading model and creating a light, why don't you post it here ?

because i already found the problem (locking locks normals, scaling after locking = evil lighting problems)

my problem now is to tell a spatial that is should re-normalize its normals NOW. i found no method to call, it seems to happen somewhere during rendering.



simply scaling a node and then locking it causes the normals not to be renormalized. but if i, instead of simply locking a node, do this:

Utils.traverseGraph(p_spatial, new Function<Spatial, Object>() {
      public Object call(final Spatial p_o) {
        p_o.setCullMode(CULL_NEVER);
        return null;
      }
    });
    m_engine.getDisplay().getRenderer().draw(p_spatial);
    Utils.traverseGraph(p_spatial, new Function<Spatial, Object>() {
      public Object call(final Spatial p_o) {
        p_o.setCullMode(CULL_DYNAMIC);
        return null;
      }
    });
    p_spatial.lock();



it works