Box is highlithed when camera moves

Hi



I have a scene with 2 boxes (same material). when app starts, the box from the right is haighlaghted. If I move the mouse to rotate the camera to the left then the box form the left is highlighted and the other box is not. If I keep rotating the camera form left to right and right to left the boxes the same effect happen. I don’t know what I’m doing wrong!



See images and code below:





[java]

public class TestNormalMapProperties extends SimpleApplication {



public static void main(String[] args) {

TestNormalMapProperties app = new TestNormalMapProperties();

app.start();

}



@Override

public void simpleInitApp() {

Material matNormalMap = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

matNormalMap.setTexture(“DiffuseMap”, assetManager.loadTexture(“Textures/wood-box-texture.jpg”));

matNormalMap.setTexture(“NormalMap”, assetManager.loadTexture(“Textures/wood-box-normalmap.JPG”));

matNormalMap.setBoolean(“UseMaterialColors”, true);

matNormalMap.setColor(“Diffuse”, ColorRGBA.White);



Box b1 = new Box(new Vector3f(-1.5f, 0, 0), 1, 1, 1);

Geometry gb1 = new Geometry(“Box”, b1);

gb1.setMaterial(matNormalMap);

rootNode.attachChild(gb1);



Box b2 = new Box(new Vector3f(1.5f, 0, 0), 1, 1, 1);

Geometry gb2 = new Geometry(“Box”, b2);

gb2.setMaterial(matNormalMap);

rootNode.attachChild(gb2);



DirectionalLight sun = new DirectionalLight();

sun.setColor(ColorRGBA.White);

sun.setDirection(new Vector3f(-1, -1, -1));

rootNode.addLight(sun);

}



@Override

public void simpleUpdate(float tpf) {

//TODO: add update code

}



@Override

public void simpleRender(RenderManager rm) {

//TODO: add render code

}

}

[/java]

if I remove

[java]matNormalMap.setTexture(“NormalMap”, assetManager.loadTexture(“Textures/wood-box-normalmap.JPG”));[/java]

all works fine





I will try with other normalmap image to see what happen

Same weird effect with other texture images







can anyone help me to understand what is wrong?

how does your normal map look? also you have only one directional light, when the box is suddenly lit from the back only I guess that might cause a visual “flip”…

1 Like

Thanks @normen for your answer. These are the texture images I’m using:





I have tryed adding a ambient light or a point light behind the boxes but the visual “flit” remains.

Generate tangents.

1 Like

Thank @pspeed . That solve the problem.

And thank @normen for helping too.

One question related to this. If I import a model that has uv coord and use that model (.j3o file) from code. is mandatory to call TangentBinormalGenerator.generate(geom)?

You need the tangents when you use normal maps, else you don’t.