[vtkusers] Rendering performance
Sebastien Jourdain
sebastien.jourdain at kitware.com
Wed Nov 24 14:07:36 EST 2010
You can use a single actor, you will need to have a programable source
that update the output dataset that has the location of each center of
the square.
Pipeline: Actor(Mapper(Glyph(CustomSource, Square)))
To change the position of a square, you can have something like that...
customSource.SetSquarePosition( suquareId, xyz )
Seb
PS: I think I wrote a sample code in Java for programmable source on the wiki...
On Wed, Nov 24, 2010 at 1:41 PM, Gib Bogle <g.bogle at auckland.ac.nz> wrote:
> Hi Seb,
>
> Although I referred to a simplified case in which the squares don't change,
> in general I need to allow for their movement. Therefore I don't think it
> will be possible for me to use a single actor. If I'm wrong, could you
> please provide a bit more detail?
>
> Thanks
> Gib
>
> Quoting Sebastien Jourdain <sebastien.jourdain at kitware.com>:
>
>> Hi Gib,
>>
>> My first question will be. Are you using one actor for each of your
>> 10000 flat squares ?
>> If so, the performance limitation may come from the number of actors
>> involved. One solution to that is to create only one dataset with all
>> the squares that has only one mapper and actor. To do so, you can
>> build it by hand or simply use the Glyph filter with your square as a
>> glyph and another dataset that has the location of those squares.
>>
>> Seb
>>
>>
>> On Wed, Nov 24, 2010 at 12:44 AM, Gib Bogle <g.bogle at auckland.ac.nz>
>> wrote:
>>>
>>> I asked about this before, but didn't attract any responses. I have a
>>> better understanding of the issue now, so perhaps my questions will make
>>> more sense.
>>>
>>> At regular intervals as my simulation program executes, I am rendering a
>>> scene that contains mainly about 1000 small spheres (which move) and
>>> about
>>> 10000 flat squares (which do not move). I have discovered that the
>>> surprising slowness of the the rendering is caused by the squares, even
>>> though the spheres have ThetaResolution and PhiResolution both equal to
>>> 12,
>>> which I guess means 144 faces per sphere, i.e. a total of 144,000 faces.
>>> By
>>> my calculations rendering the scene 288 times with spheres alone takes
>>> about
>>> 4 sec, with the squares alone takes about 20 sec, and with both spheres
>>> and
>>> squares about 24 sec. That is, 10,000 squares take 5 times as long as
>>> 1000
>>> spheres with 144,000 faces.
>>>
>>> Apparently there's something very inefficient about the way I am
>>> rendering
>>> the squares. Here is the code for tileMapper (which makes squares):
>>>
>>> // Create the square
>>> // Setup points to draw a unit square in the XY plane, at y=0
>>> vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
>>> vtkSmartPointer<vtkCellArray> vertices =
>>> vtkSmartPointer<vtkCellArray>::New();
>>> points->InsertNextPoint(-0.5, 0.0, -0.5);
>>> points->InsertNextPoint( 0.5, 0.0, -0.5);
>>> points->InsertNextPoint( 0.5, 0.0, 0.5);
>>> points->InsertNextPoint(-0.5, 0.0, 0.5);
>>>
>>> vtkSmartPointer<vtkPolygon> polygon = vtkSmartPointer<vtkPolygon>::New();
>>> polygon->GetPointIds()->SetNumberOfIds(4); //make a quad
>>> polygon->GetPointIds()->SetId(0, 0);
>>> polygon->GetPointIds()->SetId(1, 1);
>>> polygon->GetPointIds()->SetId(2, 2);
>>> polygon->GetPointIds()->SetId(3, 3);
>>>
>>> //Add the polygon to a list of polygons
>>> vtkSmartPointer<vtkCellArray> polygons =
>>> vtkSmartPointer<vtkCellArray>::New();
>>> polygons->InsertNextCell(polygon);
>>>
>>> //Create a PolyData
>>> vtkSmartPointer<vtkPolyData> polygonPolyData =
>>> vtkSmartPointer<vtkPolyData>::New();
>>> polygonPolyData->SetPoints(points);
>>> polygonPolyData->SetPolys(polygons);
>>>
>>> //Create a mapper and actor
>>> tileMapper = vtkPolyDataMapper::New();
>>> tileMapper->SetInput(polygonPolyData);
>>> tileMapper->ScalarVisibilityOff();
>>>
>>> The square actors are made like this:
>>>
>>> actor = vtkActor::New();
>>> actor->SetMapper(tileMapper);
>>> actor->GetProperty()->SetColor(boneColor);
>>> actor->GetProperty()->SetAmbient(0.5);
>>> actor->GetProperty()->SetDiffuse(0.2);
>>> actor->GetProperty()->SetSpecular(0.5);
>>> actor->SetPosition(pos);
>>> ren->AddActor(actor);
>>>
>>> then not touched again (in the simulations I report times for.)
>>>
>>> I'd be very grateful if someone could give me a clue as to what I'm doing
>>> wrong to make the rendering so slow.
>>>
>>> Thanks
>>> Gib
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>
>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list