Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offscreen rendering #6808

Merged
merged 2 commits into from
Jun 21, 2022
Merged

Offscreen rendering #6808

merged 2 commits into from
Jun 21, 2022

Conversation

wwmayer
Copy link
Contributor

@wwmayer wwmayer commented Apr 28, 2022

Thank you for creating a pull request to contribute to FreeCAD! To ease integration, we ask you to conform to the following items. Pull requests which don't satisfy all the items below might be rejected. If you are in doubt with any of the items below, don't hesitate to ask for help in the FreeCAD forum!

  • Your pull request is confined strictly to a single module. That is, all the files changed by your pull request are either in App, Base, Gui or one of the Mod subfolders. If you need to make changes in several locations, make several pull requests and wait for the first one to be merged before submitting the next ones
  • In case your pull request does more than just fixing small bugs, make sure you discussed your ideas with other developers on the FreeCAD forum
  • Your branch is rebased on latest master git pull --rebase upstream master
  • All FreeCAD unit tests are confirmed to pass by running ./bin/FreeCAD --run-test 0
  • All commit messages are well-written ex: Fixes typo in Draft Move command text
  • Your pull request is well written and has a good description, and its title starts with the module name, ex: Draft: Fixed typos
  • Commit messages include issue #<id> or fixes #<id> where <id> is the issue ID number from our Issues database in case a particular commit solves or is related to an existing issue. Ex: Draft: fix typos - fixes #4805

And please remember to update the Wiki with the features added or changed once this PR is merged.
Note: If you don't have wiki access, then please mention your contribution on the 0.20 Changelog Forum Thread.


@github-actions github-actions bot added the Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD label Apr 28, 2022
@freecadci
Copy link

pipeline status for feature branch PR_6808. Pipeline 526907328 was triggered at 0850e37. All CI branches and pipelines.

@luzpaz
Copy link
Contributor

luzpaz commented Apr 29, 2022

@wwmayer this looks interesting, what does it do?

@wwmayer
Copy link
Contributor Author

wwmayer commented Apr 29, 2022

It renders a scene off-screen :)

Coin has an integrated off-screen rendering mechanism but it always lacked the possibility to support anti-aliasing or correctly handle transparent backgrounds and for several years it has stopped working for me completely.

So, the alternative we have implemented several years ago is using Qt's off-screen rendering capabilities combined with framebuffer objects.

Now this PR only exposes the corresponding C++ class to Python. This allows it to create high-quality images of a scene in true headless mode and thus could be used as the groundwork for a thumbnailer for XFCE that supports any file format that FreeCAD supports.

@luzpaz
Copy link
Contributor

luzpaz commented Apr 29, 2022

Fantastic! BTW, could this be used as an alternate (one-directional, STDOUT-esque if you will) GUI for running FC in headless mode?

@wwmayer
Copy link
Contributor Author

wwmayer commented Apr 29, 2022

What do you mean with alternative GUI?

@luzpaz
Copy link
Contributor

luzpaz commented Apr 29, 2022

What do you mean with alternative GUI?

Meaning, not using the FreeCAD regular GUI, but like a unix pipe (if you will) to a dialog of some sort showing the model being manipulated through the headless instance of FreeCAD

@wwmayer
Copy link
Contributor Author

wwmayer commented Apr 29, 2022

You could show the rendered image in a widget and use some buttons to control the headless FreeCAD. But an interaction with the scene won't be possible and also the rendering might be a bit slow.

@yorikvanhavre
Copy link
Member

Fantastic! There are a lot of possibilities there...

I also think it would be impractical to run FreeCAD in another GUI that way, as it would need to re-render the scene 30 times per second or something like that, no sure that would be achievable... Better path would be to export the coin scene directly to some other format (webgl, etc...) and let the other app do the rendering

@luzpaz
Copy link
Contributor

luzpaz commented May 3, 2022

CC @ickby (you may be interested in this since you've been working on https://github.com/OpenCollaborationPlatform/CollaborativeFC)

@adrianinsaval
Copy link
Member

does that mean it could be also used to generate thumbnails even for FCStd files that don't have the embedded thumbnail?

@wwmayer
Copy link
Contributor Author

wwmayer commented May 3, 2022

does that mean it could be also used to generate thumbnails even for FCStd files that don't have the embedded thumbnail?

Basically yes. However, it's not my primary goal to implement a general thumbnailer. I just wanted to make the real off-screen rendering working again. The thumbnailer is just a side-product of it.

For a thumbnailer there are a few points to consider:

  • The thumbnailer would have to load FreeCAD in headless mode and if there is a directory with hundreds of files I am not sure how much it would freeze the system
  • If a STEP, STL or any other data file is relatively big then loading it can be quite time consuming. So, there should be a certain limit of the file size for that an image is created.

@wwmayer wwmayer merged commit b416c42 into FreeCAD:master Jun 21, 2022
@wwmayer wwmayer deleted the offscreen branch June 25, 2022 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants