News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Have somebody implemented thick line algorithm?

Started by HSE, June 24, 2018, 07:10:53 AM

Previous topic - Next topic

Siekmanski

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 a strategy.

HSE

Thanks Siekmanski!

Without rotation nor antialiasing I have a very nice "Gut" effect  :biggrin:
Equations in Assembly: SmplMath

Siekmanski

Creative coders use backward thinking techniques as a strategy.

HSE

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.
Equations in Assembly: SmplMath

HSE

#19
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
Equations in Assembly: SmplMath

daydreamer

Quote from: HSE on July 06, 2018, 08:20:49 AM
Quote from: daydreamer on July 06, 2018, 04:16:33 AM
wonder how it looks with dx9 line or poly used as line with fullfledged hardware antialias filter?

Fanatics of DirectX assume that everybody know something that I don't know.

I found examples to draw a detailed tiger, planets in movement... but none to draw only a line  :biggrin:
I didnt tell you because I am a dx fanatic,I told you because I want to help you and other members getting all alternatives to choose from otherwise you dont get the whole Picture
dx9 drawprimitive you see mostly TRIANGLELIST,TRIANGLESTRIP, less known is TRIANGLEFAN
found this interesting link
http://zophusx.byethost11.com/tutorial.php?lan=dx9&num=10&i=1

actually wanted to ask question on whats smallest line algo?fpu or cpu drawing to a backbuffer I mean?
one initial fdiv smallest/biggest distance and fadd that and fadd 1 for each pixel in a loop?
same with fixed Point and cpu?but that maybe requires additional code with many bitshifting?

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

HSE

Quote from: daydreamer on August 19, 2018, 12:21:08 AM
I didnt tell you because I am a dx fanatic
Don't worry, the writer of that article also is a fanatic.  :biggrin:

Apparently the "line" is only one code line.

If You know were to put that line, fantastic  :t

Nowhere there is a working full program source code to draw a simple line. There is tutorials  with everything you need to draw a planetary system in movement or things so complex like that.

It's very interesting and perhaps some day I will study those tutorials. But now I'm not going to read 11 tutorials to draw a line  :biggrin:

Quote from: daydreamer on August 19, 2018, 12:21:08 AM
actually wanted to ask question on whats...

My english is a little limited (is what in this forum is know as pseudo-english). I really don't understand what you ask. Try to make complete questions,  different question in different lines, and capital letters sometimes are usefull  :t
Equations in Assembly: SmplMath