Anti-Aliasing

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
wmayer
Site Admin
Posts: 17057
Joined: Thu Feb 19, 2009 10:32 am

Re: Anti-Aliasing

Postby wmayer » Mon May 12, 2014 2:41 pm

There are various problems in setAntiAliasingMode/getAntiAliasingMode. Note, if multi-sampling is off then SoQtGLWidget::getSampleBuffers() always returns 1 and not 0.

Here is a suggestion how the implementation should look like:

Code: Select all

void View3DInventorViewer::setAntiAliasingMode(View3DInventorViewer::AntiAliasing mode)
{
    int buffers = 1;
    SbBool smoothing = false;

    switch( mode ) {
      case Smoothing:
          smoothing = true;
          break;
      case MSAA2x:
          buffers = 2;
          break;
      case MSAA4x:
          buffers = 4;
          break;
      case MSAA8x:
          buffers = 8;
          break;
      case None:
      default:
          break;
    };

    if (getGLRenderAction()->isSmoothing() != smoothing)
        getGLRenderAction()->setSmoothing(smoothing);
#if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 5)
    if (getSampleBuffers() != buffers)
        setSampleBuffers(buffers);
#else
    if (buffers > 1)
        Base::Console().Warning("Multisampling is not supported by SoQT < 1.5, this anti-aliasing mode is disabled");
#endif
}

View3DInventorViewer::AntiAliasing View3DInventorViewer::getAntiAliasingMode() const
{
    if (getGLRenderAction()->isSmoothing())
        return Smoothing;

#if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 5)
    int buffers = getSampleBuffers();
    switch(buffers) {
      case 1:
          return None;
      case 2:
          return MSAA2x;
      case 4:
          return MSAA4x;
      case 8:
          return MSAA8x;
      default:
          const_cast<View3DInventorViewer*>(this)->setSampleBuffers(1);
          return None;
    };
#else
    return None;
#endif
}
I can't test this right now because on my Windows machine I don't have this issue at all.
ickby
Posts: 3005
Joined: Wed Oct 05, 2011 7:36 am

Re: Anti-Aliasing

Postby ickby » Mon May 12, 2014 2:50 pm

Yea, I had something like this in mind. Could have guessed that setting the values so often bringes trouble. But samplebuffers == 1 suprises me, never even thought about that!
ickby
Posts: 3005
Joined: Wed Oct 05, 2011 7:36 am

Re: Anti-Aliasing

Postby ickby » Mon May 12, 2014 5:20 pm

It took me a while to figure out why my branch with the fix could no rebase on master... than I realized Werner was faster again :)

This fixes the image plane issue, however, I couldn't reproduce the black/normal switching, so no idea if this is gone too.
jmaustpc
Posts: 10779
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Anti-Aliasing

Postby jmaustpc » Tue May 13, 2014 1:35 pm

Thanks for everything guys, this seems to be working properly now.

The tool menu save picture is still not producing the same thing as a screen shot, it does not show the partly obscured part of the cylinder in this example with a default Part cube and cylinder with the cube transparency set to 50 percent, or any other number other than 0,

this is from the tools menu save picture
50transpnothil.jpg
50transpnothil.jpg (15.97 KiB) Viewed 3714 times
this is from a screen shot application, notice the cylinder/cube common volume is now display properly
50transpnothilscreenshot.jpg
50transpnothilscreenshot.jpg (15.83 KiB) Viewed 3714 times
User avatar
yorik
Site Admin
Posts: 12184
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels, Belgium
Contact:

Re: Anti-Aliasing

Postby yorik » Tue May 13, 2014 2:04 pm

screenshot.jpg
screenshot.jpg (123.97 KiB) Viewed 3707 times
FreeCAD has never been so gorgeous! Congrats, guys!!!
jmaustpc
Posts: 10779
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Anti-Aliasing

Postby jmaustpc » Tue May 13, 2014 2:47 pm

yorik wrote:FreeCAD has never been so gorgeous! Congrats, guys!!!
almost so good that you don't need ray tracing any more :D

almost
User avatar
yorik
Site Admin
Posts: 12184
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels, Belgium
Contact:

Re: Anti-Aliasing

Postby yorik » Thu May 15, 2014 2:07 am

I don't get tired of this... It might be a small change, but for me it's a new world that opened! The texts with antialiasing really kick ass... The aspect of freecad is highly professional now
screenshot.jpg
screenshot.jpg (182.25 KiB) Viewed 3673 times
User avatar
shoogen
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: Anti-Aliasing

Postby shoogen » Mon May 19, 2014 9:49 am

yorik wrote:I don't get tired of this... It might be a small change, but for me it's a new world that opened! The texts with antialiasing really kick ass... The aspect of freecad is highly professional now
I see where is going to end. The first two items in the release notes are going to be anti-aliasing and transparency. And of course the splash screen for 0.14 would have to show those features ;)
I found that that the anti-aliasing is the first important feature i can't use with software rendering.
Now it finally pays of to go through the hassle to install all this Bumblebee stuff.
ulrich1a
Posts: 1958
Joined: Sun Jul 07, 2013 12:08 pm

Re: Anti-Aliasing

Postby ulrich1a » Fri Jun 13, 2014 10:17 pm

I wanted to see the Anti-Aliasing with Debian and a AMD HD7850 graphic card. So I installed Jessie and than compiled and installed mesa, glamor and xf86-video-ati according to this post: http://forums.debian.net/viewtopic.php? ... 15#p536603
I used llvm 3.4 and not llvm 3.3 as mentioned in the recipe.
I now sometimes see the effect, but very seldom. It vanishes as the mouse touches the model.
Does someone got the Anti-Aliasing to work with the mesa-open-source-driver?

Ulrich
kwahoo
Posts: 382
Joined: Fri Nov 29, 2013 3:09 pm
Contact:

Re: Anti-Aliasing

Postby kwahoo » Sat Jun 14, 2014 12:23 am

ulrich1a wrote: Does someone got the Anti-Aliasing to work with the mesa-open-source-driver?
Ulrich
Yes, I got. Intel (i965 driver) and AMD (R600g), both Mesa 10.3-devel. Unfortunately your driver (radeonsi) is less mature, and you've encountered a driver bug, I think.