[Interest] Qt3D face culling
Sean Harmer
sean.harmer at kdab.com
Fri Mar 11 12:44:33 CET 2016
Hi,
well the QForwardRenderer framegraph is not really designed to be modified but
you should just be able to use
QObject::findChild<Qt3DRender::QClearBuffer*>().
If you need deeper customisation of the framegraph, it's preferable to write
your own one. Of course you can use QForwardRenderer as a base to work from.
I hope in time that we will have tooling for designing framegraphs
graphically.
Cheers,
Sean
On Friday 11 Mar 2016 11:34:56 Юрий Дынников wrote:
> Thank you, Sean.
>
> I've managed to disable face-culling by putting QStateSet under
> QClearBuffer, but to get there, I had to write a piece of horrible code:
> https://gist.github.com/morodeer/974cb4ddd47c1f1f8b34#file-main-cpp
>
> Qt3DCore::QNode* clearBuffer_node = 0;
> foreach (Qt3DCore::QNode* node_viewport,
> forwardRenderer->childrenNodes()) { if
> (dynamic_cast<Qt3DRender::QViewport*>(node_viewport)) { foreach
> (Qt3DCore::QNode* node_cameraselector,
> node_viewport->childrenNodes()) {
> if
> (dynamic_cast<Qt3DRender::QCameraSelector*>(node_cameraselector)) {
> foreach (Qt3DCore::QNode* node_clearbuffer,
> node_cameraselector->childrenNodes()) {
> if
> (dynamic_cast<Qt3DRender::QClearBuffer*>(node_clearbuffer)) {
> clearBuffer_node = node_clearbuffer;
> break;
> }
> }
> break;
> }
> }
> break;
> }
> }
>
> if (clearBuffer_node) {
> Qt3DRender::QStateSet* set = new
> Qt3DRender::QStateSet(clearBuffer_node);
> Qt3DRender::QDepthTest* depthTest = new Qt3DRender::QDepthTest;
> depthTest->setFunc(Qt3DRender::QDepthTest::Always);
> set->addRenderState(depthTest);
> }
>
>
> Am I missing any simpler way to do that? Viewport, CameraSelector and
> ClearBuffer are all private in ForwardRenderer.
>
> чт, 10 мар. 2016 г. в 21:13, Sean Harmer <sean.harmer at kdab.com>:
> > On Thursday 10 Mar 2016 15:13:07 Юрий Дынников wrote:
> > > Hello, I'm trying to use Qt3D (C++) module, and there is one huge
> >
> > problem:
> > > How can I enable displaying any surface (or triangle, to be simple) from
> > > both sides?
> > >
> > > I've read that that's all about face-culling, but I can't find where it
> >
> > is
> >
> > > applied during preparation of scene.
> > > I've found QCullFace class and managed to find the place where it should
> > > belong by finding QML examples with culling settings:
> > > QMaterial->QTechnique->QRenderPass->QCullFace(or any other
> > > QRenderState).
> > > But if I replace QCuboidMesh with QPlaneMesh in "Basic shapes" examples,
> > > and try to debug all those levels of structure, I find that neither for
> > > QPhongMaterial (tested it on Qt5.5.1) nor for QGoochMaterial (It works
> > > on
> > > Qt5.6.0rc1) there are no QCullFace objects in their compositions.
> > >
> > > I've also tried to make a class for mesh of two triangles based on three
> > > vertices, but rearranging indexes to make it "flip" didn't work. Neither
> > > did modifying normals or tangents.
> >
> > Instead of adding the CullFace to the materials, you can also add it to
> > the
> > framegraph. Take a copy of the ForwardRenderer.qml framegraph (if you're
> > usign
> > that) and add a StateSet (RenderStateSet in 5.7) to the tree containing
> > the
> > CullFaceState and you will also need to add in a DepthTest state object
> > too
> > since we are replacing Qt3D's default state.
> >
> > See https://bugreports.qt.io/browse/QTBUG-51770 and my comment there.
> >
> > Cheers,
> >
> > Sean
> >
> > > Thanks in advance,
> > > morodeer
> >
> > --
> > Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
> > KDAB (UK) Ltd, a KDAB Group company
> > Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090
> > Mobile: +44 (0)7545 140604
> > KDAB - Qt Experts
--
Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
KDAB (UK) Ltd, a KDAB Group company
Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090
Mobile: +44 (0)7545 140604
KDAB - Qt Experts
More information about the Interest
mailing list