Strangely lighted terrain... >_<

hey everyone,



I added a terrainpage to my scene, but it seems, no matter what i do with the lighting, the terrain always seems very dimly lit (aside from the peaks)… help?

My car starts up and makes this funky clunking sound, what is it? :wink:





(a little more info if you please :), possible some source including your light setup)

XD Sorry :slight_smile: i'll provide more info… please let me know if any other information will be helpful. The other methods just do text reading stuff for the heightmaps and the procedural textures.







This is the class method that creates the terrainpage




public TerrainPage createTerrainPage(DisplaySystem display){

int block =findNearestSize();

int side;

if(s.length>s[0].length) side = s.length;

else side = s[0].length;



grid_gui = new TerrainPage("master_grid",

                block/6,

                block,

                new Vector3f(2f,1f,2f),

                grid_map.getHeightMap()

                ,false);



ProceduralTextureGenerator pt = new ProceduralTextureGenerator(grid_map);

pt= readDoc("rock",pt);

pt.createTexture(512);

TextureState ts = display.getRenderer().createTextureState();

Texture t1 = TextureManager.loadTexture(pt.getImageIcon().getImage(),

Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, true);

ts.setTexture(t1);

grid_gui.setRenderState(ts);

grid_gui.updateRenderState();

grid_gui.setDetailTexture(1, 1);

grid_gui.setLocalScale(2f);





return grid_gui;



}



The following is the method i put everything in. The scene is using the default lights, but is still badly lit.




protected void simpleInitGame() {





TwoLayeredGrid r = new TwoLayeredGrid(5,5);

    r.putTerrain(new Location(0,0), new Rock());

    r.putTerrain(new Location(0,1), new Rock());

    r.putTerrain(new Location(0,2), new Rock());

    r.putTerrain(new Location(0,3), new Rock());

    r.putTerrain(new Location(0,4), new Rock());

    r.putTerrain(new Location(1,0), new Rock());

    r.putTerrain(new Location(1,1), new Flower());

    r.putTerrain(new Location(1,2), new Flower());

    r.putTerrain(new Location(1,3), new Flower());

    r.putTerrain(new Location(1,4), new Flower());

    r.putTerrain(new Location(1,0), new Flower());

    r.putTerrain(new Location(1,1), new Flower());

    r.putTerrain(new Location(1,2), new Flower());

    r.putTerrain(new Location(1,3), new Flower());

    r.putTerrain(new Location(1,4), new Flower());

    r.putTerrain(new Location(2,0), new Flower());

    r.putTerrain(new Location(2,1), new Flower());

    r.putTerrain(new Location(2,2), new Flower());

    r.putTerrain(new Location(2,3), new Flower());

    r.putTerrain(new Location(2,4), new Flower());

    r.putTerrain(new Location(3,0),  new Flower());

    r.putTerrain(new Location(3,1),  new Flower());

    r.putTerrain(new Location(3,2),  new Flower());

    r.putTerrain(new Location(3,3), new Flower());

    r.putTerrain(new Location(3,4),  new Flower());

    r.putTerrain(new Location(4,0), new Rock());

    r.putTerrain(new Location(4,1), new Rock());

    r.putTerrain(new Location(4,2), new Rock());

    r.putTerrain(new Location(4,3), new Rock());

    r.putTerrain(new Location(4,4), new Rock());

    Grid g= new Grid®;



    TerrainPage grid = g.createTerrainPage(display);



    rootNode.attachChild(grid);

    rootNode.getChild(0).setLocalTranslation(0,-190,0);



display.getRenderer().setBackgroundColor(ColorRGBA.gray);



}


Have you tried creating a new light state with a directional light pointing straight down?


LightState ls = Renderer.getLightState();
DirectionalLight dl = new DirectionalLight();
dl.setDirection( Vector3f.Unit_Y );
ls.attach( dl );

rootNode.setRenderState( ls );

okies, i added the code:



LightState ls = display.getRenderer().createLightState();

    DirectionalLight dl = new DirectionalLight();

    dl.setDirection( Vector3f.UNIT_Y );

    dl.setEnabled(true);

    ls.attach( dl );



but i still get a screen that looks like this:



thats because the code u added creates a light directly shines upward instead of downward.



change the line dl.setDirection( Vector3f.UNIT_Y ); to dl.setDirection(new Vector3f(0,-1,0));



and if u r using a directional light, u might also wanna remove the default point light. so do this:

this.lightState.detachAll(); before u attach the new light.

Opps, thats what I get for just 'winging' code in a forum post 

thank you :smiley: it's a whole lot brighter now :slight_smile: Detachall really really helped :slight_smile:

faraway said:

thank you :D it's a whole lot brighter now ^_^ Detachall really really helped :)


glad i can help~