<div dir="ltr">On Wed, Aug 16, 2017 at 1:57 AM, Laszlo Agocs <span dir="ltr"><<a href="mailto:laszlo.agocs@qt.io" target="_blank">laszlo.agocs@qt.io</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="gmail-m_-6687056577268714207WordSection1">
<p class="MsoNormal">The formats look a bit strange. Try rather Texture.RGBA8_UNorm and Texture.DepthFormat (or maybe Texture.D24) for color and depth, respectively.</p></div></div></blockquote><div><br></div><div>Thanks Laszlo!</div><div><br></div><div>I was trying to follow along with the deferred-renderer-cpp manual test, so that's where the formats came from (GBuffer).<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_-6687056577268714207WordSection1"><p class="MsoNormal"><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The node hierarchy looks somewhat incorrect as well. (where<span style="font-family:"Times New Roman",serif">’</span>s the Viewport/Camera/Clear for the custom render target? What is the FilterKey for? (are there multiple renderpasses?)
 etc.)</p></div></div></blockquote><div><br></div><div>Right now I am just trying to get a simple forward render to offscreen working. Basically take the Qt3DWindow and make a version for offscreen. So the FilterKey comes from the QForwardRenderer.</div><div><br></div><div>I thought what I needed to do was set up the viewport/camera/clear on the forward renderer and just change its target to the offscreen textures using <wbr>QRenderTargetSelector. I didn't realize I needed yet another viewport and camera somewhere?<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_-6687056577268714207WordSection1"><p class="MsoNormal"><u></u><u></u></p>
<p class="MsoNormal"><u></u><u></u></p>
<p class="MsoNormal">There is some QML-based example code in <a href="https://github.com/alpqr/q3dpostproc" target="_blank">
https://github.com/alpqr/<wbr>q3dpostproc</a> showing rendering into textures (in multiple passes even) and then compositing these on-screen, which may provide some inspiration. </p></div></div></blockquote><div><br></div><div>Thanks! More examples are useful. The documentation is still very... sparse... and I've spent a lot of time spelunking the source. It's difficult to know where nodes are supposed to attach since it's not generally in the documentation.<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_-6687056577268714207WordSection1"><p class="MsoNormal">Prototyping the framegraph with QML is usually a good idea even when the final target
 is constructing it from C++ since the latter can quickly become hard to follow, esp. when getting started.</p></div></div></blockquote><div><br></div><div>The problem is - while I've been using Qt since 2000 - I've never used QML :-) I'll take a look.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_-6687056577268714207WordSection1"><p class="MsoNormal"><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Best regards,<u></u><u></u></p>
<p class="MsoNormal">Laszlo<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b>From:</b> Interest [mailto:<a href="mailto:interest-bounces%2Blaszlo.agocs" target="_blank">interest-bounces+<wbr>laszlo.agocs</a>=<a href="mailto:qt.io@qt-project.org" target="_blank">qt.io@qt-project.<wbr>org</a>]
<b>On Behalf Of </b>Andy<br>
<b>Sent:</b> onsdag 16. august 2017 07.19<br>
<b>To:</b> Sean Harmer <<a href="mailto:sean.harmer@kdab.com" target="_blank">sean.harmer@kdab.com</a>><br>
<b>Cc:</b> Qt Project <<a href="mailto:interest@qt-project.org" target="_blank">interest@qt-project.org</a>><br>
<b>Subject:</b> Re: [Interest] Qt3D Rendering offscreen<u></u><u></u></p><div><div class="gmail-h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt">Does anybody have any hints? I've tried all kinds of node configurations and can't get this to work.<u></u><u></u></p>
</div>
<p class="MsoNormal">Thanks.<u></u><u></u></p>
<div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">---<br>
Andy Maloney  //  <a href="https://asmaloney.com" target="_blank">https://asmaloney.com</a><u></u><u></u></p>
<div>
<p class="MsoNormal">twitter ~ <a href="https://twitter.com/asmaloney" target="_blank">
@asmaloney</a><u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Sat, Aug 12, 2017 at 2:03 PM, Andy <<a href="mailto:asmaloney@gmail.com" target="_blank">asmaloney@gmail.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border-width:medium medium medium 1pt;border-style:none none none solid;border-color:currentcolor currentcolor currentcolor rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt">Based on your outline, here is the hierarchy I have set up (but I still get images of size (1,1)):<br>
<br>
Qt3DRender::QRenderCapture::<br>
    Qt3DExtras::QForwardRenderer::<br>
        Qt3DRender::<wbr>QRenderSurfaceSelector::<br>
            Qt3DRender::QViewport::<br>
                Qt3DRender::QCameraSelector::<br>
                    Qt3DRender::QClearBuffers::<br>
                        Qt3DRender::QFrustumCulling::<br>
        Qt3DRender::QFilterKey::<br>
        Qt3DRender::<wbr>QRenderTargetSelector::<br>
            Qt3DRender::QRenderTarget::<br>
                Qt3DRender::<wbr>QRenderTargetOutput::<br>
                    Qt3DRender::QTexture2D::<br>
                Qt3DRender::<wbr>QRenderTargetOutput::<br>
                    Qt3DRender::QTexture2D::<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12pt">Am I attaching things in the right place?<br>
