Question about ClipPlane and FrameGraph
-
I want to use ClipPlane inside Qt3D.
Firstly I use this FrameGraph in which the ClipPlane not work:
Viewport { id: viewport normalizedRect: Qt.rect(0, 0, 1, 1) RenderSurfaceSelector { id: surfaceSelector CameraSelector { id: cameraSelector camera: mainCamera RenderStateSet { renderStates: [ ClipPlane { planeIndex: 0 } ] } ClearBuffers { id: clearBuffer clearColor: Qt.rgba(0, 0.5, 1, 1) buffers: ClearBuffers.ColorDepthBuffer } } } }
Then I found an example inside tests coming from Qt3D source code ( qt-clipplanes), and changing my FrameGraph accordingly in which the ClipPlane works:
Viewport { id: viewport normalizedRect: Qt.rect(0, 0, 1, 1) RenderSurfaceSelector { id: surfaceSelector CameraSelector { id: cameraSelector camera: mainCamera RenderStateSet { renderStates: [ ClipPlane { planeIndex: 0 } ] ClearBuffers { id: clearBuffer clearColor: Qt.rgba(0, 0.5, 1, 1) buffers: ClearBuffers.ColorDepthBuffer } } } } }
The only difference between them is the ClearBuffers is a leaf node of RenderStateSet.
I read through the doc of Qt3D FrameGraph But I didn't found the clue why one works the other doesn't.
I understand these two FrameGraphs constructs different orders of RenderView. But when the CleanBuffers is the last node, didn't clear the whole screen. In the first example it shows whole mesh of the object (with out clipping) , instead in the second example it shows a correctly clipped object.
Please help me by explaining it. Thanks
-
Each leaf node asks for the rendering of the geometry. So when you clear, the geometry is rendered just after. I would suggest you to use Layers:
In your frame graph file:
property Layer dummyLayer property Layer sceneGeometryLayer LayerFilter{ layers: [dummyLayer] // No geometry will be rendered if you don't associate the dummyLayer somewhere else. ClearBuffers { clearColor: Qt.rgba(0, 0.5, 1, 1) buffers: ClearBuffers.ColorDepthBuffer } } LayerFilter{ layers: [sceneGeometryLayer] ... }
In your main.qml file:
Femur { layer: frameGraph.sceneGeometryLayer ... }
-
@Beber Thanks, I'll take a look at it first.