I’m developing a game in RC2, and I’ve been struggling to understand a bug where the viewport occasionally goes to solid background color for no obvious reason. I’ve narrowed it down to the sphereRadius of the cube-mapped sky I’m using. The Javadoc for SkyFactory indicates that the sphereRadius should match the camera’s near plane. Part of the problem is that my camera’s near plane is at 0.01 world units, and the sphereRadius parameter is an int, so the best I can do is sphereRadius=1.
From browsing SkyFactory.java, it appears that the only use of sphereRadius is to construct a Sphere, and the Sphere constructor expects a float in that position. Could we change the createSky() interfaces (or add new ones) to accept a float value for sphereRadius?
I’m not sure whether the bug in my game is caused by sphereRadius. There seem to be other factors at work which I haven’t isolated yet. I raised the interface issue here because: (1) the method interface and the Javadoc have me confused about how I should set sphereRadius, and (2) I have a simple test program which exhibits similar symptoms depending on the value of sphereRadius, and its frustrating to be limited to integer values in my testing.
Regarding (2): in my test code, if I use sphereRadius=1 for a scene that contains nothing but cube-mapped sky, I see a circular piece of the sky surrounded by background color when the camera’s direction is (0.0, 0.0, -1.0), and the view changes to all background color the instant the camera’s direction changes. If I increase sphereRadius to 2, I see sky everywhere I turn the camera. If I then set the near plane of the camera frustrum to 3.0, I see only the background color everywhere I look. I’d appreciate some insight into this behavior.
Regarding (1) I’d appreciate advice on how to set sphereRadius in my game. If the sky is rendered at the distance of the far plane, what is the use of this parameter?
If you have some test code then post it. Someone familiar with the sky box stuff will be able to spot your issue, I guess.
I thought the radius was to control how distorted the mesh looks. Anyway, from malfunctioning test code it will be easier to get to the bottom of things. The sky working or not shouldn’t be affected by camera direction.
I think the javadoc that says your near plane should be the same as the sphere radius is erroneous. So stop doing that.
If you actually want your near plane to be 10 for some reason then the sky may have problems anyway… or try using an even bigger radius. What was happening is that the sky was being clipped by the near plane.
I don’t know why it doesn’t work in your actual game. Since you have it working in the test program then now you have something to compare it to, at least.
I’ve been struggling to develop a simple test code which reproduces the bug I see in my game. It seems to have to do with the combination of a cube-mapped sky and all other textures in the view having lit textures. If I add an unlit geometry, the bug goes away. Does that ring a bell, by any chance?