<br>
This is how I'm creating it:<br>
<br>
   const QSize cTargetSize( 1024, 768 );<br>
<br>
   m_forwardRenderer-><wbr>setExternalRenderTargetSize( cTargetSize );<br>
<br>
   Qt3DRender::QTexture2D  *color0Texture = new Qt3DRender::QTexture2D;<br>
   color0Texture->setSize( cTargetSize.width(), cTargetSize.height() );<br>
   color0Texture->setFormat( Qt3DRender::QAbstractTexture::<wbr>RGBA32F );<br>
   color0Texture-><wbr>setGenerateMipMaps( false) ;<br>
<br>
   Qt3DRender::QTexture2D  *depthTexture = new Qt3DRender::QTexture2D;<br>
   depthTexture->setSize( cTargetSize.width(), cTargetSize.height() );<br>
   depthTexture->setFormat( Qt3DRender::QAbstractTexture::<wbr>D32F );<br>
   depthTexture-><wbr>setGenerateMipMaps( false );<br>
<br>
   Qt3DRender::<wbr>QRenderTargetOutput  *colorOutput = new Qt3DRender::<wbr>QRenderTargetOutput;<br>
   colorOutput->setTexture( color0Texture );<br>
   colorOutput-><wbr>setAttachmentPoint( Qt3DRender::<wbr>QRenderTargetOutput::Color0 );<br>
<br>
   Qt3DRender::<wbr>QRenderTargetOutput  *depthOutput = new Qt3DRender::<wbr>QRenderTargetOutput;<br>
   depthOutput->setTexture( depthTexture );<br>
   depthOutput-><wbr>setAttachmentPoint( Qt3DRender::<wbr>QRenderTargetOutput::Depth );<br>
<br>
   Qt3DRender::QRenderTarget  *renderTarget = new Qt3DRender::QRenderTarget;<br>
   renderTarget->addOutput( colorOutput );<br>
   renderTarget->addOutput( depthOutput );<br>
<br>
   Qt3DRender::<wbr>QRenderTargetSelector   *renderTargetSelector = new Qt3DRender::<wbr>QRenderTargetSelector( m_forwardRenderer );<br>
<br>
   renderTargetSelector-><wbr>setTarget( renderTarget );<br>
<br>
   m_forwardRenderer->setParent( mRenderCapturer );<br>
   m_renderSettings-><wbr>setActiveFrameGraph( mRenderCapturer );<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">---<br>
