Author Topic: Have somebody implemented thick line algorithm?  (Read 371 times)

Siekmanski

  • Member
  • *****
  • Posts: 1553
Re: Have somebody implemented thick line algorithm?
« Reply #15 on: July 06, 2018, 08:58:07 PM »
Hi HSE,

Just my thoughts,

If you want to calculate a thick line, you could use the bresenham algorithm to draw a line pixel per pixel.
Draw more parallel next to each other to get a thicker line, each color a bit darker to get some antialiasing.

Or, use a texture quad with an antialiased circle or other pattern in it.
Then calculate the angle of the line, rotate the 4 quad coordinates and stretch it along the length of the line.
So that the thickness of the line is equal at any angle of the line.

Or, use the helper libraries from OpenGL, DirectX or the slow GDIplus functions.

The fastest but not the easiest way is, write a pixelshader antialiased line routine.

Here is a pixelshader antialiased line example from Inigo Quilez,
Creative coders use backward thinking techniques as their strategy.

HSE

  • Member
  • ****
  • Posts: 717
  • <AMD>< 7-32>
Re: Have somebody implemented thick line algorithm?
« Reply #16 on: July 07, 2018, 12:28:36 AM »
Thanks Siekmanski!

Without rotation nor antialiasing I have a very nice "Gut" effect  :biggrin:

Siekmanski

  • Member
  • *****
  • Posts: 1553
Re: Have somebody implemented thick line algorithm?
« Reply #17 on: July 07, 2018, 03:46:11 AM »
:t
Creative coders use backward thinking techniques as their strategy.

HSE

  • Member
  • ****
  • Posts: 717
  • <AMD>< 7-32>
Re: Have somebody implemented thick line algorithm?
« Reply #18 on: July 07, 2018, 09:47:45 AM »
Here is Biterider idea. A lot simpler than what I was thinking.

Drawing a complete line 1000 times take:

    GDI+    10500ms
    GDI        1550ms 
    bigpixel   1010ms
    pipeline    500ms

Of course they are different things, but comparisons are interesting.

HSE

  • Member
  • ****
  • Posts: 717
  • <AMD>< 7-32>
Re: Have somebody implemented thick line algorithm?
« Reply #19 on: July 08, 2018, 05:52:59 AM »
After some hours (trying to remember trigonometry :biggrin:)

Better now but 1000 complete lines take 1420ms 810ms (Sorry, I forget part of color calculation inside loops).  It's similar to big pixel  (now only points corresponding to parallel lines like Biterider idea) that is taking 478ms.

I think that because of dark margin antialiasing is unnecesary with a black background.

Thanks. Regards
« Last Edit: July 09, 2018, 03:11:12 AM by HSE »