Problem with parallax map

hi im trying yo use parallax map with lighting.j3md material on my models but it look bad. here is an screenshot of my problem.

here is my .dds texture

and my code:

[java]

    dl = new DirectionalLight();
    dl.setDirection((new Vector3f(0.5f, -0.5f, 0.5f)).normalizeLocal());
    dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1));
    rootNode.addLight(dl);

Material mat;

    mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat.setTexture("DiffuseMap", assetManager.loadTexture("Textures/textura_1.jpg"));
    mat.setTexture("NormalMap", assetManager.loadTexture("Textures/normalMap_1.dds"));
    mat.setBoolean("PackedNormalParallax", true);
    mat.setFloat("Shininess",32);
     mat.setBoolean("UseMaterialColors", true);
        mat.setColor("Specular", ColorRGBA.White);
        mat.setColor("Diffuse", ColorRGBA.White);

     Spatial modeloSpatial = assetManager.loadModel("Models/muro/muro.j3o");
    modeloSpatial.rotate(1.569f, 0, 0);
    modeloSpatial.setMaterial(mat);
    modeloSpatial.setLocalTranslation(-50, 22, 60);

    rootNode.attachChild(modeloSpatial);

[/java]

What am I doing wrong? im hope somebody helpme.thanks for all answers

Probably: your model doesn’t have tangents and you have not generated them.

See: “Shininess and Bumpiness” at this link:
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_material

hi pspeed, i dont generate tangents o code, im used the sdk to gnerate tangents and binomials, i madeed right click on my geometry then i selected tools and generate tangents.

P.D. sorry for my bad english,

ho, i forgotten say, is a blender model, my normal maps i working fine, only parallax map still causing problems

Well… just from the picture, the normal maps looked strange too. Hard to say from this perspective.

Normally bump maps work but maybe yours are expecting a different UV or something. In JME default materials the UV coordinate has to be the same for all three textures. (color, normal map, parallax map)

<span style=“text-decoration:line-through;”>So the issue is the transparency is not compatible with parallax mapping. Transparency is calculated by the renderer, and parallax mapping is calculated by the material shader.

The issue is easy to understand, but difficult for me to explain, so someone else can have a crack =).</span>

nevermind, i jumped the gun, shouldn’t play Diablo and work the forum :roll:

@thetoucher said: <span style="text-decoration:line-through;">So the issue is the transparency is not compatible with parallax mapping. Transparency is calculated by the renderer, and parallax mapping is calculated by the material shader.

The issue is easy to understand, but difficult for me to explain, so someone else can have a crack =).</span>

nevermind, i jumped the gun, shouldn’t play Diablo and work the forum :roll:

Heheh… that’s ok. I’m wrong with the texture coordinates thing, too.

Cannot solve on info provided.

Your parallax map should be a grey scale texture. It seems you set it in the alpha channel of your normal map, but it seems you only have the borders of the bricks that are grey.
your bricks in the parallax channel should be white and all the normal map surface should be covered, not only a part of it

@nehon said: Your parallax map should be a grey scale texture. It seems you set it in the alpha channel of your normal map, but it seems you only have the borders of the bricks that are grey. your bricks in the parallax channel should be white and all the normal map surface should be covered, not only a part of it

I interpret his texture as mostly “full height” with some “deep parts” around certain bricks. It looks valid to me.

To the OP, have you tried splitting the heights out into its own texture? Maybe this is specifically to do with having it packed in one texture.

Also, we’re making a lot of assumptions about what should line up where in the picture. Assuming splitting doesn’t fix things, maybe adding some color to the diffusemap texture to show where it should be deeper will help figure out if it’s a big alignment issue or a small one.

Also… how does it look on a regular quad with tangents generated? Maybe there is something about the model or something.

i noticed something, when i move the camera, the parallax moves too

@eypidemik said: i noticed something, when i move the camera, the parallax moves too

Can you try to use the material on a regular JME Quad with tangents generated, please?

…this will help us narrow down the issue.

ok, i tried with a basic cuad, and the result is same, here is an screenshot:

is the same diffuse texture and normal texture.

here is my code:

[java]
Material mat;

    mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat.setTexture("DiffuseMap", assetManager.loadTexture("Textures/textura_1.jpg"));
    mat.setTexture("NormalMap", assetManager.loadTexture("Textures/normalMap_5.dds"));
    mat.setBoolean("PackedNormalParallax", true);
    mat.setFloat("Shininess",32);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Specular", ColorRGBA.White);
    mat.setColor("Diffuse", ColorRGBA.White);


     Quad q = new Quad(100, 100);
    Geometry g = new Geometry("geom", q);
    g.setMaterial(mat);
    g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X))
    TangentBinormalGenerator.generate(g);

      rootNode.attachChild(g);

[/java]

if i use a material based in lighting material like this:

[java]
Material Pong Rock : Common/MatDefs/Light/Lighting.j3md {
MaterialParameters {
Shininess: 2.0
DiffuseMap : Textures/BrickWall.jpg
NormalMap : Textures/BrickWall_normal_parallax (1).dds
PackedNormalParallax: true
}
}
[/java]

the result is the same

I think the problem is related with the lighting or my texture, i tried the example “TestParallax” and is working fine, but it is not shiny

i saw slowly the example of the JME. and when i move my camer, the floor is moving too,

in the sample the cracks of the floor are small, , i remove q.scaleTextureCoordinates(new Vector2f(10, 10)); from the example code, and i can see the movement on the floor.

The only other thing I can suggest as a test would be to try splitting the parallax map into its own texture instead of packing it. It really shouldn’t matter, though. Not sure when/if nehon or I will have a chance to look into this.

i created a parallaMap for a quick check, this is my parallMap image:

now im not using normalMap, only diffuseMap and parallaxMap, but the issue still.

here is my an issue image:

i noticed in the testParallax example, the floor is moving, but only inside the crack. In my model, the jelly stain is moving out the crack when i move the camera como se muestra en la imagen.

muchas gracias por sus respuestas, espero que mi problema se resolverá pronto

ok, i’ve been trying for over 3 days, and i cant solve it yet, but if i use steep-parallax it work fine.
i use the following code lines.

[java]
mat.setBoolean(“SteepParallax”, true);
mat.setFloat(“ParallaxHeight”, .05f);
[/java]