When I run this code for a terrain with diffusemap and normalmap I get this error:
Uncaught exception thrown in Thread[jME3 Main,5,main]
RendererException: compile error in: ShaderSource[name=Common/MatDefs/Terrain/TerrainLighting.frag, defines, type=Fragment, language=GLSL100]
0(720) : error C1008: undefined variable “calculateNormal”
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.renderer.RenderManager;
import com.jme3.terrain.geomipmap.TerrainQuad;
import com.jme3.terrain.heightmap.AbstractHeightMap;
import com.jme3.terrain.heightmap.ImageBasedHeightMap;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture.WrapMode;
//import com.jme3.util.TangentBinormalGenerator;
/**
* This is the Main Class of your Game. You should only do initialization here.
* Move your Logic into AppStates or Controls
* @author normenhansen
*/
public class Main extends SimpleApplication {
Material matTerrain;
private float groundScale = 16;
private TerrainQuad terrain;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
// TERRAIN TEXTURE material
matTerrain = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
matTerrain.setBoolean("useTriPlanarMapping", false);
matTerrain.setFloat("Shininess", 0.0f);
// HEIGHTMAP image (for the terrain heightmap)
Texture heightMapImage = assetManager.loadTexture("Textures/heightmap.png");
Texture ground = assetManager.loadTexture("Textures/Ground/Ground_04.png");
ground.setWrap(WrapMode.Repeat);
matTerrain.setTexture("DiffuseMap", ground);
matTerrain.setFloat("DiffuseMap_0_scale", groundScale);
Texture normalMap0 = assetManager.loadTexture("Textures/Ground/Ground_04_Nrm.png");
normalMap0.setWrap(WrapMode.Repeat);
matTerrain.setTexture("NormalMap", normalMap0);
// CREATE HEIGHTMAP
AbstractHeightMap heightmap = null;
try {
heightmap = new ImageBasedHeightMap(heightMapImage.getImage(), 0.5f);
heightmap.load();
heightmap.smooth(0.9f, 1);
} catch (Exception e) {
e.printStackTrace();
}
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
terrain.setMaterial(matTerrain);
terrain.setLocalTranslation(0, -100, 0);
rootNode.attachChild(terrain);
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
Can someone help me? I just want to try out a terrain with a normalmap.