It seems to me that Qt3D cannot render 2D meshes well. To see what I mean open the shadow map QML example and change the camera controller from FirstPersonCameraController to OrbitCameraController. Run the program and attempt to view the ground plane from below, you will see it disappear. So QT3D just renders 2D meshes from one side and makes them transparent from the other side.
How can I fix this? i.e. render 2D meshes from both sides?
EDIT: Now I know that I have to disable culling for the rendering to work. I came up to this point:
//'this' refers to Qt3DWindow
rootEntity->addComponent(this->renderSettings());
QCullFace *face = new QCullFace();
QRenderStateSet *stateSet = new QRenderStateSet(this->renderSettings()->activeFrameGraph());
QRenderSurfaceSelector *selector = new QRenderSurfaceSelector(this->renderSettings());
face->setMode(QCullFace::NoCulling);
stateSet->addRenderState(face);
selector->setSurface(this);
but this still doesn't seem to change anything. Am I missing something?
Here is a minimally working example:
main.cpp
:graphicswindow.h
:graphicswindow.cpp
:Keep in mind that the
setActiveFramegraph
function of theQt3DWindow
automatically adds theQRenderSettings
returned by therenderSettings()
function of the window on the frame graph node that you set as the active frame graph. If you are implementing your own 3D window or create and offscreen renderer you have to useQRenderSettings
as the root node of your framegraph (the window sets its render settings as the parent of the root frame graph node that you set) and add the render settings to the actual root node, i.e. the node that is the parent of the frame graph and the scene graph.