rbdl / rbdl-toolkit

Application for visualizing and working with rbdl models
European Union Public License 1.2
19 stars 11 forks source link

Render Image, Image Sequence and Video all produce blank images #23

Open idlebear opened 3 years ago

idlebear commented 3 years ago

As the title suggests, creating a model with an animation and attempting to render it results in a series of blank images.
The Qt library is writing:

QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined 

to the terminal window.

Source pulled as of Feb 13, 2021. Qt library: 5.15.2.

ju6ge commented 3 years ago

Hey, can you provide more details, I have been aware of that warning but as of yet I have not run into any trouble on multiple systems. Meaning on my test systems (arch workstation, multiple virtual machines running different versions of Ubuntu and a Macbook Pro) the warning also appears, but the images/series/video render just fine.

So this might be a case of system/hardware dependent behavior.

idlebear commented 3 years ago

Probably system? I just tried it with the 1.1.1 app image and got the same result -- a directory full of 8.2kb empty images. I'm running Ubuntu 20.04 with a 4k display.
The app image also crashes when the render completes (this is new behaviour, the system built version didn't segfault). Let me know if you want display driver details, etc.

ju6ge commented 3 years ago

I think the most probable explanation is the graphics stack. What graphics card do you use and what driver are you using?

The AppImage is build using qt5.14.2 because packing the AppImage with 5.15 resulted in missing opengl dependecies that seem to be missing from the qt 5.15 build. So the crash might be related to that, I have seen crashes after rendering but that did not effect the images/video. So the crash happens after the images/video have been written to disc.

I am not really sure I can fix this directly, because I am using the rendering functionality of qt with a offscreen surface. Because otherwise i would be stuck using the dimensions of the current render view or have some other weird display behavior. An approach to fix this may be to go to qt 6 which is also on my to do at some point. But first it would be good to know in which situations this happens exactly.

If you are using nvidia graphics you could try switching from the opensource to the proprietary driver or vice versa and see if something changes. And if that does not help you could try running the toolkit in a vm, that way you would enforce rendering with the cpu. In any case thanks for the report and any further investigation ;)

idlebear commented 3 years ago

It's running on nvidia GTX 1080. With the proprietary drivers (-450, 460), the result is the same, an empty series of images. Same result with 18.04 so my money is on the driver as well.

If I load the Nouveau driver, the render works. A bit painful in 1024x768, but it works if necessary.

Let me know if you want me to try anything else.

ju6ge commented 3 years ago

Hm interesting. Did you try rendering at a higher resolution? I don't think the driver should have much to say about that. And rbdl-toolkit lets you set the desired resolution to what ever you want. That information is then used to set the size of the offscreen surface.

idlebear commented 3 years ago

Resolution doesn't seem to have any effect other than a larger/smaller output image.

ju6ge commented 3 years ago

Well that is exactly what the resolution of an image/video is describing. How many pixel its height/width are. Or where saying that due to using the the nouveau driver your screen resolution is stuck at 1024x768?

The image/video rendering uses the same camera position as in the application, so it is expected that when you make the image bigger you would see a larger part of the scene.

idlebear commented 3 years ago

Yes, of course -- I mean that in all cases, at all resolutions get a blank image (of varying size....)

ju6ge commented 3 years ago

Okay, to summarize there is a problem with the with rendering images/videos if you are running a nvidia card on linux. (My workstation has AMD and mac is another situation). Rendering to images/video works when using the nouveau driver, but that is not necessarily desirable since it has other performance problems. Using the proprietary nvidia driver only yields blank images.

RBDL-Toolkit uses the RenderCapture class in qt 3D to capture the rendered frames, and depending on what you want saves the frame as a image or uses ffmpeg to encode images into a video. The bug is that the images returned by the graphics stack when rendering offscreen on a nvidia card (with proprietary driver) are blank.

Things to test in the future:

idlebear commented 3 years ago

Upgraded and ported to qt6 -- same result. I saw a comment that it could be related to the underlying GLX layer, but haven't looked into it any further. I see if I can find anything obvious when I get a chance,

ju6ge commented 3 years ago

Well, that is disappointing. Could you send the the upgrade to qt6 as a pull request?