[Interest] Qt3D - Render to QImage

Philip Schuchardt vpicaver at gmail.com
Tue Dec 20 13:48:39 CET 2016


Awesome! Thanks Juan.

On Mon, Dec 19, 2016 at 7:18 PM Juan Jose Casafranca <jjcasmar at gmail.com>
wrote:

> Hi,
>
> I've began to look a the QRenderCapture code to implement the
> QBufferCapture node and I've found that the problem that Philip described
> may happen because of the render target format used.
> The debugger says that the render target is a RGB8_UNorm which is not
> considered in the big switch case statement in
> graphicshelpers/graphicscontext.cpp file (line 1624).
>
> I will file a jira with this info
>
> 2016-12-12 15:43 GMT+01:00 Philip Schuchardt <vpicaver at gmail.com>:
>
> I'm using Scene3D in my QML application. Qt Quick is in charge. The
> default format returns -1, -1, -1, and -1 for alpha, red, green, and blue.
> I'm on macOS 10.12.1 with an AMD Radeon HD 6770M 1024 MB.
>
> On Fri, Dec 9, 2016 at 3:26 AM Sean Harmer <sean.harmer at kdab.com> wrote:
>
>
>
> On 09/12/2016 00:28, Philip Schuchardt wrote:
> > I figured out why it wasn't working for me. After using the qt3d debug
> > build, I noticed that Qt3D was asserting:
> >
> > ASSERT failure in Q_UNREACHABLE(): "Q_UNREACHABLE was reached", file
> > graphicshelpers/graphicscontext.cpp, line 1684
> >
> >
> > Basically, it was telling me that it had an invalid framebuffer type. I
> > had multisampling enabled which would prevent direct reads from a
> > framebuffer. Multisampled framebuffers need to be copied to a texture
> > before reading to main memory. After disabling multisampling, it still
> > wasn't working.  Then I forced a new default format with QSurfaceFormat:
>
> Right. We could handle this multisample resolving internally so please
> do file a bug report for this. I also want to add a framebuffer blit
> framegraph node for 5.9 too as this has other uses outside of
> RenderCapture.
>
> >
> >
> > QSurfaceFormatformat=QSurfaceFormat::defaultFormat();
> >
> > format.setAlphaBufferSize(8);
> >
> > format.setRedBufferSize(8);
> >
> > format.setGreenBufferSize(8);
> >
> > format.setBlueBufferSize(8);
> >
> > QSurfaceFormat::setDefaultFormat(format);
> >
> >
> > Then it worked! I tried re-enabling multisampling which caused it not to
> > work agian.
> >
> >
> > I think there's currently two bugs for RenderCapture:
> >
> > 1. The default QSurfaceFormat doesn't work with RenderCapture (on macOS
> > 10.12.1)
>
> What setup are you using? Qt QUick in charge + a Scene3D or pure QT 3D
> application? What is the default format you get in this case?
>
> >
> > 2. The multisampling (using Scene3D) doesn't work with RenderCapture
> >
> >
> > Sean, should I make a bug report?
>
> Yes please :)
>
> Thanks for investigating!
>
> Sean
>
> >
> >
> > Thanks,
> >
> > Phi|ip
> >
> >
> > On Sat, Dec 3, 2016 at 4:16 PM Philip Schuchardt <vpicaver at gmail.com
> > <mailto:vpicaver at gmail.com>> wrote:
> >
> >     I prototyped a framegraph using 5.8-beta and RenderCapture, but was
> >     unable to get anything to save to disk. It creates a
> >     RenderCaptureReply. The reply gets completed but the image is null
> >     and nothing is saved. I'm currently saving to "~/testShot.png".  Any
> >     ideas why it's not working? I probably set up the framegraph wrong
> >     or something. I would be really helpful if there was an example in
> >     the documentation.
> >
> >     Here's my test example. You can run through Qt Creators -> Tools ->
> >     External -> Qt Quickt - > qmlscene
> >     https://dl.dropboxusercontent.com/u/13470469/Renderer3D.qml
> >
> >     On Mon, Nov 28, 2016 at 11:33 AM Philip Schuchardt
> >     <vpicaver at gmail.com <mailto:vpicaver at gmail.com>> wrote:
> >
> >         Cool! I didn't see RenderCapture class in 5.7. I glad it was
> >         added in 5.8. I'll try to prototype something with custom
> >         framegraph in 5.8.
> >
> >         Phi|ip
> >
> >         On Mon, Nov 28, 2016 at 6:48 AM Juan Jose Casafranca
> >         <jjcasmar at gmail.com <mailto:jjcasmar at gmail.com>> wrote:
> >
> >             I will have a better look to how the aspect translates the
> >             framegraph node to opengl commands.
> >
> >             Thanks!
> >
> >             2016-11-28 12:42 GMT+01:00 Sean Harmer <sean.harmer at kdab.com
> >             <mailto:sean.harmer at kdab.com>>:
> >
> >                 On Monday 28 November 2016 12:34:01 Juan Jose Casafranca
> >                 wrote:
> >                 > How does QRenderCapture works? When a capture is
> requested it sets a flags
> >                 > and when generating the view, it creates a job that
> will render the image?
> >                 > I imagine the QRenderCapture in the framegraph is
> important. If you put it
> >                 > right after the ClearBuffers, it will render an empty
> image, wont it?
> >
> >                 I suspect the issue here is not being clear on the frame
> >                 graph. Each leaf node
> >                 of the frame graph results in a phase of rendering. The
> >                 RenderCapture node
> >                 essentially gets translated into a glReadPixels call for
> >                 that rendering phase.
> >                 If the sub-tree containing the ClearBuffers and
> >                 RenderCapture also does some
> >                 drawing (i.e. doesn't have a NoDraw node) the
> >                 glReadPixels will happen after
> >                 the draw calls so should read back the framebuffer that
> >                 has just been drawn
> >                 to.
> >
> >                 Hope this helps,
> >
> >                 Sean
> >
> >                 >
> >                 > 2016-11-28 12:11 GMT+01:00 Sean Harmer
> >                 <sean.harmer at kdab.com <mailto:sean.harmer at kdab.com>>:
> >                 > > On Monday 28 November 2016 11:48:14 Harald Vistnes
> >                 wrote:
> >                 > > > Hi,
> >                 > > >
> >                 > > > yes, this would be a most welcome feature.
> >                 > > >
> >                 > > > Concerning Jira, it has already been requested
> >                 multiple times
> >                 > > > https://bugreports.qt.io/browse/QTBUG-52074
> >                 > > > https://bugreports.qt.io/browse/QTBUG-52136
> >                 > >
> >                 > > I meant for reading back from a buffer. :)
> >                 > >
> >                 > > > I tried to render into a FBO and read back the
> >                 results, but had some
> >                 > > > problems. I attached some test code in the Jira
> >                 > > >
> >
> https://bugreports.qt.io/secure/attachment/57353/offscreenrenderer.zip
> >                 > >
> >                 > > but
> >                 > >
> >                 > > > never got any feedback. If someone will look into
> >                 this it would be
> >                 > > > great.
> >                 > >
> >                 > > I'll see if someone can take a look. I may have some
> >                 time next week if
> >                 > > nobody
> >                 > > else can.
> >                 > >
> >                 > > Cheers,
> >                 > >
> >                 > > Sean
> >                 > >
> >                 > > > Thanks,
> >                 > > > Harald
> >                 > > >
> >                 > > > 2016-11-28 11:41 GMT+01:00 Sean Harmer
> >                 <sean.harmer at kdab.com <mailto:sean.harmer at kdab.com>>:
> >                 > > > > On Monday 28 November 2016 11:40:10 Juan Jose
> >                 Casafranca wrote:
> >                 > > > > > Oh thanks!
> >                 > > > > >
> >                 > > > > > Yes, in fact my first thought was to use it
> >                 for a compute shader. It
> >                 > > > >
> >                 > > > > would
> >                 > > > >
> >                 > > > > > make Qt3D a great tool not only for rendering
> >                 but also for GPGPU.
> >                 > > > > > I will try to have a look on it during the
> >                 Christmas vacations :-)
> >                 > > > >
> >                 > > > > Awesome! Drop by #qt-3d on irc if you need
> anything.
> >                 > > > >
> >                 > > > > Cheers,
> >                 > > > >
> >                 > > > > Sean
> >                 > > > >
> >                 > > > > > 2016-11-28 11:31 GMT+01:00 Sean Harmer
> >                 <sean.harmer at kdab.com <mailto:sean.harmer at kdab.com>>:
> >                 > > > > > > Hi,
> >                 > > > > > >
> >                 > > > > > > On Monday 28 November 2016 11:22:30 Juan
> >                 Jose Casafranca wrote:
> >                 > > > > > > > Hi Sean,
> >                 > > > > > > >
> >                 > > > > > > > is there any example on how to do that? I
> >                 tried to use a
> >                 > > > >
> >                 > > > > QRenderCapture
> >                 > > > >
> >                 > > > > > > but
> >                 > > > > > >
> >                 > > > > > > > I failed two weeks ago.
> >                 > > > > > >
> >                 > > > > > >
> >                 http://code.qt.io/cgit/qt/qt3d.git/tree/tests/manual/
> >                 > >
> >                 > > rendercapture-qml
> >                 > >
> >                 > > > > > >
> >                 http://code.qt.io/cgit/qt/qt3d.git/tree/tests/manual/
> >                 > >
> >                 > > rendercapture-cpp
> >                 > >
> >                 > > > > > > > Is there any way to access the buffers
> >                 content data using a
> >                 > >
> >                 > > similar
> >                 > >
> >                 > > > > > > > approach to the QRenderCapture method?
> >                 > > > > > > > For example, in an animation system, use a
> >                 graphics pipeline to
> >                 > > > >
> >                 > > > > compute
> >                 > > > >
> >                 > > > > > > the
> >                 > > > > > >
> >                 > > > > > > > deformed mesh and then get the new vertex
> >                 positions for export.
> >                 > > > > > >
> >                 > > > > > > Right, that is missing at the moment. It
> >                 would be very useful to
> >                 > > > > > > be
> >                 > > > >
> >                 > > > > able
> >                 > > > >
> >                 > > > > > > to do
> >                 > > > > > > this to read back the results of a compute
> >                 shader too for e.g.. If
> >                 > >
> >                 > > you
> >                 > >
> >                 > > > > > > wish to
> >                 > > > > > > have a go at adding such a feature analogous
> >                 the the RenderCapture
> >                 > > > > > > node
> >                 > > > > > > then
> >                 > > > > > > that would be awesome. If not, we can try to
> >                 do it for 5.9 but the
> >                 > > > >
> >                 > > > > feature
> >                 > > > >
> >                 > > > > > > freeze is approaching. In either case could
> >                 you file a JIRA for it
> >                 > > > >
> >                 > > > > please?
> >                 > > > >
> >                 > > > > > > Thanks!
> >                 > > > > > >
> >                 > > > > > > Sean
> >                 > > > > > >
> >                 > > > > > > > Cheers
> >                 > > > > > > > Juan José
> >                 > > > > > > >
> >                 > > > > > > > 2016-11-28 11:13 GMT+01:00 Sean Harmer
> >                 <sean.harmer at kdab.com <mailto:sean.harmer at kdab.com>>:
> >                 > > > > > > > > On Monday 28 November 2016 02:23:59
> >                 Philip Schuchardt wrote:
> >                 > > > > > > > > > I'm trying to port my OpenGL code (
> >                 > >
> >                 > > https://github.com/Cavewhere/
> >                 > >
> >                 > > > > > > > > cavewhere/)
> >                 > > > > > > > >
> >                 > > > > > > > > > to use Qt3D. I think Qt3D will allow
> >                 me to quickly improve
> >                 > >
> >                 > > and
> >                 > >
> >                 > > > > > > modify my
> >                 > > > > > >
> >                 > > > > > > > > > rendering pipeline. The one
> >                 requirement I need is to be able
> >                 > >
> >                 > > to
> >                 > >
> >                 > > > > > > render
> >                 > > > > > >
> >                 > > > > > > > > to a
> >                 > > > > > > > >
> >                 > > > > > > > > > QImage and save it to disk. Currently,
> >                 have a method that
> >                 > > > > > > > > > renders
> >                 > > > > > > > > > high-resolution images from OpenGL. I
> >                 do this by tiling a
> >                 > > > >
> >                 > > > > projection
> >                 > > > >
> >                 > > > > > > > > matrix
> >                 > > > > > > > >
> >                 > > > > > > > > > and rendering the scene one tile at a
> >                 time and combining
> >                 > > > > > > > > > them
> >                 > > > >
> >                 > > > > into
> >                 > > > >
> >                 > > > > > > > > > on
> >                 > > > > > > > >
> >                 > > > > > > > > huge
> >                 > > > > > > > >
> >                 > > > > > > > > > PNG. The problem is I'm not sure how
> >                 to render Qt3D pipeline
> >                 > >
> >                 > > to
> >                 > >
> >                 > > > > > > > > > a
> >                 > > > > > > > > > texture
> >                 > > > > > > > > > and then download if from the GPU into
> >                 memory in Qt3D. Is
> >                 > >
> >                 > > there
> >                 > >
> >                 > > > > an
> >                 > > > >
> >                 > > > > > > easy
> >                 > > > > > >
> >                 > > > > > > > > way
> >                 > > > > > > > >
> >                 > > > > > > > > > to do that? Do I need to create my own
> >                 Aspect?
> >                 > > > > > > > >
> >                 > > > > > > > > Hi, you can use a custom frame graph
> >                 that includes a
> >                 > > > > > > > > QRenderCapture
> >                 > > > > > >
> >                 > > > > > > node
> >                 > > > > > >
> >                 > > > > > > > > (coming in Qt 5.8). If you combine this
> >                 with a camera and some
> >                 > > > >
> >                 > > > > logic
> >                 > > > >
> >                 > > > > > > for
> >                 > > > > > >
> >                 > > > > > > > > tiling the frustum (NodeInstantiator)
> >                 you should be able to
> >                 > > > >
> >                 > > > > replicate
> >                 > > > >
> >                 > > > > > > your
> >                 > > > > > >
> >                 > > > > > > > > existing logic. I'd like to get
> >                 something like this wrapped up
> >                 > > > >
> >                 > > > > along
> >                 > > > >
> >                 > > > > > > with
> >                 > > > > > >
> >                 > > > > > > > > Qt
> >                 > > > > > > > > 5.9.
> >                 > > > > > > > >
> >                 > > > > > > > > > Also, many parts of the documentation
> >                 seem to be missing,
> >                 > >
> >                 > > very
> >                 > >
> >                 > > > > > > > > > light,
> >                 > > > > > > > > > and
> >                 > > > > > > > > > not up to the same standard as the
> >                 rest of Qt's
> >                 > >
> >                 > > documentation.
> >                 > >
> >                 > > > > > > > > Yes this is something I really want to
> >                 have a push on in the
> >                 > >
> >                 > > near
> >                 > >
> >                 > > > > > > future.
> >                 > > > > > >
> >                 > > > > > > > > Cheers,
> >                 > > > > > > > >
> >                 > > > > > > > > Sean
> >                 > > > > > > > >
> >                 > > > > > > > > > Perhaps,
> >                 > > > > > > > > > I'm just missing something from the
> >                 undocumented
> >                 > >
> >                 > > documentation.
> >                 > >
> >                 > > > > > > > > > Thanks,
> >                 > > > > > > > > > Phi|ip
> >                 > > > > > > > >
> >                 > > > > > > > > --
> >                 > > > > > > > > Dr Sean Harmer | sean.harmer at kdab.com
> >                 <mailto:sean.harmer at kdab.com> | Managing Director UK
> >                 > > > > > > > > KDAB (UK) Ltd, a KDAB Group company
> >                 > > > > > > > > Tel. +44 (0)1625 809908
> <+44%201625%20809908>
> >                 <tel:%2B44%20%280%291625%20809908>; Sweden (HQ)
> >                 +46-563-540090 <+46%20563%2054%2000%2090>
> <tel:%2B46-563-540090>
> >                 > > > > > > > > Mobile: +44 (0)7545 140604
> <+44%207545%20140604>
> >                 <tel:%2B44%20%280%297545%20140604>
> >                 > > > > > > > > KDAB - Qt Experts
> >                 > > > > > > > >
> >                 _______________________________________________
> >                 > > > > > > > > Interest mailing list
> >                 > > > > > > > > Interest at qt-project.org
> >                 <mailto:Interest at qt-project.org>
> >                 > > > > > > > >
> >                 http://lists.qt-project.org/mailman/listinfo/interest
> >                 > > > > > >
> >                 > > > > > > --
> >                 > > > > > > Dr Sean Harmer | sean.harmer at kdab.com
> >                 <mailto:sean.harmer at kdab.com> | Managing Director UK
> >                 > > > > > > KDAB (UK) Ltd, a KDAB Group company
> >                 > > > > > > Tel. +44 (0)1625 809908
> <+44%201625%20809908>
> >                 <tel:%2B44%20%280%291625%20809908>; Sweden (HQ)
> >                 +46-563-540090 <+46%20563%2054%2000%2090>
> <tel:%2B46-563-540090>
> >                 > > > > > > Mobile: +44 (0)7545 140604
> <+44%207545%20140604>
> >                 <tel:%2B44%20%280%297545%20140604>
> >                 > > > > > > KDAB - Qt Experts
> >                 > > > >
> >                 > > > > --
> >                 > > > > Dr Sean Harmer | sean.harmer at kdab.com
> >                 <mailto:sean.harmer at kdab.com> | Managing Director UK
> >                 > > > > KDAB (UK) Ltd, a KDAB Group company
> >                 > > > > Tel. +44 (0)1625 809908 <+44%201625%20809908>
> >                 <tel:%2B44%20%280%291625%20809908>; Sweden (HQ)
> >                 +46-563-540090 <+46%20563%2054%2000%2090>
> <tel:%2B46-563-540090>
> >                 > > > > Mobile: +44 (0)7545 140604 <+44%207545%20140604>
> >                 <tel:%2B44%20%280%297545%20140604>
> >                 > > > > KDAB - Qt Experts
> >                 > > > > _______________________________________________
> >                 > > > > Interest mailing list
> >                 > > > > Interest at qt-project.org
> >                 <mailto:Interest at qt-project.org>
> >                 > > > >
> >                 http://lists.qt-project.org/mailman/listinfo/interest
> >                 > >
> >                 > > --
> >                 > > Dr Sean Harmer | sean.harmer at kdab.com
> >                 <mailto:sean.harmer at kdab.com> | Managing Director UK
> >                 > > KDAB (UK) Ltd, a KDAB Group company
> >                 > > Tel. +44 (0)1625 809908 <+44%201625%20809908>
> >                 <tel:%2B44%20%280%291625%20809908>; Sweden (HQ)
> >                 +46-563-540090 <+46%20563%2054%2000%2090>
> <tel:%2B46-563-540090>
> >                 > > Mobile: +44 (0)7545 140604 <+44%207545%20140604>
> >                 <tel:%2B44%20%280%297545%20140604>
> >                 > > KDAB - Qt Experts
> >                 > > _______________________________________________
> >                 > > Interest mailing list
> >                 > > Interest at qt-project.org <mailto:
> Interest at qt-project.org>
> >                 > >
> http://lists.qt-project.org/mailman/listinfo/interest
> >
> >                 --
> >                 Dr Sean Harmer | sean.harmer at kdab.com
> >                 <mailto:sean.harmer at kdab.com> | Managing Director UK
> >                 KDAB (UK) Ltd, a KDAB Group company
> >                 Tel. +44 (0)1625 809908 <+44%201625%20809908>
> <tel:+44%201625%20809908>;
> >                 Sweden (HQ) +46-563-540090 <+46%20563%2054%2000%2090>
> <tel:+46%20563%2054%2000%2090>
> >                 Mobile: +44 (0)7545 140604 <+44%207545%20140604>
> <tel:+44%207545%20140604>
> >                 KDAB - Qt Experts
> >
> >
> >             _______________________________________________
> >             Interest mailing list
> >             Interest at qt-project.org <mailto:Interest at qt-project.org>
> >             http://lists.qt-project.org/mailman/listinfo/interest
> >
> >         --
> >         Phi|ip
> >
> >     --
> >     Phi|ip
> >
> > --
> > Phi|ip
> >
> >
> > _______________________________________________
> > Interest mailing list
> > Interest at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/interest
> >
>
> --
> Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
> KDAB (UK) Ltd, a KDAB Group company
> Tel. +44 (0)1625 809908 <+44%201625%20809908>; Sweden (HQ) +46-563-540090
> <+46%20563%2054%2000%2090>
> Mobile: +44 (0)7545 140604 <+44%207545%20140604>
> KDAB - Qt Experts
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
> --
> Phi|ip
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
> --
Phi|ip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161220/ba166a65/attachment.html>


More information about the Interest mailing list