Is there a way to split a gl line once it is the shader?

135 Views Asked by At

I have a view where I can display the Earth, and satellites in a 3d view, or 2d view (Mercator). I can send the XYZ data to the shader, and the shader will do the appropriate display for 3d or 2d. In 2d, it does an XYZ to Lat/Lon/Alt conversion in the shader. The problem is as follows: In the 3d view, everything is great:

3d View

The 2d view looks good, except for lines that in 3d cross the +/- 180 longitude boundary. The line is of course across the entire earth. What would be better, is if I could break the line into 2 segments (the proposed yellow lines below) 2d View

I can't really fix this in the vertex shader, because I only have a single vertex to work with. All options I have come up with are ugly:

  1. Move LLA conversion to CPU instead of GPU, and split lines there. (Waste of CPU, and doubling of data)
  2. Multiply all vertices to have "phantom segments" to add segments, and turn segments on/off by changing transparency (up to 4x times the data to the vertex shader, and lots of extra transparent lines to the fragment shader).

Final limitation: This is webgl, so I can't have a geometry shader.

Does anyone have some shader magic or cleverness so that I can keep this on the GPU?

0

There are 0 best solutions below