Using Normal map in Terrain Editor

A few months ago, I tried to make a game, and failed. So I actually took the time to go and learn java. Now I’ve coded several games (using jME), they work great. Now I’m trying to create a map in Terrain Editor and load it, that works great. But the normal map doesn’t do anything. I used the grass, dirt, and road textures from the “hello terrain”, and used gimp to generate the normal maps, but even when I make the normal maps kinda extreme, still nothing… :?



picture

http://imgur.com/fBlSS comparing the two

(I edited your post to add the proper link to the image)

Do you have a directional light in your scene or just an ambient light? You will need a directional one at a reasonably shallow angle to really notice the bumps.

Do the terrain test cases with normal maps and lighting look correct for you?

EDIT : the only thing I’ve actually coded was a spatial that imports the scene, and I gave it physics with the player… if you want to see the code, go for it.



[java]

package freefall;



import javax.swing.JOptionPane;



import com.jme3.app.SimpleApplication;

import com.jme3.bullet.BulletAppState;

import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;

import com.jme3.bullet.collision.shapes.CollisionShape;

import com.jme3.bullet.control.CharacterControl;

import com.jme3.bullet.control.RigidBodyControl;

import com.jme3.bullet.util.CollisionShapeFactory;

import com.jme3.input.KeyInput;

import com.jme3.input.controls.ActionListener;

import com.jme3.input.controls.KeyTrigger;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.scene.Node;

import com.jme3.scene.Spatial;

import com.jme3.terrain.geomipmap.TerrainLodControl;



/**

  • test
  • @author John Wargo

    /

    public class Start extends SimpleApplication implements ActionListener {



    public static void main(String[] args) {

    Start app = new Start();

    app.start();

    }



    //==========================================================================

    //Define advanced shapes here

    private Node land;

    private Spatial map;



    //the bulletAppState

    private BulletAppState bulletAppState;



    //the landscape physics

    private RigidBodyControl landscape;



    //character physics

    private CharacterControl player;



    //walking var’s

    private Vector3f walkDirection = new Vector3f();

    private boolean left = false, right = false, up = false, down = false;



    //physics toggle

    private boolean _physDebug;



    //inistantize JOP as jop

    private static JOptionPane jop = new JOptionPane();

    //==========================================================================



    @Override

    public void simpleInitApp() {

    //before anything display alpha info

    jop.showMessageDialog(null, “Alpha Tester:nPlease Read The Controls And The ChangelognThanks For Testing”);



    //create node for land

    land = new Node();



    //initiate physics engine

    bulletAppState = new BulletAppState();

    stateManager.attach(bulletAppState);



    //initiate camera and viewPort

    viewPort.setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f));

    flyCam.setMoveSpeed(20);



    //initiate keys

    initKeys();



    //load level scene

    map = assetManager.loadModel(“Scenes/map1.j3o”);

    map.setLocalTranslation(0,0,0);

    map.setLocalScale(1);

    //attach to land node

    land.attachChild(map);

    //create physics for land node

    CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) land);

    landscape = new RigidBodyControl(sceneShape, 0);

    land.addControl(landscape);



    //Create the player with a capsule shape

    CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);

    player = new CharacterControl(capsuleShape, 0.05f);

    player.setJumpSpeed(60);

    player.setFallSpeed(70);

    player.setGravity(160);

    player.setPhysicsLocation(new Vector3f(0, 30, 0));



    //attach land to root node for landscape appear

    rootNode.attachChild(land);



    //add player and land to physics

    bulletAppState.getPhysicsSpace().add(landscape);

    bulletAppState.getPhysicsSpace().add(player);

    }



    private void initKeys()

    {

    inputManager.addMapping(“Left”, new KeyTrigger(KeyInput.KEY_A));

    inputManager.addMapping(“Right”, new KeyTrigger(KeyInput.KEY_D));

    inputManager.addMapping(“Up”, new KeyTrigger(KeyInput.KEY_W));

    inputManager.addMapping(“Down”, new KeyTrigger(KeyInput.KEY_S));

    inputManager.addMapping(“Jump”, new KeyTrigger(KeyInput.KEY_SPACE));

    inputManager.addMapping(“PhyDebug”, new KeyTrigger(KeyInput.KEY_I));

    inputManager.addMapping(“Help”, new KeyTrigger(KeyInput.KEY_H));

    inputManager.addMapping(“Sprint”, new KeyTrigger(KeyInput.KEY_LSHIFT));

    inputManager.addListener(this, “Left”);

    inputManager.addListener(this, “Right”);

    inputManager.addListener(this, “Up”);

    inputManager.addListener(this, “Down”);

    inputManager.addListener(this, “Jump”);

    inputManager.addListener(this, “PhyDebug”);

    inputManager.addListener(this, “Help”);

    inputManager.addListener(this, “Sprint”);

    }



    /
    * These are our custom actions triggered by key presses.
  • We do not walk yet, we just keep track of the direction the user pressed. */

    public void onAction(String binding, boolean keyPressed, float tpf) {

    if (binding.equals(“Left”)) {

    left = keyPressed;

    }

    else if(binding.equals(“Right”))

    {

    right = keyPressed;

    }

    else if(binding.equals(“Up”))

    {

    up = keyPressed;

    }

    else if(binding.equals(“Down”))

    {

    down = keyPressed;

    }

    else if(binding.equals(“Jump”) && keyPressed)

    {

    player.jump();

    }

    else if(binding.equals(“PhyDebug”) && !keyPressed)

    {

    //toggle

    _physDebug = !_physDebug;

    //if true enable, if false, disable

    if(_physDebug)

    {

    bulletAppState.getPhysicsSpace().enableDebug(assetManager);

    }

    else

    {

    bulletAppState.getPhysicsSpace().disableDebug();

    }

    }

    else if(binding.equals(“Help”) && !keyPressed)

    {

    jop.showMessageDialog(null, “w,a,s,d :: movenh :: helpni :: physics debug”);

    }

    }



    //============================================================================



    @Override

    public void simpleUpdate(float tpf) {

    //setup camera

    Vector3f camDir = cam.getDirection().clone().multLocal(0.6f);

    Vector3f camLeft = cam.getLeft().clone().multLocal(0.4f);

    //clear walk direction

    walkDirection.set(0, 0, 0);

    //4 INDEPENDANT if’s for multidirectional support

    if (left) { walkDirection.addLocal(camLeft); }

    if (right) { walkDirection.addLocal(camLeft.negate()); }

    if (up) { walkDirection.addLocal(camDir); }

    if (down) { walkDirection.addLocal(camDir.negate()); }

    //walk

    player.setWalkDirection(walkDirection);

    //camera follows player

    cam.setLocation(player.getPhysicsLocation());

    }

    }

    [/java]

