Hi
I had a look at the example TestParallax and something immediately looked slightly wrong about the effect. After zooming about a bit and tweaking the settings to make the effect stronger I realised that in the y axis of the texture, the perspective appears “concave” whereas it should be convex. It is absolutely fine in the other (x) axis of the texture.
I have created a simpler example to more easily make the problem apparent (below). To explain as clearly as I can what the problem is, run this example and look at a brick near the bottom of the object, and you will note that you can see the brick’s southern edge’s face rather than its northern edge’s face. Note that in the texture’s x axis there is no problem - look at a brick on the left and you can see its eastern edge’s face.
N.B. the “SteepParallax” property is set true to make it easier to see the problem, but the problem exists even without SteepParallax. To verify this is not an artifact of my example, run the standard TestParallax example and up the parallax height a bit and you will see the same problem clearly.
[java]
package jme3test.light;
import com.jme3.app.SimpleApplication;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.texture.Texture;
public class TestSimpleParallax extends SimpleApplication implements AnalogListener {
public static void main(String[] args){
TestSimpleParallax app = new TestSimpleParallax();
app.start();
}
private Geometry thing;
@Override
public void simpleInitApp() {
inputManager.addMapping("CharLeft", new KeyTrigger(KeyInput.KEY_N));
inputManager.addMapping("CharRight", new KeyTrigger(KeyInput.KEY_M));
inputManager.addListener(this, "CharLeft");
inputManager.addListener(this, "CharRight");
Box cube2Mesh = new Box( 1f,1f,0.01f);
thing = new Geometry("window frame", cube2Mesh);
thing.setLocalTranslation(0, 0.5f, 0);
Material mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall2.j3m");
mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(Texture.WrapMode.Repeat);
mat.getTextureParam("NormalMap").getTextureValue().setWrap(Texture.WrapMode.Repeat);
mat.setFloat("ParallaxHeight", 0.25f);
mat.setBoolean("SteepParallax", true);
thing.setMaterial(mat);
thing.setLocalScale(3f);
rootNode.attachChild(thing);
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
dl.setColor(ColorRGBA.White);
rootNode.addLight(dl);
}
public void onAnalog(String binding, float value, float tpf)
{
System.out.println(binding + " " + value + " " + tpf);
if (binding.equals("CharLeft")) {
if (value > 0) {
System.out.println("LEFT");
thing.rotate(0, 0, -0.01f);
}
} else if (binding.equals("CharRight")) {
if (value > 0) {
System.out.println("RIGHT");
thing.rotate(0, 0, 0.01f);
}
}
}
}
[/java]
Thanks
Barney