[Fixed] Basic Lighting

Hi, JME newbie here.

I’ve created a basic scene, using terrain and some shapes and I’d now like to add some nice lighting to the scene. As it is, everything appears in the scene without any light being present. After reading the lighting documents and looking through the examples, I have one question. Clearly within my scene I would like to have everything (my terrain as well as shapes) affected by the light. However, from what I have read so far it appears I would need to apply the Lighting.jm3d material to all my objects in order for this to happen. Unfortunately though I’ve already applied materials to all my objects, including my terrain which uses the Terrain.jm3d material base. My question is how can I keep these materials while still having everything affected by the lighting within my scene?

Thanks in advance for any help, greatly appreciated :slight_smile:

Use TerrainLighting.j3md :wink: A material is really more than just the appearance like color etc. Without lighting computed in a shader thats used in the material you wont get lighting in the render output.

normen said:
Use TerrainLighting.j3md ;) A material is really more than just the appearance like color etc. Without lighting computed in a shader thats used in the material you wont get lighting in the render output.


Hi, thanks for the help! My only issue is now that my application wont compile because of the material parameters I'm using. I was able to get everything correct except this:

[java] Texture grass = assetManager.loadTexture("textures/terrain/grass.jpg");
grass.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("AlphaMap_1", grass);
mat_terrain.setFloat("m_Text1Scale", 64f);[/java]

I found that I needed AlphaMap_1 instead of m_Tex1 which was what I was using, but I can't find out how to scale the textures using the new material. I couldn't even see any scaling paramters in the material file. Hopefully theres a simple fix, again any help is much appreciated!

Cheers