NaviCube Anti-Aliasing (lack therof)

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
obelisk79
Veteran
Posts: 1061
Joined: Thu Sep 24, 2020 9:01 pm

NaviCube Anti-Aliasing (lack therof)

Post by obelisk79 »

unknown (1).png
unknown (1).png (5.28 KiB) Viewed 2698 times
Observation based on the screenshot above, the navi-cube does not appear to be drawn with anti-aliasing applied to it. I realize this is a purely cosmetic complaint but is this something that could be looked into?

Current AA settings preferences don't apply to the NaviCube, most likely due to the way it is drawn into the viewport. As a comparison, LinkStage/LinkDaily builds do not seem to display the same pixelation to edges/fonts.

Using Manjaro Linux and latest development appimages.
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: NaviCube Anti-Aliasing (lack therof)

Post by chrisb »

obelisk79 wrote: Thu Mar 24, 2022 9:07 pm Using Manjaro Linux and latest development appimages.
"Latest" can be already outdated one day later. Please always add your FreeCAD infos to such posts.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
obelisk79
Veteran
Posts: 1061
Joined: Thu Sep 24, 2020 9:01 pm

Re: NaviCube Anti-Aliasing (lack therof)

Post by obelisk79 »

chrisb wrote: Fri Mar 25, 2022 12:19 am "Latest" can be already outdated one day later. Please always add your FreeCAD infos to such posts.
FreeCAD_weekly-builds-28193-Linux-Conda_glibc2.12-x86_64.AppImage
Manjaro 64 Bit

I'm unable to paste the info directly from clipboard because I am only able to access the internet from a government computer and cannot install 3rd party software onto it. I run FreeCAD on a non-networked machine right now, as I am on a Navy ship out to sea.

Also, I believe this to still be the case as I have reviewed the git history here, and while I'm not able to fully understand all of the code, the comments do not imply that this has been addressed: https://github.com/FreeCAD/FreeCAD/comm ... viCube.cpp

This has been noted in the past by chennes and donovally (uwestoehr on the forum I think?) since this PR reworking the NaviCube:
https://github.com/FreeCAD/FreeCAD/pull ... -786992101
User avatar
chennes
Veteran
Posts: 3878
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: NaviCube Anti-Aliasing (lack therof)

Post by chennes »

I think you need to be looking at the code in View3DInventorViewer.cpp -- my read is that the MSAA is being applied to the framebuffer before the navicube is being drawn.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: NaviCube Anti-Aliasing (lack therof)

Post by onekk »

When speaking about Qt and interfaces there are many "layers" of complexity between the graphics hardware and the "toolkit".

Sadly without seeing what is used and what is implemented, maybe even in some obscure Qt setting around it is difficult to pinpoint the problem.

I have had recently many artifacts in FC and they were triggered to a chaneg in "mesa" library that I have to downgrade in my Arch Linux distribution as 22.0.0 was creating strange results.

Take in account that antialising could be even set in the WM or the DE or by Compositor if you use one, or maybe even by some settings in the Qt part, as some recent findings about "Disappearing Start page" has revealed.

This complexity sadly is not very easy to manage without knowing what "visualization chain" you are using.

Graphics hardware > OpenGl implementation > .... > .... > Qt.

It is not even to easy to pinpoint all the exact steps, I was directed to issue these commands when I have had problems:

Code: Select all

glxinfo -B 
and:

Code: Select all

 lspci -knn | grep -iA4 vga
Probably these could be a decent starting point in trying to see what graphics chain is use, and maybe solve things, if related.

Anyone know other commands, or ways to inspect what is used maybe at Qt level with "environment variables"

in Python console this could gave some ideas:

Code: Select all

print(os.environ)

Hope it helps

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
obelisk79
Veteran
Posts: 1061
Joined: Thu Sep 24, 2020 9:01 pm

Re: NaviCube Anti-Aliasing (lack therof)

Post by obelisk79 »

even in /src/Gui/NaviCube.cpp there are code comments mentioning that anti-aliasing needs to be added.

The NaviCube is drawn using QPainter. Now, according to the API you should be able to use something along the lines of the the following in the createCubeFaceTex() method right after paint.begin(&image);

"paint.setRenderHints(QPainter::Antialiasing);"

I've also tried using the following in that method:
beginNativePainting();
*paint the face here codeblock*
endNativePainting();


However when doing this, it has no affect on the drawn cube. Chennes may be correct in his assumption that the issue lies in how the NaviCube is applied to the framebuffer in View3dInventorViewer.cpp

Sadly it's a fair bit above my current level of programming knowledge to understand fully whats going on with how the cube is rendered. I even tried easter-egging things to try and get an improved result with no luck.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: NaviCube Anti-Aliasing (lack therof)

Post by onekk »

obelisk79 wrote: Mon Apr 04, 2022 3:40 pm even in /src/Gui/NaviCube.cpp there are code comments mentioning that anti-aliasing needs to be added.

Yes but the problem with most of the Gui things are that some "functions" are passed to the graphics chain, so if my "graphics drivers" has "no antialiasing" capabilities it is simply ignored.

Same as for advanced things like subpixel hints and so on.

For some graphics cards, at least on Linux there are different flavours, some uses a "framebuffer" some use "native rendering" some other use "proprietary dirvers" so having only informations about graphics card type is not enough.

For which I have asked if there is some way to have more information about the "graphics chain", see maybe:


https://wiki.archlinux.org/title/Intel_graphics

Only to see the complexity of the matter.

(usually on ArchLinux and Gentoo wiki you will find decent explanations on many things, sadly they are a wiki for a distribution, but "better than nothing")


Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: NaviCube Anti-Aliasing (lack therof)

Post by adrianinsaval »

what kind of graphics driver doesn't have anti alias?? I would think that would be a very basic feature
User avatar
obelisk79
Veteran
Posts: 1061
Joined: Thu Sep 24, 2020 9:01 pm

Re: NaviCube Anti-Aliasing (lack therof)

Post by obelisk79 »

Carlo,

The anti-aliasing for the NaviCube has nothing to do with the graphics stack. MSAA works in the viewport, but due to how it is drawn it doesn't apply to the NaviCube, this was tested on both Windows and Manjaro Linux using a NVIDIA RTX2060 GPU with robust proprietary drivers that are OpenGL API compliant. Additionally the same on an older laptop with NVIGIA 640LM mobile graphics and also while it runs off the intel iGPU. FreeCAD does not really take advantage of shaders and renders OpenGL to a framebuffer. Additionally, FreeCAD renders with MSAA even on something as minor as a Raspberry Pi, so while I understand your points I find them more distracting than enlightening.

Regards,
Obelisk
asegura
Posts: 16
Joined: Sat Jan 23, 2021 11:43 pm

Re: NaviCube Anti-Aliasing (lack therof)

Post by asegura »

Hi,

I just tried a little change in NaviCube.cpp and I think a got an improvement here. Look at the "RIGHT" text. and the outer borders (not the arrows though)

Image

I only changed one of the texture creation blocks and set the minification filter to LinearMipMapLinear:

Code: Select all

	texture->generateMipMaps();  // <-- also this, need to create mipmaps
	texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);  // <--
	texture->setMagnificationFilter(QOpenGLTexture::Linear);
Post Reply