(Resolved) Lighted objects are invisible

(edit)

Thanks for that bit about light only affecting what is in its node/subnodes. I would not have guessed that myself, though I can see how that would be useful for making specific light sources only affect certain things.

(/edit)



I am trying to add lighting to my scene. I was using SimpleTextured.j3md and setting m_ColorMap to the texture with my color map. Am I mistaken in thinking that, if all I want is for unlit surfaces to appear dark, that I can just use Lighting.j3md instead and use the same color map texture with m_DiffuseMap?



The object displays fine with the SimpleTextured color map. When I change it to Lighting and use the color map as a diffuse map instead, my object is no longer visible. It’s not even showing up as a dark, black image as I would think something unlit should; it’s just invisible, and I can see the object behind it.



I went from this…

pre type="java"



Material material = new Material(getAssetManager(), “Common/MatDefs/Misc/SimpleTextured.j3md”);


material.setTexture(“m_ColorMap”, getAssetManager().loadTexture(“Models/planet.jpg”));


planetModel.setMaterial(material);
/pre

… to this…

pre type="java"



Material material = new Material(getAssetManager(), “Common/MatDefs/Light/Lighting.j3md”);


material.setTexture(“m_DiffuseMap”, getAssetManager().loadTexture(“Models/planet.jpg”));


planetModel.setMaterial(material);
/pre

And there is a light source nearby.

pre type="php"



PointLight light = new PointLight();


light.setRadius(50);


light.setColor(ColorRGBA.White);


// getModel() here refers to a node just a few units away (<50) from the planets


getModel().addLight(light);
/pre

Where is the flaw in my understanding of lighting?

First, the SimpleTextured material is deprecated, use Unshaded.j3md. Second, the light only propagates to subnodes, so attach it to the rootNode to affect all geometries.