Hello,
I am having some issues with the detail of lines. I am using the line class, which is essentially a mesh with 2 endpoints and the mode of “lines”. I get this level of detail currently: http://prntscr.com/fppak0. It would be better if these faded more into the distance, but I am unsure of how to do that. I don’t believe that LOD will fix that as there are only 2 vertices, so “removing” vertices doesn’t seem to help. I know the line width is constant, which I am guessing is the source of the problem. Even a 1px line height will create this provided there are enough lines. Is there any way to get around this? I was thinking perhaps a custom fragment shader, but I am not sure how to do that, or if it’s even possible. Thanks!
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);
geo.setQueueBucket(RenderQueue.Bucket.Transparent);
node.attachChild(geo);
Here is the code. Nothing special.
One way to make the lines “fade” would be to break them into short segments and draw each segment in a different color, depending on how far it is from the camera.
Shader based “fog” would work, too… but requires shader hacking. There have been a few forum posts about it, though. It’s not hard to hack into lighting or unshaded.
Thanks for these ideas!
If you still want to know a shader approach, or you want a gradual fade out so lines up close aren’t transparent at all (waaay easier with custom shader than messing with verts etc.) I think this would get you started on that…
//Vertex shader
varying vec4 positionProjectionSpace;
...
positionProjectionSpace = gl_Position; //Send to frag shader, declare the same varying
positionProjectionSpace.z = distance
Use a value calculated from that to set a variable value for gl_FragColor.a (alpha).
Thank you for the starting blocks. This will help out greatly!