Cubemap: top and bottom textures doesn´t match with the horizontal textures

I use FOV 90 and aspect ratio 1 to render the views.
The horizontal textures matches perfectly.
The rootScene only have a SkyBox attached

[java]mirror_mat = new Material(assetManager,
“Shaders/Reflection/Reflection.j3md”);
// Create cameras and set it
Camera top_cam = new Camera(512,512);
top_cam.setFrustumPerspective(90f, 1f, 1f, 1000f);
top_cam.setLocation(new Vector3f(0f, 0f, 0f));
top_cam.lookAtDirection(new Vector3f(0,1,0), Vector3f.UNIT_Y);

    Camera bottom_cam = new Camera(512,512);
    bottom_cam.setFrustumPerspective(90f, 1f, 1f, 1000f);
    bottom_cam.setLocation(new Vector3f(0f, 0f, 0f));
    bottom_cam.lookAtDirection(new Vector3f(0,-1,0), Vector3f.UNIT_Y);
    
    Camera front_cam = new Camera(512,512);
    front_cam.setFrustumPerspective(90f, 1f, 1f, 1000f);
    front_cam.setLocation(new Vector3f(0f, 0f, 0f));
    front_cam.lookAtDirection(new Vector3f(0,0,1), Vector3f.UNIT_Y);
    
    Camera back_cam = new Camera(512,512);
    back_cam.setFrustumPerspective(90f, 1f, 1f, 1000f);
    back_cam.setLocation(new Vector3f(0f, 0f, 0f));
    back_cam.lookAtDirection(new Vector3f(0,0, -1), Vector3f.UNIT_Y);
    
    Camera left_cam = new Camera(512,512);
    left_cam.setFrustumPerspective(90f, 1f, 1f, 1000f);
    left_cam.setLocation(new Vector3f(0f, 0f, 0f));
    left_cam.lookAtDirection(new Vector3f(-1,0,0), Vector3f.UNIT_Y);
    
    Camera right_cam = new Camera(512,512);
    right_cam.setFrustumPerspective(90f, 1f, 1f, 1000f);
    right_cam.setLocation(new Vector3f(0f, 0f, 0f));
    right_cam.lookAtDirection(new Vector3f(1,0,0), Vector3f.UNIT_Y);

// Create vewports and set it
ViewPort top_view = renderManager.createPreView(“Top View”, top_cam);
top_view.setClearFlags(true, true, true);
top_view.setBackgroundColor(ColorRGBA.Blue);
ViewPort bottom_view = renderManager.createPreView(“Bottom View”, bottom_cam);
bottom_view.setClearFlags(true, true, true);
bottom_view.setBackgroundColor(ColorRGBA.Red);

    ViewPort front_view = renderManager.createPreView("Front View", front_cam);
    front_view.setClearFlags(true, true, true);
    front_view.setBackgroundColor(ColorRGBA.Green);
    ViewPort back_view = renderManager.createPreView("Back View", back_cam);
    back_view.setClearFlags(true, true, true);
    back_view.setBackgroundColor(ColorRGBA.Pink);
    
    ViewPort left_view = renderManager.createPreView("Left View", left_cam);
    left_view.setClearFlags(true, true, true);
    left_view.setBackgroundColor(ColorRGBA.Yellow);
    ViewPort right_view = renderManager.createPreView("Right View", right_cam);
    right_view.setClearFlags(true, true, true);
    right_view.setBackgroundColor(ColorRGBA.Gray);

//Create Cubemap and set it
TextureCubeMap cube_Tex = new TextureCubeMap(512, 512, Format.RGBA8);
cube_Tex.setMinFilter(Texture.MinFilter.Trilinear);
cube_Tex.setMagFilter(Texture.MagFilter.Bilinear);

//Create FrameBuffers and set it
FrameBuffer top_Buffer = new FrameBuffer(512, 512, 1);
top_Buffer.setDepthBuffer(Format.Depth);
top_view.setOutputFrameBuffer(top_Buffer);
FrameBuffer bottom_Buffer = new FrameBuffer(512, 512, 1);
bottom_Buffer.setDepthBuffer(Format.Depth);
bottom_view.setOutputFrameBuffer(bottom_Buffer);
FrameBuffer front_Buffer = new FrameBuffer(512, 512, 1);
front_Buffer.setDepthBuffer(Format.Depth);
front_view.setOutputFrameBuffer(front_Buffer);
FrameBuffer back_Buffer = new FrameBuffer(512, 512, 1);
back_Buffer.setDepthBuffer(Format.Depth);
back_view.setOutputFrameBuffer(back_Buffer);
FrameBuffer left_Buffer = new FrameBuffer(512, 512, 1);
left_Buffer.setDepthBuffer(Format.Depth);
left_view.setOutputFrameBuffer(left_Buffer);
FrameBuffer right_Buffer = new FrameBuffer(512, 512, 1);
right_Buffer.setDepthBuffer(Format.Depth);
right_view.setOutputFrameBuffer(right_Buffer);

    top_Buffer.addColorTexture(cube_Tex, TextureCubeMap.Face.NegativeY);
    bottom_Buffer.addColorTexture(cube_Tex, TextureCubeMap.Face.PositiveY);
    front_Buffer.addColorTexture(cube_Tex, TextureCubeMap.Face.NegativeZ);
    back_Buffer.addColorTexture(cube_Tex, TextureCubeMap.Face.PositiveZ);
    left_Buffer.addColorTexture(cube_Tex, TextureCubeMap.Face.NegativeX);
    right_Buffer.addColorTexture(cube_Tex, TextureCubeMap.Face.PositiveX);

//Attach the scene to the viewports
top_view.attachScene(rootNode);
bottom_view.attachScene(rootNode);
front_view.attachScene(rootNode);
back_view.attachScene(rootNode);
left_view.attachScene(rootNode);
right_view.attachScene(rootNode);[/java]

I guess the isue it that you keep Y as the up axis when looking up.
In the PointLightShadowRenderer I use the setaxis method on the cam instead of the lookatDirection.
https://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/shadow/PointLightShadowRenderer.java#89

1 Like

OK, thanks. It´s works now!