My skybox is not always visible, even if i set it at:
skyboxNode.setCullHint(CullHint.Never);
skyboxNode.setQueueBucket(Bucket.Sky);
It is working fine, until I set the camera frustum:
camera.setFrustumPerspective(45.0f, (float) screenWidth / screenHeight, 9f, 60000f);
(see Image)
Moving or rescaling the skybox does not help…
Do I do something wrong, or how can I fix this?
I think i am not doing anything weird here…
I tested with the TestSkyLoading.java in the texture test package.
[java]
package jme3test.texture;
import com.jme3.app.SimpleApplication;
import com.jme3.scene.Spatial;
import com.jme3.texture.Texture;
import com.jme3.util.SkyFactory;
public class TestSkyLoading extends SimpleApplication {
public static void main(String[] args) {
TestSkyLoading app = new TestSkyLoading();
app.start();
}
@Override
public void simpleInitApp() {
Texture west = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_west.jpg");
Texture east = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_east.jpg");
Texture north = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_north.jpg");
Texture south = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_south.jpg");
Texture up = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_up.jpg");
Texture down = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_down.jpg");
Spatial sky = SkyFactory.createSky(assetManager, west, east, north, south, up, down);
rootNode.attachChild(sky);
// Added to create artifact
cam.setFrustumPerspective(45.0f, (float) settings.getWidth() / settings.getHeight(), 9f, 5000f);
}
}
[/java]
And there the same artifact occurs.
Anyone any info on this?
It seems that the issue is with the near plane. Why 9? the issue start at 8 apparently.
I guess those values are distorting the frustum and some weirdness appear with the skybox. Using any value below 8 fixes the issue.
The reason that I need to set my near frustum higher than 8, is to make
sure that no z-buffer fighting appears in my scene.
(It is a rather large scene)
The reason I picked 9 for this example, was to show it goes wrong when
a value bigger than 8 is set…
So it is impossible to set the camera near plane frustum higher than 8
when you use a sky box?
maxxer said:
So it is impossible to set the camera near plane frustum higher than 8
when you use a sky box?
well apparently not :p
I'm gonna look into it and see what i can do.
nehon said:
well apparently not :p
I'm gonna look into it and see what i can do.
I presume the sky is drawn at some fixed depth/radius... is it 10 by any chance?
pspeed said:
I presume the sky is drawn at some fixed depth/radius... is it 10 by any chance?
Damn you're clever!!!
if i set the radius of the sphere mesh to 100 the issue disappear....
But i don't really get why scaling it does not yield the same result....
Scaling it where?
anywhere with setLocalScale.
anyway @maxxer I committed a change now you can specify the sphere radius when creating the sky.
set it to at least 25% or 30% above your near clipping plane.
Thanks guys, you are really helping me here
I will immediately test this, first thing tomorrow!
@maxxer Why wait till tomorrow?
cool
Hi @nehon , could we add the radius feature to a new function derived from:
[java]
public static Spatial createSky(AssetManager assetManager, String textureName, boolean sphereMap);
[/java]
I tried doing:
[java]
Spatial skyG = SkyFactory.createSky(
_app.getAssetManager(),
_app.getAssetManager().loadTexture(“Textures/stormydays3.dds”),
new Vector3f(1,1,1),
false,
1200);
[/java]
as a workaround, but it seems that up and down are being mixed up, so there might be a little bug there…
For anyone who might need it, I read through the jme code and came up with this solution. The texture needed some help figuring out it’s true purpose in life I guess.
[java]
String texturePath = “Textures/stormydays3.dds”;
TextureKey key = new TextureKey(texturePath, true);
key.setGenerateMips(true);
key.setAsCube(true);
Texture tex = assetManager.loadTexture(key);
int radius = 5000000;
Spatial skyGeom = SkyFactory.createSky(
assetManager,
tex,
Vector3f.UNIT_XYZ,
false,
radius);
[/java]
Works like a charm:)