SkyFactory.createSky SphereMap texture mapping problem

I have a problem with the Sphere map in Sky Factory.

I understand that there will be distortion at the poles but my theory is that the texture coordinates are not being mapped correctly.

Looking at the original image texture it appears to be correct you can download the original from http://paulbourke.net/miscellaneous/starfield/

I have read other posts on the subject Sky looks distorted when using SkyFactory.createSky with spheremap
and Sphere-mapped SkyBox texturing problems. However they have not helped.

By the way the images are seascapes so the lower halves of the images are reflections of the stars in the sea, so its correct that there will be distorsion.

To test the texture coordinate problem I copied the relevant code from com.jme3.util.SkyFactory
and added
Quaternion quat=new Quaternion();
quat.fromAngles(FastMath.PI/2,0,0);
sky.setLocalRotation(quat);

This is much better. Note the stars are not distorted as lines.
However they have a distorsion as if we are facing a pole of the sphere.

It appears that as a new user I can only add one image maybe yoy can see the others with the url

src="/uploads/default/original/2X/b/bb74a4448c8ee153a5af893cd3e05fc6dd2447a4.png" width=“607” height=“500”

Looking at 90 degrees from the pole I see the result I am expecting, crisp well defined stars.

src="/uploads/default/original/2X/e/e55acdc18974685350084a204d962172e01b7bff.png" width=“607” height=“500”

I tried to rotate the whole background by adding the sky to a node and rotating that by 90 degrees around the x axis but theres no change in the sky.

Node node=new Node();
node.getChildren().add(sky);
quat=new Quaternion();
quat.fromAngles(-FastMath.PI/2,0,0);
node.setLocalRotation(quat);
return node;

Can you confirm if there is a problem in the texture mapping in SkyFactory.

And also can anyone give a hint as to why I cannot rotate the sky by 90 degrees.

Details:

Code is called like this
Texture texture=assetManager.loadTexture(“Scenes/night/stars8192x4096.png”);
//sky=SkyFactory.createSky(assetManager,texture ,Vector3f.UNIT_XYZ, true,nearPlane);
sky=createSky(assetManager,texture ,Vector3f.UNIT_XYZ, EnvMapType.SphereMap, nearPlane);


//Modified code Taken from com.jme3.util.SkyFactory on github

public Spatial createSky(AssetManager assetManager, Texture texture,
        Vector3f normalScale,  EnvMapType envMapType,  float sphereRadius) {
    if (texture == null) {
        throw new IllegalArgumentException("texture cannot be null");
    }
    final Sphere sphereMesh = new Sphere(10, 10, sphereRadius, false, true);

    Geometry sky = new Geometry("Sky", sphereMesh);
    
    //Begin modification
    Quaternion quat=new Quaternion();
    quat.fromAngles(FastMath.PI/2,0,0);
    sky.setLocalRotation(quat);
    //End modification
    sky.setQueueBucket(Bucket.Sky);
    sky.setCullHint(Spatial.CullHint.Never);
    sky.setModelBound(new BoundingSphere(Float.POSITIVE_INFINITY, Vector3f.ZERO));

    Material skyMat = new Material(assetManager, "Common/MatDefs/Misc/Sky.j3md");
    skyMat.setVector3("NormalScale", normalScale);
    
    switch (envMapType){
        case CubeMap : 
            // make sure its a cubemap
            if (!(texture instanceof TextureCubeMap)) {
                Image img = texture.getImage();
                texture = new TextureCubeMap();
                texture.setImage(img);
            }
            break;
        case SphereMap :     
            skyMat.setBoolean("SphereMap", true);
            break;
        case EquirectMap : 
            skyMat.setBoolean("EquirectMap", true);
            break;
    }
    texture.setMagFilter(Texture.MagFilter.Bilinear);
    texture.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
    texture.setAnisotropicFilter(0);
    texture.setWrap(Texture.WrapMode.EdgeClamp);
    skyMat.setTexture("Texture", texture);
    sky.setMaterial(skyMat);
    
  //Begin modification
    //the texture at the pole is ok but now we are looking straight ahead at a pole
    //this is an attempt to correct that but the pole always appears on the horizon straight ahead. Anyone know why?
    Node node=new Node();
    node.getChildren().add(sky);
    quat=new Quaternion();
    quat.fromAngles(-FastMath.PI/2,0,0);
    node.setLocalRotation(quat);
    return node;
    //End modification
}

I only started using Jme this week and this is my first post so I may have another problem in the code.

Thanks in advance

I’m pretty sure sphere maps are broken for quite long time now… :frowning:

Thanks for replying.

After the first rotation I get the following image viewed from the same angle as the first image

and then at 90 degrees to that I get a much sharper image

So it doesnt appear to be very broken, is there a bug report open on this issue?

this is an equirect map by the way, you could use it right away with the skybox, without having to convert it to a spheremap, unless you are using 3.0.