[Interest] Qt3D Framegraphs
Andy
asmaloney at gmail.com
Tue Aug 21 13:54:40 CEST 2018
Thank you so much Paul!
That gives me something to start working on/pick apart. I see now how
onscreen vs. offscreen works and can concentrate on getting the onscreen
working the way I want first since they are very similar.
1) "I assume you want to fill the depth buffer with a simple shader right?"
I think so? Ultimately I want to experiment with a cel-shaded scene, but
for now I'd be happy with adding some black contours on my entities using
depth - slightly thicker lines closer to the camera, thinner farther away.
Is this the right setup for that?
2) "Have you tried the rendercapture ones?"
Yes I have. That's how I got my render capture working (once those examples
worked).
One thing that wasn't clear to me before was where to attach the
RenderCapture node. In the rendercapture example, it's created and then the
forward renderer is re-parented, which is what I did with mine. Your
outline makes more sense.
ClearBuffers (and NoDraw!) now make sense too. In QForwardRenderer they are
on the camera selector which seems strange.
3) If I want to use any of the "default materials" in extras - Phong,
PhongAlpha, etc - then in (3) and (4.3) the filterkeys must be
"renderingStyle"/"forward", correct? Or can I even use them anymore if I'm
going this route?
4) I will use the offscreen to generate snapshot images and video - I
assume I can turn offscreen rendering on/off dynamically by simply
enabling/disabling the RenderTargetSelector?
Thanks again for your help. I finally feel like I'm in danger of
understanding something here!
On Mon, Aug 20, 2018 at 1:20 AM Paul Lemire <paul.lemire at kdab.com> wrote:
> Hi Andy,
>
> Please see my reply below
>
> On 08/15/2018 02:59 PM, Andy wrote:
>
> I've been struggling with framegraphs for a very long time now and still
> don't feel like I understand their structure - what goes where or what
> kind of nodes can be attached to what. I can throw a bunch of things
> together, but when it doesn't work I have no idea how to track down what's
> missing or what's in the wrong place.
>
> Can anyone give an outline of what a framegraph would look like to
> facilitate all of the following for a given scene:
>
> 1. rendering in a window onscreen
> 2. depth pass for shaders to use
>
> I assume you want to fill the depth buffer with a simple shader right?
>
> 3. render capture for taking "snapshots" of what the user is seeing
> onscreen
> 4. offscreen rendering of the current scene at a specified size (not the
> UI window size)
> 5. render capture of the offscreen scene to an image
>
>
> I've not tested but the I would image what you want would look like the
> frame Graph below:
>
> RenderSurfaceSelector { // Select window to render to
>
> Viewport {
>
> // 1 Clear Color and Depth buffers
> ClearBuffers {
> buffers: ClearBuffers.ColorDepthBuffer
> NoDraw {}
> }
>
>
> // Select Camera to Use to Render Scene
> CameraSelector {
> camera: id_of_scene_camera
>
> // 2 Fill Depth Buffer pass (for screen depth buffer)
> RenderPassFilter {
> filterKeys: [ FilterKey { name: "pass"; value: "depth_fill_pass"] //
> Requires a Material which defines such a RenderPass
> }
>
> // 3 Draw screen content and use depth compare == to benefit for z fill
> passs
> RenderPassFilter {
> filterKeys: [ FilterKey { name: "pass"; value: "color_pass"] //
> Requires a Material which defines such a RenderPass
> RenderStateSet {
> renderStates: DepthTest { depthFunction: DepthTest.Equal }
> RenderCapture { // Use this to capture screen frame buffer
> id: onScreenCapture
> }
> }
> }
>
> // 4 Create FBO for offscreen rendering
> RenderTargetSelector {
> target: RenderTarget {
> attachments: [
> RenderTargetOutput {
> attachmentPoint: RenderTargetOutput.Color0
> texture: Texture2D { width: width_of_offscreen_area;
> height: height_of_offscreen_area; .... }
> },
> RenderTargetOutput {
> attachmentPoint: RenderTargetOutput.Depth
> texture: Texture2D { width: width_of_offscreen_area;
> height: height_of_offscreen_area; .... }
> } ]
> } // RenderTarget
>
> // Note: ideally 4.1, 4.2 and 4.3 and 1, 2, 3 could be factored
> out as a reusable subtree (if using QML)
>
> // 4.1 Clear FBO
> ClearBuffers {
> buffers: ClearBuffers.ColorDepthBuffer
> NoDraw {}
> }
>
> // 4.2 Fill Depth Buffer pass (for offscreen depth buffer)
> RenderPassFilter {
> filterKeys: [ FilterKey { name: "pass"; value: "depth_fill_pass"]
> // Requires a Material which defines such a RenderPass
> }
>
> // 4.3 Draw content into offscreen color buffer and use depth compare
> == to benefit for z fill pass
> RenderPassFilter {
> filterKeys: [ FilterKey { name: "pass"; value: "color_pass"] //
> Requires a Material which defines such a RenderPass
> RenderStateSet {
> renderStates: DepthTest { depthFunction: DepthTest.Equal }
> RenderCapture { // Use this to capture offscreen frame buffer
> id: offScreenCapture
> }
> }
> }
> } // RenderTargetSelector
>
> } // CamerSelector
>
> } // Viewport
>
> } // RenderSurfaceSelector
>
>
>
>
> Using the forward renderer in Qt3DExtras, I can do (1) and (3), but I've
> been supremely unsuccessful at implementing any of the rest despite many
> many attempts - even working with the examples. (And the deferred renderer
> examples - which might help? - don't work on macOS.)
>
> Have you tried the rendercapture ones ? which are in tests/manual
>
>
> I am using C++, not QML. I tried replacing my framegraph with a
> QML-specified one but can't get that to work either (see previous post to
> this list "[Qt3D] Mixing Quick3D and C++ nodes").
>
> Can anyone please help? I'm stuck.
>
> Thank you.
>
> ---
> Andy Maloney // https://asmaloney.com
> twitter ~ @asmaloney <https://twitter.com/asmaloney>
>
>
>
> _______________________________________________
> Interest mailing listInterest at qt-project.orghttp://lists.qt-project.org/mailman/listinfo/interest
>
>
> --
> Paul Lemire | paul.lemire at kdab.com | Senior Software Engineer
> KDAB (France) S.A.S., a KDAB Group company
> Tel: France +33 (0)4 90 84 08 53, http://www.kdab.fr
> KDAB - The Qt, C++ and OpenGL Experts
>
>
---
Andy Maloney // https://asmaloney.com
twitter ~ @asmaloney <https://twitter.com/asmaloney>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180821/5e98a432/attachment.html>
More information about the Interest
mailing list