Why does reversing an axis direction change shading properties?
이전 댓글 표시
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
채택된 답변
추가 답변 (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
Justin Solomon
2012년 10월 12일
편집: Justin Solomon
2012년 10월 12일
Star Strider
2012년 10월 12일
편집: Star Strider
2012년 10월 12일
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
2012년 10월 12일
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
2012년 10월 12일
편집: Justin Solomon
2012년 10월 12일
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
2012년 10월 12일
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!