MATLAB Figure Rendering: OpenGL vs. Painters?
Asked Answered
D

1

6

I'm clueless when it comes to which renderer to use for MATLAB figures or when it matters, but I have come across certain examples where it does matter:

plot(0,0,'ko','markersize',50,'linewidth',8);
set(gcf,'renderer','opengl');
set(gcf,'renderer','painters');

Left=OpenGL, Right=Painters:

OpenGL resultPainters result

(running Windows 7 Professional and MATLAB R2015b)

Are there times when using the OpenGL renderer produces better results than Painters? In general how do the two renderers differ?

Davao answered 16/11, 2015 at 18:29 Comment(4)
Interesting question. Talking as a layman on graphics rendering who regularly has to produce publication-quality figures with MATLAB, a definitive answer to this one would be nice.Emplacement
Read here. Painters is usually faster. OpenGL makes a big difference in the quality of 3-D plots, especially if you're using lighting or transparency, or if you have a Retina display.Enervated
Is there a way to set "painters" as default for all plots? In R2016a the default is "opengl". EDIT: Found an answer: put set(0, 'DefaultFigureRenderer', 'painters'); in startup.m.Metameric
The link by @Enervated is broken, but a short explanation is given here.Weinberger
I
1

These are the differences I know of

  • OpenGL is the default renderer
  • OpenGL allows to plot transparency and Painter does not
  • If there is a graphical bug when using OpenGL or if Matlab crashes, use Painter
  • Select Painter to export figures in postscript format. Using OpenGL when the figure gets too complex, Matlab saves as Bitmap and you cannot edit it.

From the Mathworks website (Scroll down to "renderer"):

  • 'opengl' — OpenGL® renderer. This option enables MATLAB to access graphics hardware if it is available on your system. The OpenGL renderer displays objects sorted in front to back order, as seen on the monitor. Lines always draw in front of faces when at the same location on the plane of the monitor.

  • 'painters' — Painters renderer. This option works well for axes in a 2-D view. In 2-D, the Painters renderer sorts graphics objects by child order (order specified). In 3-D, the Painters renderer sorts objects in front to back order. However, it might not correctly draw intersecting polygons in 3-D.

See also this link on fixing low level graphics issues with OpenGL.

Ikhnaton answered 2/2, 2019 at 4:5 Comment(2)
I have added links.Ikhnaton
so painters seem to use the CPU exclusively for rendering. In situations where Z-fighting might occur with opengl (e.g. plotting a 2d object in the same plot with a 3d plot object), painters appear to display surfaces consistently.Faucet

© 2022 - 2024 — McMap. All rights reserved.