How do I Improve Graphics Performance in Matlab?

Asked by chris on 25 Apr 2012
Latest activity Commented on by Jan Simon on 28 Apr 2012

I made a 3D chess set in CATIA, converted it to VRML format (.wrl), and will use it with an AI, GUI, etc. as part of a chess program. When converting to wrl, I cut down on the file size as much as CATIA would let me, so all circular objects are octagonal. The total file size of the board and the pieces is around 2MB. I incorporated a click and drag feature on the pieces, but for whatever reason, Matlab struggles mightily to render the chess set while moving the pieces. Movement is extremely choppy and rotating the set takes forever, even with navigation style set to "fast." However, when I used a web viewer for VRML objects, rendering the chess set was child's play for the web viewer. Movement was smooth, frame rates were high, etc. But not so when viewing it in Matlab. CPU usage (using Task Manager) was at around 30-50% when I moved a piece around. That's unacceptably high. The computer specs are: Dell Precision series, nVidia graphics, xeon processor, 4GB ram.

Anyway, why is this? I looked around on Mathworks for a possible cause, but no luck. I would appreciate any help, as this project is due in a few days. I tried everything, but to no effect.

0 Comments

chris

Products

No products are associated with this question.

3 Answers

Answer by Jan Simon on 26 Apr 2012

Which Matlab version are you using? Which renderer is active? And if it is OpenGL, do you use the hardware or software rendering? How do you move and rotate the objects?

I do not have problems to display 21 spheres of 10*10 facettes and 25 cyclinders, a checkerboard floor and some 2D stuff with the hardware OpenGL renderer. This GIF is recorded with about half real-time on a PentiumM 1.5GHz, 512MB, a 16MB graphics card (a T40 IBM laptop), Matlab 2009a:

I can add further objects without reducing the fluently appearence. surface objects are drawn faster than patch objects. Therefore I assume your slow displaying is a problem of the VRML viewer in Matlab. Can you convert the objects to surface objects?

5 Comments

chris on 26 Apr 2012

I made a vrml file of the chess set, with planesensors in it. The code for the whole set is around 20,000 lines. I open the set by double clicking on the file in the directory. i don't mess with any settings or anything.

chris on 26 Apr 2012

I'm pretty sure the computer is not taking advantage of hardware acceleration or whatever, because the web view does (directx or opengl), and it is loads faster. I just need to know how to set it so Matlab tells itself to use hardware acceleration instead of simply relying on just the CPU.

chris on 26 Apr 2012

And what code should I post? I don't run any code to open the file. I could post the vrml code, but that's 20,000 lines.

Jan Simon
Answer by chris on 26 Apr 2012

Does anybody else have an idea of how to fix this? Its quite urgent.

6 Comments

Daniel on 28 Apr 2012

@Chris, clearly you didn't read either of the links I provided. As Walter says "This is not a resource for HELP NEEDED URGENTLY. If you need help urgently, then you should be hiring a consultant, such as http://www.mathworks.com/services/consulting/"

I highly doubt that we need such a complicated VRML file to see the problem in the rendering. YOU need to spend the time to create an example that we can follow. Then you need to tell us what you see/get and what you expect to see/get. Without that it is highly unlikely that we can help you.

chris on 28 Apr 2012

I read the links. However, because this project is due in 2 days, it's a very urgent issue. And I can't afford to hire someone, because I'm a college student with hardly any money.
All I'm trying to do with the vrml file is to open it up and expect the viewer to perform like a normal vrml viewer. but what I see is a slow, jerky vrml renderer. An example to witness this effect would simply be opening a file bigger than 2MB in Matlab and trying to rotate it. Then open the same file in a normal vrml viewer and seeing that it rotates the model like it's nothing. I'm certain it is a software render vs. hardware render issue. That is all. I didn't think it was a complicated issue.

Jan Simon on 28 Apr 2012

Chris, please read the links again. And if they are still not clear, read them again. Walter is a very experienced programmer. This does not only mean, that he can use the correct syntax, but this requires a deeper knowledge of the physical background and efficient application of project management tools. Participants of this forum can profit from Walter's knowledge for free! If he tells you, that your problem is not urgent, it is worth to think as long about this opinion until you get his point.

chris
Answer by Jan Simon on 28 Apr 2012

Although you repeatedly claim, that your project is urgent, you needed 3 days to tell us, that you use the "Simulink 3D animation internal viewer" to display the VRML file. Instead of this important detail, you explained details about your work with CATIA - a software or language I do not know and as far as I understand it is not relevant for the problem.

You said that 30-50% cpu load during moving a piece around is unacceptable high. Why? I would accept 100% or is a partially sleeping cpu important for your project? If so, why?

But let me summarize the already mentioned facts:

  1. You are using the Simulink 3D animation internal viewer to display a not really large VRML scene.
  2. You are not satisfied with the performance.
  3. Neither you nor another user of this forum knows a magic switch, which makes the viewer 3 or 4 or what ever times faster - btw, you did not specify which amount of acceleration is wanted.

Then this conclusion is obvious: The Simulink 3D animation internal viewer is not sufficient for your project. This is not a fault of Matlab, you simply had wrong expectations and did not test this early enough.

I see two solutions:

  • Either use another tool for displaying. I have explained, that Matlab can display surface objects with a sufficient speed for user interactions in 3D. I do not think that this can be programmed in 2 days.
  • Face the facts and finish the project with an unfinished visualization. This would not be the first project, which is not ready in time. All professional programmers have experiences with a failing project management.

I hope and think, that you have learned a lot from this project. Therefore I'm still convinced, that your problem is not "urgent". Wearing burning socks is an urgent problem. I have the impression, that you simply did not start to solve the problem early enough. Then repeating the project next term or year with more experiences is a valuable solution.

And for questions in this forum, other forums or scientific discussion, I repeat the suggestion to read and consider http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer . A good question is succinct and requires no guessing for the answering.

Good luck!

0 Comments

Jan Simon

Contact us