Anti-Aliasing

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Anti-Aliasing

Post by ickby »

Hello,

for quite some time I'm unsatisfied with the possible anti-aliasing, which looks like this for me:
Smoothing.png
Smoothing.png (43.73 KiB) Viewed 5934 times
Bassicly it uses openGL line and vertex smoothing which works well for sinlge lines (e.g. the grid). However, lines on shapes have a very ugly white border (e.g. cube). Additionaly, shape borders whithout edges are not anti-aliased (e.g. cylinder).

So I digged into Anti-Aliasing and openGL just to find out that the more advanced stuff is already possible in Coin. Here the same scene with multipass (4x) enabled:
MPAA 4x.png
MPAA 4x.png (26.58 KiB) Viewed 5934 times
The edges look very good, but the color loss is annoying. Then there is multisampling (which actually already is implemented in FreeCAD, just not exposed in the preference dialog):
MSAA 8x.png
MSAA 8x.png (52.67 KiB) Viewed 5934 times
I propose to add the multisampling (with different passes, 2x,4x,8x) to the preferences as alternative to the current smoothing which should stay as it is the fasted. Multipass can be omitted as noone is going to use it. I would implement a dropdownbox with all options, what do you think? I can provide a pathc with the rather smaller changes once we agreed on the best options.
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Anti-Aliasing

Post by quick61 »

Coming at this from a user standpoint, I think anything that helps to improve the visual aspect of FreeCAD can only be a good thing for the project, especially for the new / casual user. There was another topic started by jriegel - Mirror bottom in Z- that discussed some of the not used features of Coin. I sure wouldn't mind seeing this, that, and some of the other stuff like advanced lighting and shadows, etc. added to FreeCAD.

At any rate, this looks like a good starting point to me.

+1

Mark

Edit - Do you have a current branch that can be pulled for testing?
This post made with 0.0% Micro$oft products - GOT LINUX?
danielfalck
Posts: 395
Joined: Fri Oct 07, 2011 8:58 pm
Location: Beaverton,Oregon, USA
Contact:

Re: Anti-Aliasing

Post by danielfalck »

+1 also. Go for it.
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Anti-Aliasing

Post by NormandC »

Pimp my FreeCAD! :P
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Anti-Aliasing

Post by wmayer »

Any idea whether it's possible to improve some transparency bugs as shown here? viewtopic.php?f=3&t=6037&hilit=transparency
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Anti-Aliasing

Post by jmaustpc »

Hi Ickby
this would be a nice improvement.

How much effect would this have on speed, with complicated models? What effect on minimum hardware requirements? I think any GPU from the last 15 years would cope with this, am I right?

Is this something that would benefit from multi-threading with TBB in OCE?

Will this allow us to set the tessellation value to a larger number but still get good looking curves?
wmayer wrote:Any idea whether it's possible to improve some transparency bugs as shown here? viewtopic.php?f=3&t=6037&hilit=transparency
I was going to ask that as well. :-)


Jim
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Anti-Aliasing

Post by yorik »

Excellent! Go for it!
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Anti-Aliasing

Post by ickby »

Hello,

thanks for the feedback, I'm going to provide a patch.
How much effect would this have on speed, with complicated models? What effect on minimum hardware requirements? I think any GPU from the last 15 years would cope with this, am I right?
It will definitly put some strain on the hardware, but therefore it is optional and old cards will go fine without it. The Multisampling is a Hardware anti-aliasing method, so it will highly depend on your card. My home nvidia has no problems with the example scene and 8 passes, my work-notebook with intel card went down with 4 passes. So thisis something for the guys with big computing power, but still nice to have.
Is this something that would benefit from multi-threading with TBB in OCE?
No, this is entirly done on the rendered scene right inside the graphics card, it has nothing to do with the tesselation.
Will this allow us to set the tessellation value to a larger number but still get good looking curves?
No, all it does is to make look straight lines not grainy but smooth. So if occ tesselates a circle with 3 edges, the 3 edges will look smooth but the circle ist still a triangle, a nice looking one thought.


@Werner:
Any idea whether it's possible to improve some transparency bugs as shown here?
It lookes like the transperency render order or some depth values are wrong, and after some diging into it the problem seems to be that FreeCAD View3dInventorViewer messes with the zbuffer while rendering. If you comment out all calls to

Code: Select all

glDepthRange
in

Code: Select all

void View3DInventorViewer::renderScene(void)
the trancperency renders nicely. Now I can't oversee the whole impact of that change (as I'm not sure what get's drawn in the frontroot node) so I can not provide a fix. But maybe this information gives you some hints for solving this.
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Anti-Aliasing

Post by wmayer »

ickby wrote:@Werner:
Any idea whether it's possible to improve some transparency bugs as shown here?
It lookes like the transperency render order or some depth values are wrong, and after some diging into it the problem seems to be that FreeCAD View3dInventorViewer messes with the zbuffer while rendering. If you comment out all calls to

Code: Select all

glDepthRange
in

Code: Select all

void View3DInventorViewer::renderScene(void)
the trancperency renders nicely. Now I can't oversee the whole impact of that change (as I'm not sure what get's drawn in the frontroot node) so I can not provide a fix. But maybe this information gives you some hints for solving this.
Great, I'll have a look at it tomorrow to see how it looks like.
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Anti-Aliasing

Post by wmayer »

Yes, disabling the glDepthRange does the trick. Apparently the changes were made to allow to increase the performance for the highlighting of the SoFCSelection node:
http://free-cad.svn.sourceforge.net/vie ... 88&r2=2648
http://free-cad.svn.sourceforge.net/vie ... 48&r2=2649
The two changes give this change:
http://free-cad.svn.sourceforge.net/vie ... 88&r2=2649

Now the SoFCSelection node has been almost replaced by SoFCUniqueSelection where we don't need the performance boost of SoFCSelection any more because the part shapes now only use a single shape node for all its faces, edges and vertexes instead of an own one for each sub-element.

But I have no idea if disabling glDepthRange causes a regression somewhere and thus I think we should do the change after 0.14 is out so that we have more time for testing.
Post Reply