Why does reversing an axis direction change shading properties?
Mostra commenti meno recenti
I am working on an interactive GUI. Part of the GUI contains an axis which is used render 3D objects. I need to use a left-handed coordinate system in this axis. Thus I run the line below to flip the z-axis
set(gca,'ZDir','reverse')
When I do this, the lighting of the object becomes very flat:
Compare this with the rendering before flipping the z-axis:
Anyone know why this would be? I much prefer the way the second (non-flipped) rendering looks. Any way to reproduce this 'shiny' look and still have a flipped z-axis?
Thanks, Justin
Risposta accettata
Più risposte (1)
I am not sure if this will help at all. It might help if you provide some code. Here is what I did to simulate what I see in your images:
figure
ax(1) = subplot(1,2,1);
sphere(300);
L = light;
box
ax(2) = subplot(1,2,2);
sphere(300);
L(2) = light;
box
axis(ax,'equal')
H = findobj('type','surf');
set(H,'edgecolor','none')
set(H,'facecolor',[.5 .5 .5])
set(ax(2),'zdir','reverse');
Now if this looks like what you see, and is similar to what you did, then have a look at what this command does:
set(gcf,'render','z')
Now we can move the light to make things the same:
set(L(2),'pos',[1 0 -1])
6 Commenti
Justin Solomon
il 12 Ott 2012
Modificato: Justin Solomon
il 12 Ott 2012
Star Strider
il 12 Ott 2012
Modificato: Star Strider
il 12 Ott 2012
The best I can come up with for documentation on that is Figure Properties — Renderer. I didn't even know it existed until now, much less its import to correct figure appearance.
Matt — If this isn't correct, please provide the correct link.
Justin — Thank you for raising this problem. I learned something.
EDIT — It may be time to contact TMW with a bug report on this problem if Matt's 'Renderer' fix didn't solve your problem.
Matt Fig
il 12 Ott 2012
Yes, it is the renderer. Sorry, I am used to using partial property names in MATLAB (because I can, as long as no ambiguity between properties arises). Since there is only one figure property that begins with an 'R' (Renderer), and this property has only one option that begins with a 'Z' (Zbuffer), this actually will set it:
set(gcf,'r','z');
But of course it can be confusing to people who don't know this!
Anyway, glad your issue is fixed!
Justin Solomon
il 12 Ott 2012
Modificato: Justin Solomon
il 12 Ott 2012
That's the catch. And this is a well known issue that MATLAB has had forever. Only opengl supports both lighting and transparency... If you open up the doc and search for:
renderer transparency
you will find these things discussed. Opengl is often buggy, and system dependent. It looks like you have stumbled upon yet another opengl issue. If you read the doc for opengl, you may find one of the settings works for you, but I doubt it.....
Justin Solomon
il 12 Ott 2012
Categorie
Scopri di più su Graphics Performance in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!