Graphical Glitches on Large Sphere Meshes

Hi all,



I’ve been lurking around these forums for the last few months now, learning what I can about JME and abusing the search engine to help with problems I encounter. Unfortunately, I have hit one problem I can’t seem solve, so I’ve decided signed up and ask for help. I’m almost certain it’s a simple problem that the more experienced JME code monkeys have seen before, but my lack of experience with JME is stopping me from getting past it.



I’ve basically created a model of the solar system, (original I know) and I’m having an issue with the size of the spheres I’m using. I want to be able to create car sized objects and Jupiter sized objects and have the user be able to navigate around them at any scale in-between. However when I create very large spheres, somewhere in the order of 1500+ units, I get a strange graphic anomaly on the texture, which is being lit be a PointLight. Anything under 1500 and the glitch disappears, but that means my small objects are far too small (less than 1 unit). I’ve even try replacing the object with a Box and a geosphere from Milkshape, but the same problem occurs.



The odd thing is, if I remove the skybox I’m using, the glitching texture appears fine, though as you can see in the videos, the marker lines and labels appear to flicker through the spheres from time to time, leading me to think it’s maybe a z-order issue. I remember JME2 having a Z-order control class but I can’t find a similar class in JME3. I know this is probably a really simple problem but I just can’t find a solution. I’m not very experience with graphical systems, the bulk of my coding experience is with DB’s and DB front ends, so I imagine I’m missing a fundamental principle of some kind. Maybe surface normals or something like that. Any help would be much appreciated.



With SkyBox

http://i107.photobucket.com/albums/m301/aaronlittle/scene.jpg



http://www.youtube.com/watch?v=r7d2sHPuFS4





Without SkyBox

http://i107.photobucket.com/albums/m301/aaronlittle/scene1.jpg



http://www.youtube.com/watch?v=RFR_UkrtVqw



PointLight Initialising code

sun = new PointLight();

sun.setPosition(new Vector3f(0,0,0));

sun.setRadius(1e9f);

sun.setColor(ColorRGBA.White);

rootNode.addLight(sun);





Sphere Initialising code

object = new Sphere(128,128, size/CONST);

geom = new Geometry(name, object);

object.setTextureMode(Sphere.TextureMode.Projected);

TangentBinormalGenerator.generate(object);

mat = new Material(am, “Common/MatDefs/Light/Lighting.j3md”);

mat.setTexture(“m_DiffuseMap”, t);

mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

geom.setMaterial(mat);

geom.setModelBound(new BoundingBox());

geom.setLocalTranslation(tmpf);

geom.updateModelBound();



Geom Update in simpleUpdate()



geom.setLocalTranslation(screenPosition);

geom.updateModelBound();



The code is pulled out of various classes but that’s the crux of the objects on screen.



P.S. This is the first time I’ve used the forum and I don’t see a preview mode, so forgive me if the formatting of this post is a little screwy.

That’s a depth issue



the depth buffer goes from 0 to 1 and is not linear. This means it keeps a lot of accuracy for objects near the camera and few for far objects.

So, if your scene is 100m deep, 0 to 0.99 will represent objects that are in the 10 first meters and 0.99 to 1.0 the rest.

Usually this is fine, because you always need more accuracy for nearby objects.



In your case your planet is so far that it’s probably in the 0.99 to 1.0 range.

Then…the issue with the skybox is that it’s always rendered at depth = 1.0 (to ensure it’s always behind everything in the scene) so you have some z fighting with your planet that is faaaaar away.

What you could do, is increase the accuracy of the depth buffer (in the settings of the app you can bump it up to 24bits), but i guess it’s not really a solution (not every hardware support more than 16 bits).

The better way I guess would be to scale down your scene let’s say 10 times or 100 times and see what it does.

1 Like

Thanks for the response nehon. I have scaled the scene down and it does indeed eliminate that effect. Unfortunately, when I have a planet at a screen size of say 1200, the objects like space craft and satellites end up having a screen size of much less than 1 and I’m finding it hard to even view objects of that size. One tick of the mouse moving has the object swinging from one side of the screen to the other. I guess I could look at scaling mouse velocities or find some other means to scale the objects as a player approaches them. Thanks for the info though. It’s gives me a place to start. :slight_smile:

Okay here’s some questions:

What happens when you remove the line “sun.setRadius(1e9f)”?

What about removing the line “mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha)”?

Also, I assume you’re using jME3-alpha3?



Also, all the lines where you have the words “modelbound” are not needed, model bounds are handled for you automatically in jME3

Hi Momoko Fan. I removed those first two lines “sun.setRadius(1e9f)” and “mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha)” and there was no change, which is not all bad news. At least I now know those lines aren’t absolutely necessary. Yes, I’m using JME3-Alpha-3. I’m using the JMonkeyPlatform rather than using my usual IDE though.



Thanks for the tip on the ‘modelbound’ thing. I was used to working in JME2 and I guess I just assumed the were still needed.