Terrain dark area

Hello, I am trying to implement a simple game using jME but I am now wondering about a weird graphic result.



I got a dark area in the following render. Look at the horizon line (before the mountains on the skybox) in this screenshot:



http://mapage.noos.fr/foxalert/screen.jpg



The surface is a terrainblock with some texture generated with the ProceduralTextureGenerator class.



I even tried, without better result, to add a materialstate to the terrain, for it to be lighted by the two directional lights. Actually, I wondered if a terrainblock has got normals? and are there particular things to initialize if you want texture + lighting?



Anyway, it should work without lighting, shoudn’t it?

Maybe have I forgotten a very simple thing (probably not related to jME itself).



Thanks for any piece of advice.

it appears that the terrain blocks normals are incorrect for that strip. What process did you use to create the TerrainBlock?

does turning off lights help? is the dark spot always where the horizon meets the land? is it perhaps an issue with the image you are using?

I genrate the terrain block with these lines:



         File imgf = new File("heightmap2.gif");
         java.awt.Image img = ImageIO.read(imgf);
         ImageBasedHeightMap hm = new ImageBasedHeightMap(img);
         Vector3f scaling = new Vector3f(10f,1f,10f);
         Vector3f translation = new Vector3f();
         translation.x = - scaling.x * hm.getSize() / 2;
         translation.z = - scaling.z * hm.getSize() / 2;
         translation.y = -300f;
         
         TerrainBlock terrain = new TerrainBlock("terrain", hm.getSize(), scaling, hm.getHeightMap(), translation, false);
         TextureState textureState=MainGame.getGame().getDisplay().getRenderer().createTextureState();
         ProceduralTextureGenerator pg = new ProceduralTextureGenerator(hm);
         pg.addTexture(new ImageIcon(ImageIO.read(new File("basphlt.jpg"))), 0, 30, 50);
         pg.addTexture(new ImageIcon(ImageIO.read(new File("samp03.jpg"))), 30, 80, 120);
         pg.addTexture(new ImageIcon(ImageIO.read(new File("stones.jpg"))), 100, 130, 256);
         pg.createTexture(1024);
         ImageIcon ic=pg.getImageIcon();
         Texture tex = TextureManager.loadTexture(ic.getImage(), Texture.MM_LINEAR, Texture.FM_LINEAR, true, true);
         tex.setAnisoLevel(textureState.getMaxAnisotropic());
         textureState.setTexture(tex);
         terrain.setRenderState(textureState);
         terrain.updateRenderState();
         
         Node node = new Node("terrain");
         setType("Terrain");
         node.attachChild(terrain);
         setNode(node);
         MainGame.getGame().getRootNode().attachChild(node);

                        //lines added to make a try
         MaterialState ms = MainGame.getGame().getDisplay().getRenderer().createMaterialState();
         ms.setDiffuse(new ColorRGBA(1f,1f,1f,1f));
         ms.setAmbient(new ColorRGBA(1f,1f,1f,1f));
         ms.setEnabled(true);
         node.setRenderState(ms);



The heightmap is there:
http://mapage.noos.fr/foxalert/heightmap2.gif

I realize that this line

 pg.addTexture(new ImageIcon(ImageIO.read(new File("stones.jpg"))), 100, 130, 256);


could bring something unexpected at the 256 height level :?

About the second ask: yes, I get the same result without material state, i.e. without lighting.

But do you actually remove the lightstate and/or disable it? If so then we can cross off normalization.



Also, what about my horizon question? and is this always whereever a certain image is used (say basphlt.jpg or stones.jpg?) Maybe you could provide those images too?

The image produced without lightstate is there:

http://mapage.noos.fr/foxalert/lightstate-disabled.jpg



Here are the textures:

http://mapage.noos.fr/foxalert/samp03.jpg

http://mapage.noos.fr/foxalert/Basphlt.jpg

http://mapage.noos.fr/foxalert/stones.jpg



Renanse, I am not sure to understand the horizon question well. The dark area is not on the skybox itself (which is luminous even below the terrainblock horizon):

http://mapage.noos.fr/foxalert/noterrain.jpg

Is this what you wanted to know ?

re: horizon, what I’m asking is if the dark strip is always right along the edge in the screenshot where the terrain meets the skybox (ie, the “horizon”) It appears this is just the black asphalt image…

Hey, you were perfectly right. That was the default black color under the texture distribution. With your correction, it does the trick:



http://mapage.noos.fr/foxalert/goodone.jpg



The scene is quite ugly anyway but now that the issue is solved, i can try to make it look better :smiley:



Thank you renanse !

Anytime. :slight_smile: