Increasing HG2 framerate when updating large meshes: mission impossible?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Dear all,
since the introduction of HG2 I have been fighting with its associated performance issues. This is mostly why I've continued using with my dear old R2012a with HG1. Now I'm trying to force myself to move to HG2 versions...but without success!
One of the typical things I have to do is visualizing animations of quite large meshes which change their properties. I do this with typical for-loops containing set(...,'vertices',...) to update the coordinates of the vertices.
While HG1 was ok in terms of speed (apart from the never solved issue of bug 415190), performance of HG2 are so poor that, for me, it is almost unusable for the above mentioned tasks. And new matlab versions do not seem to improve the performance to a level even comparable with HG1.
This is an example code, with a relatively small mesh, to see the issue (I use much larger meshes, so the problem is much worse):
---------------
[x,y,z,v] = flow;
[F1,V1]=isosurface(x,y,z,v,-3);
F1=[F1;F1+max(F1(:))]; %just to increase the mesh dimension
V1=[V1;V1+10]; %just to increase the mesh dimension
[F2,V2]=isosurface(x,y,z,v,-1);
F2=[F2;F2+max(F2(:))]; %just to increase the mesh dimension
V2=[V2;V2+10]; %just to increase the mesh dimension
figure
p1 = patch('faces',F1,'vertices',V1,'Facecolor','y','Edgecolor','k');
p2 = patch('faces',F2,'vertices',V2,'Facecolor','m','Edgecolor','b');
axis equal;
view(3)
tic;
for i=1:100
set(p1,'vertices',V1+pi*i);
set(p2,'vertices',V2+pi*i);
drawnow;
end
fprintf('fps=%0.3f',i/toc);
------------------------
Results:
R2012a (HG1): fps=92.766
R2017a (HG2): fps=19.848
Ratio R2012a/R2017a : 4.7
The difference is striking! Of course HG2 graphics has a nicer rendering, but an fps reduced by a factor of almost 5 is a little bit a too high price for smoother and nicer rendering...
So now my question: is there any way to have HG2 to get close to HG1 performance for this task? If not, this is somewhat a serious problem, because, on the one hand, keeping coding with old matlab releases is not recommended. At the same time, moving to new releases is prevented from the performance reduction of the graphical engine.
Any answer/suggestion/magical trick?
Thanks,
Gabriele
1 comentario
Walter Roberson
el 18 de Mzo. de 2017
For a question like this, I think it would be better to open a support case.
Respuestas (2)
Yair Altman
el 20 de Mzo. de 2017
Editada: Yair Altman
el 20 de Mzo. de 2017
There is indeed a performance penalty for HG2 compared to HG1. One thing that could alleviate the pain is to use the new 'limitrate' input of the drawnow function
Sean de Wolski
el 20 de Mzo. de 2017
What about using an hgtransform?
t = hgtransform;
set([p1 p2],'parent',t);
for i=1:100
tform = makehgtform('translate',zeros(1,3)+(pi+i));
set(t,'Matrix',tform);
% set(p1,'vertices',V1+pi*i);
% set(p2,'vertices',V2+pi*i);
drawnow;
Note that with drawnow limitrate, I get 1000fps, not sure if this is what you want or not.
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!