Today I found the answer myself. I do not understand this completely, but this solved the issue.
A problem arises when the vertices of the line extend beyond the approximation plane of the projection matrix defined for the scene (in my case, all the final vertices of the three lines). The solution is to manually copy the vertices of the lines within the truncation (thus, the vertices cannot go beyond the nearest plane!).
What happens to ndc0 and ndc1 when they are out of sight? If you look at the images, it seems that the XY components change sign (after they are transformed in the clip space!): This will mean that the W coordinate is opposite to normal, isn't it?
Without a geometric shader, the rasterizer should take responsibility for the clicks of these primitives outside the view, but since I presented the geometric shader, I need to calculate these results myself. Can anyone suggest me a link to this question?
source share