09-14-2024, 01:18 AM
(09-13-2024, 10:42 PM)TerryRitchie Wrote: Ok, I found that thread on the old site: https://qb64forum.alephc.xyz/index.php?P...pic=3813.0I _think_ the idea is that if you look at the drawing as a series of horizontal (or vertical) lines, any particular point cannot have more than one segment of it's color on the line. IE. If you have a green point and a blue point, you'll never get a sequence of 'green-blue-green' pixels in a line, it will always have a single segment of green and a single segment of blue (assuming both colors appear on the line).
This code is fast! I'm picking it apart to make sense of it.
You can use that fact to throw out many of the points without calculating their distance - if you find that pixel Y=49 is colored by a point but Y=50 is too far away (because there's already another point that is closer), then you don't need to look at the pixels past Y=50. None of those pixels can be colored by your current point because you already finished its segment in the line, the color will never appear again until you start the next line.
There's probably some extra logic you can add to make it even faster - if you have lots of points, most lines are probably only colored by a small portion of them. You could process the points by Y distance to the line (when using horizontal lines) and stop looking at points if every pixel on the line is already colored by a closer point than any of the points left (the Y direction to the line is the absolute minimum distance a point can have to the line).
That said I believe my shader approach is still faster it's the same approach you did, but the GPU can parallelize the process so much that it doesn't matter.