NodeMaterial and CreateLines bug (lines disappear)

While doing a lot lately on my project I noticed a very bad behavior of lines in front of models with NodeMaterial.


So on the image, we got lines with:

line.edgesWidth = 10;
line.edgesColor = color;

and they are in front of NodeMaterial with nothing else then just color:


My scene is big and my camera is placed in a distance and while rotating part of the lines that intersect with the model with NodeMaterial it’s disappearing. Actually, it looks like rendered edges are gone, but only for certain angles and it happens in 2 places pre 360 degrees rotation.

I made a PG to demon this:


It’s purely visible during the rotation, and when you have a lot of them next to each other it looks like they disappear.


On top of that, the blue line is always in front of the yellow line. They are aligned based on when in code the lines were added then based on their 3D position:


I do not see any problem with what I’m doing. In my project, this is more complex but while making simple PG this is also visible. The situation is more visible when I use alpha in a shader (at least for me).

I left nodes in NME to be connected after like this:


The alpha puts more problems on top of this. Without the extra depth, pass meshes become transparent and they are not covering everything. I will try to do a separate PG for this when I got time. But now the lines are a bigger problem, cause I can’t find a solution to that.

Hello you can try to force the NodeMaterial to ignore alpha:

The two lines and the ground are considered to be transparent objects, so they don’t write to the depth buffer and they are sorted from back to front for rendering. This sorting won’t work on some angles, as you could see.

You should make the lines be considered as opaque by setting useVertexAlpha = false when creating them.

Also, the edge renderer disables the depth write setting of the line shader, that’s why the order of the green and blue lines can somewhat be wrong. You can enable this setting by using scene._edgeRenderLineShader.disableDepthWrite = false;:

Actually I can’t ignore alpha cause I will be using it. I will make PG with it tomorrow afternoon. Problem is that this only shows up with the distance for some reason.

And this is a solution for me :slight_smile: Worked very nice. Im not bothered by the depth at the moment but this disappearing thing was a problem.

Tomorrow I will try to do another. PB with weird alpha behaviour. I need to set up additional z depth pass but I do not think that this is needed, I probably am missing something, like here.

Thank you for help :slight_smile: