Issue with "saveImage" and Parts with Transparency Nonzero

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
uwestoehr
Posts: 1425
Joined: Sun Jan 27, 2019 3:21 am

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Postby uwestoehr » Mon Jan 06, 2020 3:27 pm

UR_ wrote:
Mon Jan 06, 2020 6:32 am
If you miss this parameter just create a new one.
Just right-click and awake context menu.
Many thanks! This works.
wmayer wrote:
Fri Dec 27, 2019 12:16 pm
Werner, can this new parameter please there initially (without the need to add it manually)? Since this topic poped up already several times, it might also be nice to have this option in the preferences, or is there a reason why it should not be there?
UR_
Posts: 1184
Joined: Tue Jan 03, 2017 8:42 pm

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Postby UR_ » Mon Jan 06, 2020 4:02 pm

Perhaps available types of frame grabber (GrabFramebuffer, FramebufferObject, PixelBuffer, CoinOffscreenRenderer)
should be selectable by list box from SaveImage dialog.

Because GrabFramebuffer doesn't support other backgrounds, concerning list box should be greyed out while GrabFramebuffer is selected.
Also Height input box, because aspect ratio is fixed to that one from 3D view.
User avatar
uwestoehr
Posts: 1425
Joined: Sun Jan 27, 2019 3:21 am

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Postby uwestoehr » Mon Jan 06, 2020 5:05 pm

UR_ wrote:
Mon Jan 06, 2020 4:02 pm
Perhaps available types of frame grabber (GrabFramebuffer, FramebufferObject, PixelBuffer, CoinOffscreenRenderer)
should be selectable by list box from SaveImage dialog.
:+1:
wmayer
Site Admin
Posts: 15721
Joined: Thu Feb 19, 2009 10:32 am

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Postby wmayer » Tue Jan 07, 2020 12:57 pm

uwestoehr wrote:
Sun Jan 05, 2020 9:01 pm
So what do I have to do to get (not only PNG but also a JPG) that shows the scene exactly as I see it?
As soon as you have transparencies then you must use a file format that supports it. JPG doesn't support transparencies: https://de.wikipedia.org/wiki/Jpg#Visue ... te_Formate
User avatar
uwestoehr
Posts: 1425
Joined: Sun Jan 27, 2019 3:21 am

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Postby uwestoehr » Tue Jan 07, 2020 2:48 pm

wmayer wrote:
Tue Jan 07, 2020 12:57 pm
As soon as you have transparencies then you must use a file format that supports it.
It is not about transparency, it is about the image itself as I wrote.
With your new GrabFamebuffer option, the images look as I see the scene in FC and that is perfect. So all I and also UR_ want now is to have an option in the preferences to activate it. I fully agree with UR_ more detailed proposal: https://forum.freecadweb.org/viewtopic. ... 10#p358400
wmayer
Site Admin
Posts: 15721
Joined: Thu Feb 19, 2009 10:32 am

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Postby wmayer » Wed Jan 08, 2020 11:51 am

User avatar
uwestoehr
Posts: 1425
Joined: Sun Jan 27, 2019 3:21 am

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Postby uwestoehr » Wed Jan 08, 2020 1:23 pm

wmayer wrote:
Wed Jan 08, 2020 11:51 am
git commit 8e5151002
Many thanks. I will describe it in the Wiki ASAP. To do so, 2 questions:

Attached are images take with the now 4 available methods.
- What are their difference?
- the currently set default is "Offscreen (new)". But since this is the one most far away from what I actually see in FC, maybe another method should be the default.

------------------
The image dialog is a bit too large for my laptop screen -> I'll have a look the next days and make a PR.
Attachments
FBAS.png
Framebuffer (as is)
FBAS.png (50.85 KiB) Viewed 197 times
FBC.png
Framebuffer (custom)
FBC.png (44.89 KiB) Viewed 197 times
OO.png
Offscreen (old)
OO.png (37.13 KiB) Viewed 197 times
ON.png
Offscreen (new)
ON.png (30.34 KiB) Viewed 197 times
wmayer
Site Admin
Posts: 15721
Joined: Thu Feb 19, 2009 10:32 am

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Postby wmayer » Wed Jan 08, 2020 2:29 pm

- What are their difference?
Framebuffer (as is) = GrabFramebuffer:
If multi-sampling is off (i.e. no anti-aliasing) then it reads the image directly from the graphic renderer. If multi-sampling is on then it renders to a framebuffer and gets the image from there. The key part of this method is Qt's QOpenGLFramebufferObject class

Framebuffer (custom) = FramebufferObject:
It always uses the same technique as the latter method from above. Additionally it allows to set custom sizes and background

Offscreen (old) = CoinOffscreenRenderer:
It only uses pure Coin3d functions. The method however doesn't support multi-sampling, relies heavily on graphic driver and on many modern Linux systems it doesn't work at all any more.

It's a real off-screen rendering method that doesn't require an OpenGL window.

Offscreen (new) = default method
It's a replacement/alternative for Coin3d's off-screen rendering. Additionally it supports multi-sampling
The most important classes are Qt's QOffscreenSurface and QOpenGLFramebufferObject
- the currently set default is "Offscreen (new)". But since this is the one most far away from what I actually see in FC, maybe another method should be the default.
Have you enabled anti-aliasing in your settings? If not then set it to MSAA 8x and repeat all your tests again.
User avatar
uwestoehr
Posts: 1425
Joined: Sun Jan 27, 2019 3:21 am

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Postby uwestoehr » Wed Jan 08, 2020 3:41 pm

Thanks the the explanation
wmayer wrote:
Wed Jan 08, 2020 2:29 pm
Have you enabled anti-aliasing in your settings? If not then set it to MSAA 8x and repeat all your tests again.
This was off. Now I set it to MSAA 8x. But with this, I get in no case exactly what I see on screen in FC :o :

Without MSAA 8x I got with Framebuffer (as is) what I need.
Attachments
FBAI.png
Framebuffer (as is)
FBAI.png (82.49 KiB) Viewed 184 times
FBC.png
Framebuffer (custom)
FBC.png (82.48 KiB) Viewed 184 times
OSO.png
Offscreen (old)
OSO.png (58.6 KiB) Viewed 184 times
OSN.png
Offscreen (new)
OSN.png (52.25 KiB) Viewed 184 times
wmayer
Site Admin
Posts: 15721
Joined: Thu Feb 19, 2009 10:32 am

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Postby wmayer » Wed Jan 08, 2020 4:42 pm

Attached are your datum plane project and two Inventor files. The one Inventor file has been modified where all custom nodes are replaced with original Inventor nodes.

For the modified Inventor file the image looks correct while for the original file it looks bad. So the culprit must be one of the custom Inventor nodes which causes problems with transparencies.

I assume that the problem is introduced with realthunder's Link3 branch.
Attachments
Datum-plane.iv
(22.21 KiB) Downloaded 6 times
Datum-plane-org.iv
(31.63 KiB) Downloaded 6 times
Datum-plane-issue.FCStd
(17.98 KiB) Downloaded 8 times
cron