I’m only using one directional lighting, which is part of the scene, I’ll try making another in the scene, that is shallow and let you know how it goes…

I got rid of the directional light in the scene, and just started coding my own. I can just barely see the normal map at work. I’m 99% sure its something on my side, so I’ll keep working on it.



Thanks for the help, I kinda feel like I’m wasting your time when a problem can be solved in about 8 lines of coding, sorry if I was.

hehe don’t worry about it. Lighting can be a little tricky to get it to look “right” and in the mean time can feel like it is broken. You often have to exaggerate things a bit with the lights and normal maps to have the effects really stand out.

For example lots of games won’t put the sun directly overhead, because then the shadows will just be underneath the object and the scene won’t look fancy. So instead you see the sun skirt along the horizon, which makes no sense with reality when playing on a tropical island probably near the equator, but hey it looks good :slight_smile:

chessmaster942:

if you really want more effect, try just make more intense normal Map or increase Shininess(but it is bad to increase it for terrain, i would like to make shininess for each texture but its impossible)



and its somehow about topic:

Sploreg:



will be parallax added to TerrainLighting material in future?

I don’t have a plan to add it in the near future. I would add per-texture layer shininess before parallax.

@oxplay2:

Thanks for the tips, I’ll keep in mind that you can make more/less intense maps.



@Sploreg:

I’ve always wondered about the light rarely being directly overhead, now it not only makes sense, but seems very logical and like a good idea.



Thanks again for all your help, I’ve almost got it right where I want it, toying with it for another few minutes should get me there :smiley: