Remove natural light of terrain

I have my terrain and i am using this

DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(1,0,-1).normalizeLocal());
   sun.setColor(ColorRGBA.White);

and this my terrain code

     main.getRootNode().detachAllChildren();
    Material mapacastelo = new Material(main.getAssetManager(), 
            "Common/MatDefs/Terrain/Terrain.j3md");
    
    mapacastelo.setTexture("Alpha", main.getAssetManager().loadTexture(
            "Textures/mapas/mapacastelo.png"));
   
    
    Texture grass =  main.getAssetManager().loadTexture(
            "Textures/aparencia/paredepedras.jpg");
    grass.setWrap(Texture.WrapMode.Repeat);
    
    mapacastelo.setTexture("Tex1", grass);
    mapacastelo.setFloat("Tex1Scale", 32f);
    
    AbstractHeightMap heightmap = null;
    Texture heightMapImage =  main.getAssetManager().loadTexture(
            "Textures/montanhas/montanhacastelo.png");
    heightmap = new ImageBasedHeightMap(heightMapImage.getImage());
    heightmap.load();
      
    
    int patchSize = 65;
         terrenocastelo = new TerrainQuad("mapacastelo", patchSize, 513, heightmap.getHeightMap());
 terrenocastelo.setShadowMode(ShadowMode.CastAndReceive);
      terrenocastelo.setMaterial(mapacastelo);
    terrenocastelo.setLocalTranslation(0, 0, 0);
    terrenocastelo.setLocalScale(2f, 1f, 2f);
    main.getRootNode().attachChild(terrenocastelo);
    
//CollisionShape sceneShape =
//                CollisionShapeFactory.createMeshShape((Node) terrenocastelo);
//        RigidBodyControl ft = new RigidBodyControl(sceneShape, 0);
        
 
  RigidBodyControl ft=new RigidBodyControl(0f);
  
 terrenocastelo.addControl(ft);
 main.getPhysicsSpace().add(ft);

I want my terrain use the light of DirectionalLight because my objects already use, but my terrain always is bright and clear, my objetcts have shadow ready and this work good, but my terrain is don’t use DirectionalLight .In my terrain i see the shadow of objects but i don’t see the light in my terrain…

Common/MatDefs/Terrain/TerrainLighting.j3md

  • instead of -
    Common/MatDefs/Terrain/Terrain.j3md

see this wiki page
http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:materials_overview

:chimpanzee_smile:

And once you are using the proper material, you may find that this does strange things to your lighting:

…as I’m pretty sure it will screw up the normals. Really, I think that’s not the way you do that with terrain.

Edit: actually I suppose the normals might be ok… I haven’t looked at the material.

Hey thanks, I try it before, but when i use it i have problems with this
“Alpha” and “Tex1”

mapacastelo.setTexture("Alpha", main.getAssetManager().loadTexture(
        "Textures/mapas/mapacastelo.png"));


Texture grass =  main.getAssetManager().loadTexture(
        "Textures/aparencia/paredepedras.jpg");
grass.setWrap(Texture.WrapMode.Repeat);

mapacastelo.setTexture("Tex1", grass);
mapacastelo.setFloat("Tex1Scale", 32f);

That’s because this material definition works very different than the other one.
Click the link that I have posted and search for Common/MatDefs/Terrain/TerrainLighting.j3md
There is a small description on how to use this material.
:chimpanzee_smile: