[SOLVED] Cannot get light to work. Material problem?

Since my game objects are going to be made exclusively of custom mesh, dynamically generated, I decided to try to do that first.

Using the default lighting provided by SimpleApplication (what IS the default lighting; I can’t see anything about it in SimpleApplication), with Unshaded.j3md material, and material.setBoolean(“VertexColor”, true), I can build my mesh, and see it, although it seems to be lit from the left, so that the right side is totally dark.

Adding a directional light has no effect:

    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-.5f,-.5f,-.5f).normalizeLocal());

Adding an ambient light has no effect:

    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(1.8f,1.8f,1.8f,1.0f));

Adding both still has no effect.

I took both example from the wiki/forum, and assume they are right. Therefore it is probably an issue with my material and/or my mesh.

Is there a way to say: just display everything at full color? No shadows.

I tried using wireframe, but even that seems to be shaded. I use the same color everywhere, so it should not be an issue that I used black or something, giving it a shaded look. Still some of my corner/vertice are “dark”, while the others look OK.

This is because jME only renders front facing polygons by default. Ones with indexes defined in counter-clockwise. The bottom of the custom mesh wiki explains it:

Also there is no “default lighting”, and a light won’t do anything with a material with Unshaded.j3md

You should go through all the basic tutorials, particularly the material ones which cover things like the difference between lighting and unshaded in detail.

I’ve already gone through all the basic tutorials, as well as stuff like threading model, custom controls, appstates, custom mesh, headless server, …

I have found the reason why some corner are “dark”, it’s because my color buffer was too small. The number of colors must be the same as the number of vertice, rather then the number of “triangle index” * 3. This surprised me, as it means that I have to put the same vertex multiple times in the vertice buffer, if I want to draw it with multiple colors. I still don’t find this “logical”, but I can live with it.

From your answers, I gather that if I use Unshaded.j3md as material, it should always use the full color, independent of lighting. But If I used a material that used lighting, it would be black with the default settings, because no light is configured by default.

That’s correct.

You colour vertices not faces as you can put different colour at each vertex and the shader will interpolate between them…