Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

FXAA

Participant ,
Mar 04, 2017 Mar 04, 2017

Hi. I've drawn a curved line but it's very jagged and don't know how to smooth it. Does anyone know if it's possible to implement FXAA or a similar method?

I've considered drawing my line at a much higher res and then downscaling, but I think FXAA would be more efficient. Thanks!Screen Shot 2017-03-05 at 2.42.05 am.png

TOPICS
SDK
2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 05, 2017 Mar 05, 2017

Hi James!

'Super sampling' (writing at higher scale then reducing) gives good results, but you'll have to handle large EffectWorlds.

It used to be a bummer, but nowadays, machines can deal with it, so it can be an easy way to go.

I don't know of any built in function for FXAA. I'm using OpenGL, so I just added a FXAA shader...

But you could adapt it to an iteration function pretty easily. You'll have to try to be sure, but I think Super Sampling can be faster than iteration.

Otherwise, if you're only drawing lines, the easiest is to draw antialiased lines directly!

You can check this link https://en.wikipedia.org/wiki/Xiaolin_Wu

Hope it helps!

François

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 05, 2017 Mar 05, 2017

Thanks for the info Francois. Super noob question, can AMD cards run FXAA? I believe it was developed by an Nvidia employee so it wouldn't surprise me if they kept it to themselves.

I did see that link, would be good but I'm doing curved lines .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 06, 2017 Mar 06, 2017

Well, any card can run it, as long as you write your own shader. Cos' it doesn't rely on any specific function, it is very basic Glsl.

I use a slightly modified version of this one: (Tested) Fast Approximate Anti-Aliasing (FXAA) Demo (GLSL) – Page 3 – Geeks3D

You can start from there if you want to implement it for an AE iteration function.

Now about curves: curves can be seen as straight segments put together! So you can split your curves in pieces and write them already antialiased. 🙂

Cheers,

François

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 06, 2017 Mar 06, 2017

Great, thanks for the link!

I'm using penner's easing to draw my curved line, I think it's a little advanced for me to implement wu's algorithm into that but it's nice to know it can be done.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 06, 2017 Mar 06, 2017

If you're using Penner's easing (or bezier, or actually a lot of algorithms!), you probably have a 't' variable, varying from 0 to 1 along the curve, right?

Instead of drawing pixels one by one, you can draw a small segment with wu's algorithm each time.

Here's a pseudo code for a curve split in 100:

A_FloatPoint     previousPoint = easing( easing_parameter1, easing_parameter2, 0);// startPoint of the curve, i.e at t == 0

A_FloatPoint     newPoint;

for (float tf = 1; tf <= 100; tf++) {

     newPoint = easing( easing_parameter1, easing_parameter2, tf * myCurveLength / 100);//get newPosition along the curve

     drawSmoothLine(     previousPoint, newPoint);//draw segment from previous point to new point with wu's algorithm

     previousPoint = newPoint;//update previous point with new point's position, so you don't need to re-compute it

}

Hope it helps!

Cheers,

François

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 12, 2017 Mar 12, 2017

Thanks for that code Francois. Unfortunately I'm putting this plugin on the backburner for now as I just learned how difficult it is to make a curved line that's wider than 1px

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 12, 2017 Mar 12, 2017

Well, there is a way, close to what the stroke effect does:

_create a PF_EffectWorld the size of your line width. This will be your brush.

_fill it with a circle of your color. Here you can make the circle slightly blurry (lets say 1 pixel or 2).

_copy your brush along your path with WorldTransform.

Tada! You have an antialiased thickline!

Not the most efficient in terms of memory, and transparency can be an issue, but it's easy to do. 🙂

Cheers,

François

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 13, 2017 Mar 13, 2017
LATEST

You could also make use of OS libraries - Quartz on Mac and GDI+ on Windows. They're a bit fiddly to get working - you need to set aside some memory for a bitmap, and each library has its own way of setting things up, but I managed to figure it out 😉 If you search for GDI+ on here you may find some old posts from me asking questions about doing this.

These libraries provide functions for drawing all sorts of things antialiased, nice and fast using the GPU. I used them extensively for my plugin qp Grade Assistant, which was my first native plugin. I'd be happy to share some code with you if you want to get in touch privately.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines