On 13/04/2017 10:14, Igor Mironchik wrote:
Hi,
13.04.2017 12:02, Sean Harmer пишет:
Hi,
On 13/04/2017 09:33, Igor Mironchik wrote:
Hi,
13.04.2017 9:58, Sean Harmer пишет:
Hi,
On 13/04/2017 07:09, Igor Mironchik wrote:
Hello,
3Dtree has been updated. Now autumn is animated. Removed hand-made
classes of leaf geometry and mesh. Now example uses ready mesh
prepared
in Blender. Modified a little constants of the tree. Example looks
nice.
This is a benchmark of your video card, because leafs and branches are
stand alone objects (QEntity). For example 5 years tree has ~ 900
objects. My Intel Pentium with Intel HD graphics normally paint only 5
years tree, 6 years tree starts to slow down.
Yes, at present each entity with a material/geometry renderer combo
gets translated to an OpenGL draw call. We are looking to add batching
(similar to how Qt Quick 2 works) but it's not there yet.
If you don't need to address each individual leaf/branch in your
object model. E.g. if you're just rendering them, then you can get
*much* better performance by using instanced rendering.
Essentially you have one entity representing all leaves. This entity
contains the material and geometry renderer as normal. The positions
and any other custom properties that vary between instances (rotation,
leaf size, leaf colour etc) should be placed into an additional
attribute/buffer and provided to the geometry renderer. On this
attribute, set the divisor property to 1 meaning that 1 piece of data
maps to 1 instance of the leave in the scene. With this approach you
will be able to render 10,000's leaves in a single draw call. It maps
through to a call to glDrawElementsInstanced() in case you want to
read up on it. Essentially you're moving the for loop over each leaf
on to the GPU.
Typically, you'd have your data for the leaves in an array in C++ and
use this to populate the leaf instance buffer.
Thank you Sean. Interesting technique. I read a little about it and
looked at the OpenGL uses of such approach.
But I have questions on how to implement this approach with Qt3D. I can
set QAttribute to the QGeometryRenderer. If this attribute will have
divisor = 1 then this attribute will affect only 1 instance. Cool, such
I can use instancing.
But I need to define attribute that will have QTransform matrix for
transformation. And one attribute with diffuse colour. So 2 attributes
per instance. Then leaves will be drawn instanced.
And here I can't understand how to do it with Qt3D.
Is it possible? Or I should do instancing in another way?
I'm sorry for the noobs questions. And thank you again.
The plan is to have a batcher that uses this instancing facility.
It will be great. And with this batching my current code will render
10,000 leaves if I share a mesh only? Or material should be shared too?
See
http://code.qt.io/cgit/qt/qt3d.git/tree/examples/qt3d/instanced-arrays-qml?h=5.9
for an example of instancing.
You need to share the same geometry and same material for all
instances in that entity. I'd suggest starting simple and just storing
the position of each leaf in the per instance buffer/attribute to
start with.
This I understood. With position or default colour I can do the trick.
But with whole transformations...
Either build the transformation matrix in C++ and pass this in as an
attribute, or pass in position/rotation/scale and build the matrix in
the vertex shader.
Cheers,
Sean
You will need a custom material as the built in materials don't
support instancing out of the box - this is waiting on the shader
generator that is in development at the moment.
Ok. Thank you.
Cheers,
Sean
Cheers,
Sean
And one more - now you can rotate the tree with the left mouse button.
11.04.2017 12:15, Igor Mironchik пишет:
Hi,
I fixed a little 3Dtree. Now branches positions are correct. And I
know that not all leafs is visible (this is because leaf geometry is
implemented as plain which renders only on one side).
10.04.2017 13:20, Igor Mironchik пишет:
Hello,
I guess that Qt3D has huge memory leaks.
You can check it on this example:
https://github.com/igormironchik/3Dtree
It's 3D tree, that grows year by year.
By default tree will grow 5 years (5 minutes).
When tree grown you can restart tree. And here I delete all
resources:
void
MainWindowPrivate::createTree()
{
if(m_tree)
{
for(constauto&e:m_rootEntity->childNodes())
e->deleteLater();
}
m_tree=newBranch(m_startPos,m_endPos,c_startBranchRadius,
true,m_rootEntity);
m_tree->setAge(0.0f);
m_tree->updatePosition();
m_tree->placeLeafs();
}
But a lot of memory are eaten.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest