JME3.1 - The Sky Render Black for Some Android Devices

Hi,

The sky was obtained through the method below.

Spatial sky = SkyFactory.createSky(this.app.getAssetManager(), “Textures/Sky/Bright/blue_sky_512x512_2.png”, SkyFactory.EnvMapType.SphereMap);

I noticed this problem for two android devices:

  • Samsung Galaxy Tab S3;
  • Motorola Moto Maxx.

The following figures show the normal situation and the error situation.

https://drive.google.com/open?id=0B6PayivIlyTVSmYyMnhJckdkeFE

https://drive.google.com/open?id=0B6PayivIlyTVTUtXOEo3WWwxLUE

In fact, after some tests, I realized that the sky was not being rendered.

After a few more tests, I identified where the problem occurs.

In the file Sky.j3md has the following definition:

    RenderState {
        DepthWrite Off
        DepthFunc Equal
    }

The problem is in DepthFunc = Equal. For rendering to have to be DepthFunc = LessOrEqual.

To work around the problem I did the following after calling the SkyFactory.createSky function:

                Geometry g = (Geometry) sky;
                
                //Bug fix para Samsung Galaxy Tab S3 e Motorola Moto Maxx
                g.getMaterial().getAdditionalRenderState().setDepthFunc(RenderState.TestFunction.LessOrEqual);
4 Likes

Love you dude!!! Spent a lot of time to get it working, with this parameter set, everything goes beautiful!!!

In addition want to provide example of creating sky geometry, here is my example:

Kotlin code, taken from default SkyFactory

private fun createSky(sphereRadius : Float, normalScale : Vector3f, texture : Texture) : Geometry {

val sphereMesh = Sphere(10, 10, sphereRadius, false, true)
sky = Geometry(“Sky”, sphereMesh)
sky.queueBucket = RenderQueue.Bucket.Sky
sky.cullHint = Spatial.CullHint.Never
sky.modelBound = BoundingSphere(Float.POSITIVE_INFINITY, Vector3f.ZERO)

val skyMat = Material(assetManager, “Common/MatDefs/Misc/Sky.j3md”)
skyMat.setVector3(“NormalScale”, normalScale)
skyMat.setBoolean(“EquirectMap”, true)
texture.magFilter = Texture.MagFilter.Bilinear
texture.minFilter = Texture.MinFilter.BilinearNoMipMaps
texture.anisotropicFilter = 0
texture.setWrap(Texture.WrapMode.EdgeClamp)
skyMat.setTexture(“Texture”, texture)
skyMat.additionalRenderState.depthFunc = RenderState.TestFunction.LessOrEqual
sky.material = skyMat

return sky
}

Hello Rukurbanov,
I’m glad I could help.