Changing alpha property on surface objects causes text objects in GUI to flip direction?

1 view (last 30 days)
I'm creating a GUI that (among other things) uses surface plots in a central axes. I have a transparency button that I have written with a callback to change the alpha setting of the central axes, to adjust the transparency of the surfaces. However, this is causing the x/y/z tick numbers as well as the axis labels to 'flip', as if someone's reflected them in a mirror. It's also affecting other text objects in the GUI that aren't related to the main axes.
.
This is happening when both calling alpha(X) or using findobj('Type','Surface') and manually setting all the surface alpha values with get/set. I'm totally at a loss as to why the text objects appear to be modified at all, let alone with this particular behaviour. When I use the button again to remove the transparency, the text objects are then returned to their original state. From looking at the exact line of code that seems to cause the flip, it's simply alpha(0.8) that does it.
.
I'm running on Vista x32, R2010a.
.
That code snippet in the answer below runs fine. I can't seem to make the issue occur anywhere except in my GUI. I will see if I can repeat the error on a different version. Otherwise I can post my GUI and an example file to read into it, and perhaps you will see where the problem comes in.
.
Has anyone seen this before, or know how I can stop it happening?
  1 Comment
Todd Flanagan
Todd Flanagan on 21 Jan 2011
Walter said, "Which version are you using and which OS? I seem to recall hearing about something like this in one of the 2009 releases, possibly only for Mac OS-X.
I just looked at the code of alpha.m in 2008a and cannot see anything in there that would cause this behaviour."

Sign in to comment.

Answers (5)

Doug Hull
Doug Hull on 21 Jan 2011
The change might be because you are changing renderers when you add the transparency. Of the three renderers in MATLAB, only OpoenGL supports transparency.
Try the following one line at a time:
get(gcf,'renderer') %before and after transparency
set(gcf,'renderer','painters')
set(gcf,'renderer','zbuffer')
set(gcf,'renderer','opengl')
Did you get the text change between renderers?
  2 Comments
Emily
Emily on 4 Feb 2011
Hi Doug
Apologies for the delay in getting back to this. Yes, it appears that setting the renderer from 'zbuffer' to 'opengl' causes the text objects to flip over.
Is there any way of preventing this? I'm at a loss as to why it happens to start with, but it is obviously necessary to use OpenGL for the transparency effects.
Thanks,
Emily
Emily
Emily on 4 Feb 2011
OK, so I've experimented with removing the hardware acceleration on the OpenGL rendering, and it appears to have fixed the flipping text object problem. However, it has now caused a different one, in that it seems to get confused as to whether a surface is obscuring a point or not - some points are visible 'above' a surface, even though they shold be underneath it when being viewed from a given angle.
Any ideas on this?
Thanks!

Sign in to comment.


Matt Fig
Matt Fig on 20 Jan 2011
Would you post some code that reproduces what you see? For example, this does not reproduce what you are seeing on my machine:
[X,Y,Z] = peaks(30);
S = surf(X,Y,Z)
axis([-3 3 -3 3 -10 5])
xlabel('XLABEL'),ylabel('YLABEL'),zlabel('ZLABEL')
alpha(.8)

thomas decloedt
thomas decloedt on 29 Jan 2011
Hi ,
i am having a related problem. I like using the patch function to show the confidence intervals of a variable. Unfortunately, setting 'FaceAlpha' to some transparent value causes the lower and left side of the box around the figure and legend to disappear. Changing the renderer to zbuffer or painters, the box reappears but then the transparency does not work.. I think it is a mac os x 10.6/matlab compatibility problem? Bummed that plotting figures on mac in matlab does weird stuff i never saw before on older macs
MATLAB Version 7.10.0.499 (R2010a) MATLAB License Number: ########## [SCd Censor] Operating System: Mac OS X Version: 10.6.6 Build: 10J567 Java VM Version: Java 1.6.0_22-b04-307-10M3261 with Apple Inc. Java HotSpot™ 64-Bit Server VM mixed mode ---------------------------------------------------------------------
  1 Comment
Emily
Emily on 4 Feb 2011
Transparency will not work with any renderer except OpenGL. Unfortunately, because you're on a mac, you also don't have the option of removing the hardware acceleration on the opengl renderer I don't think.

Sign in to comment.


Brett Shoelson
Brett Shoelson on 4 Feb 2011
Emily, You've run into a known issue with an incompatibility between your hardware and your version of OpenGL. You can circumvent the problem by implementing openGL in software, rather than in hardware. Try executing:
openGL software
and rerun... Cheers, Brett
  3 Comments
Emily
Emily on 5 Feb 2011
Hi Brett
I've noted this above, and already solved the issue by using software rendering. But that in itself has thrown up some other issues (see comments on Doug's reply).
Do you have any idea on these?
Emily
Brett Shoelson
Brett Shoelson on 9 Feb 2011
Unfortunately, Emily, I don't have a workaround for issues caused by switching to software rendering. It may sound like a cop-out, but it's not really a MATLAB issue. Sorry.

Sign in to comment.


Tong
Tong on 24 Nov 2011
Just want to leave a words to express my thanks to Brett. I ran the code and fixed my problem of the mirrored ticks, ending up my effort to solve it after quite a lot of time.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!