Lines Being Culled

Hello,
I am working on a project where the user starts by drawing lines on the ground. The issue is that the lines are being culled depending on the camera angle. I am unsure of what causes this:
Not Culled: http://prntscr.com/fnsh9x
Culled: http://prntscr.com/fnshe0

In the line creation code, I am disabling depth test and setting cull face mode to off in the material. additionally, I am setting the geometry cull hint to Never, so I am unsure of what is causing this.

Here is the camera frustum perspective line: cam.setFrustumPerspective(70f, ((float) settings.getWidth())/settings.getHeight(), 0.1f, 1000f);

Let me know if there is something I can do to fix this. Thanks!

1 Like

Looking at the code you posted… (heheh)… You didn’t update the bounding box of your mesh and/or geometry.

1 Like

What do you mean?
Line line = new Line(start, end);
Geometry geo = new Geometry("", line);
Material material = new Material(Main.getApp().getAssetManager(), “Common/MatDefs/Misc/Unshaded.j3md”);
material.setColor(“Color”, ColorRGBA.Black);
material.getAdditionalRenderState().setDepthTest(false);
geo.setMaterial(material);
node.attachChild(geo);
This is the code. I don’t see what I am missing.

1 Like

As a test, try putting it in the transparent bucket.

2 Likes

Interesting, that worked. Why is that? And is there a better solution than this since the line isn’t technically transparent?

1 Like

It worked because it forced it to be drawn after the “floor”… which presumably is in the opaque bucket.

Because the lines are exactly on the floor if the floor gets drawn after then it might cover it up. You could either offset it up a little or play with the poly offsets in the material’s additional render state.

…or just leave it in the transparent bucket.

1 Like

Interesting, So I ran a test where I offset the line much higher than the floor, and it still disappeared. Your explanation definitely made sense, however, I am unsure why that is still an issue in this case. I disabled the depth test on the line, but that didn’t seem to make a difference. Just somewhat peculiar…

1 Like

Well, if the line is drawn first then depth test won’t matter. (which is clearly what’s happening)

If you offset it up and it still disappears then it’s the angle of the camera… the sorting is done based on point closest to the camera… and the opaque bucket sorts nearest to farthest.

Actually, I can’t really explain it based on just what I’ve seen in this thread but it’s definitely what’s happening. You will have to experiment a little… or just leave the lines in the transparent bucket. (That’s what I would do, probably.)

1 Like

I see. Very insightful. Thanks!

1 Like