Andy Maloney  //  <a href="https://asmaloney.com" target="_blank">https://asmaloney.com</a><u></u><u></u></p>
<div>
<p class="MsoNormal">twitter ~ <a href="https://twitter.com/asmaloney" target="_blank">
@asmaloney</a><u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">On Sat, Aug 12, 2017 at 8:58 AM, Andy <<a href="mailto:asmaloney@gmail.com" target="_blank">asmaloney@gmail.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border-width:medium medium medium 1pt;border-style:none none none solid;border-color:currentcolor currentcolor currentcolor rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p class="MsoNormal">On Sat, Aug 12, 2017 at 8:40 AM, Sean Harmer <<a href="mailto:sean.harmer@kdab.com" target="_blank">sean.harmer@kdab.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<blockquote style="border-width:medium medium medium 1pt;border-style:none none none solid;border-color:currentcolor currentcolor currentcolor rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">Hi,<br>
<br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">On Friday 11 August 2017 14:34:34 Andy wrote:</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> Goal: With Qt3D (C++), render my scene offscreen, use render capture on it,</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> and save image to disk.</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> With my Qt3DWindow-based solution the scene looks fine and I can do the</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> render capture part (on macOS anyways - Windows doesn't work for me -</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> <a href="https://bugreports.qt.io/browse/QTBUG-61223" target="_blank">
https://bugreports.qt.io/<wbr>browse/QTBUG-61223</a> ).</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> Now I need to be able to do it offscreen (without the window open).</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> I thought this was going to be as simple as setting a QOffscreenSurface as</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> my forward renderer surface - something like:</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">>    QOffscreenSurface *surface = new QOffscreenSurface;</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">>    surface->create();</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">>    Qt3DExtras::QForwardRenderer  *forwardRenderer = new</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> Qt3DExtras::QForwardRenderer;</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">>    forwardRenderer->setSurface( surface );</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">>    forwardRenderer-><wbr>setExternalRenderTargetSize( QSize( 800, 600 ) );</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">>    qDebug() << surface->format() << surface->size() << surface->isValid();</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> While this gives me a valid surface and the format is correct, its size is</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> always (1,1) and the render capture gives me images of that size.</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> How do I set the size of the QOffscreenSurface?</span><br>
<br>
You don't :) An offscreen surface is only good for making a GL context<br>
current. It is not suitable as a render target. If you want to do offscreen<u></u><u></u></p>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I guess I find that class name confusing then... One draws on a surface, right? :-)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<blockquote style="border-width:medium medium medium 1pt;border-style:none none none solid;border-color:currentcolor currentcolor currentcolor rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">rendering with QOffscreenSurface, you will need to provide your own render<br>
target in the form of a framebuffer object.<br>
<br>
You will need to create an FBO by way of a QRenderTarget with a 2D texture of<br>
the desired size attached to the color0 attachment point, and a depth format<br>
texture of the same size attached to the depth attachment point.<u></u><u></u></p>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">So that's a QTexture2D for colo0 and... what for the "depth format texture"? Another QTexture2D?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">  <u></u><u></u></p>
</div>
<blockquote style="border-width:medium medium medium 1pt;border-style:none none none solid;border-color:currentcolor currentcolor currentcolor rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal"><br>
Select this with a QRenderTargetSelector in a custom framegraph to direct<br>
rendering into the attached textures. You can then do a pixel read back<br>
operation with the QRenderCapure and save the resulting image.<u></u><u></u></p>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">You make it sound so easy!<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<blockquote style="border-width:medium medium medium 1pt;border-style:none none none solid;border-color:currentcolor currentcolor currentcolor rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal"><br>
I suppose this could be wrapped in a convenience that allows the rest of the<br>
framegraph beyond the render target selector and render capture to be set.<u></u><u></u></p>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">+1. If I ever get anything working, I'd be happy to work with someone to get it into shape for Qt3DExtras.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks Sean!<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<blockquote style="border-width:medium medium medium 1pt;border-style:none none none solid;border-color:currentcolor currentcolor currentcolor rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal"><br>
Cheers,<br>
<br>
Sean<br>
<br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> Or am I going about this the wrong way?</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> (It would be nice to have a class like the Qt3DWindow one specifically for</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> offscreen rendering.)</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">></span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> ---</span><br>
<span class="gmail-m_-6687056577268714207m-6547546309794316694m-7470516929726528121gmail-">> Andy Maloney  // 
<a href="https://asmaloney.com" target="_blank">https://asmaloney.com</a></span><br>
> twitter ~ @asmaloney <<a href="https://twitter.com/asmaloney" target="_blank">https://twitter.com/asmaloney</a><wbr>><br>
<br>
--<br>
Dr Sean Harmer | <a href="mailto:sean.harmer@kdab.com" target="_blank">sean.harmer@kdab.com</a> | Managing Director UK<br>
Klarälvdalens Datakonsult AB, a KDAB Group company<br>
Tel. UK <a href="tel:%2B44%20%280%291625%20809908" target="_blank">+44 (0)1625 809908</a>, Sweden (HQ)
<a href="tel:%2B46-563-540090" target="_blank">+46-563-540090</a><br>
KDAB - Qt Experts - Platform-independent software solutions<u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
---<br>
Andy Maloney  //  <a href="https://asmaloney.com" target="_blank">https://asmaloney.com</a><u></u><u></u></p>
<div>
<p class="MsoNormal">twitter ~ <a href="https://twitter.com/asmaloney" target="_blank">
@asmaloney</a><u></u><u></u></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></div></div>
</div>

</blockquote></div><br clear="all">---<br>Andy Maloney  //  <a href="https://asmaloney.com" target="_blank">https://asmaloney.com</a><br><div>twitter ~ <span dir="ltr"><a href="https://twitter.com/asmaloney" target="_blank">@<span>asmaloney</span></a></span></div></div></div>