I want to not draw some objects on the scene. In normal OpenGL we have just to not call function related to drawing the mesh.
Unfortunately I didn't found this "functionality" in the QML. The Entity doesn't contain the "visibility" attribute etc. Of course we can try to send the uniform to the shader and just discard the rendering when needed - it will work but this approach doesn't look good.
Is possible do to that by using QML or full rendering functionality should be created in cpp file?
Yes it is possible.
The easiest solution is to remove the material from your entity. You would have something like this:
Entity {
property bool visible: true // or ideally, dynamically read from a c++ property or whatever suits you
Material {
id: myMaterial
// stuff
}
GeometryRenderer {
id: myRenderer
// stuff
}
components: visible ? [myMaterial, myRenderer] : []
}
Another solution (maybe a bit more difficult) is to use filters in the Effect you use in your material. The Effect component will have one or several RenderPasses. Each of these render passes can have filter keys:
RenderPass {
id: myPass
filterKeys: [ FilterKey { name: "PassType"; value: "customFilterIdString" } ] // <-- This line here
renderStates: [
BlendEquationArguments {
...
},
...
]
}
Each render pass can be filtered in your RenderTree Using the RenderPassFilter component. This allow you to skip whole set of object and order the way passes are done. This is a bit more advanced and I don't think you need it if you just want to hide specific objects, but don't hesitate to read the doc and look for examples using these components
The easiest way is actually to set the enabled property of the entity to false.
For finer and more versatile control, you could look at using QLayer components.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With