[SOLVED] Mesh + Material with Lighting.j3md throws error

Lighting.j3md require Proper normal (vertex/face direction) in Mesh. it is you need to fill this:

mesh.setBuffer(VertexBuffer.Type.Normal, 3, nb);

for full quad for example you can fill it like:

nb.put(normalDirection.x).put(normalDirection.y).put(normalDirection.z);
nb.put(normalDirection.x).put(normalDirection.y).put(normalDirection.z);
nb.put(normalDirection.x).put(normalDirection.y).put(normalDirection.z);
nb.put(normalDirection.x).put(normalDirection.y).put(normalDirection.z);

Also it require Light so it will not be just black and Front of face will be lit. it can be done with:

rootNode.addLight(al) //ambient light - overall light not depends on normals, but normals you need to see front faces
rootNode.addLight(dl) //directional light - it depends on normals from your mesh

As i know this 2 things(light/normals) is required for your Lighting.j3md to not be “black”(not lit).

Unshaded do not need light/normals. PBR also need lightProbe to make metallic work. As you can see each material can have some “requirements”.

Anyway imo TestCase is always easiest way to solve.

1 Like

To put this as plainly and bluntly as possible.

Lighting = how much is this face pointing at the light.
“face pointing” = normal

Lighting requires normals.

If your mesh doesn’t have a normal buffer, no lighting for you… as the surfaces are never pointing to the light.

1 Like

I think hes confused as to why the Box works when his is not and hes using the same material even though you guys are telling him the answer.

1 Like

Now i understand that I need a VertexBuffer for the normals. Everything works fine now. Thank you all very much!!

3 Likes