Why does reversing an axis direction change shading properties?

조회 수: 1 (최근 30일)
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

채택된 답변

Star Strider
Star Strider 2012년 10월 10일
편집: Star Strider 2012년 10월 10일
The position of the light changed with respect to its original z-axis position when you reversed the direction of the z axis. You will probably have to reposition it with respect to the reversed z axis to put it back where it was originally with respect to your viewing angle.
  댓글 수: 4
Justin Solomon
Justin Solomon 2012년 10월 11일
I'll look into this more. I'll let you know if I find something. Thanks for your help!
Star Strider
Star Strider 2012년 10월 11일
Thank you!
It is my pleasure to help — I wish I actually could have found the answer. The only success I can claim is that I read everything I could find in the documentation and tried every fix that occurred to me.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt Fig
Matt Fig 2012년 10월 11일
편집: Matt Fig 2012년 10월 11일
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
Matt Fig
Matt Fig 2012년 10월 12일
편집: Matt Fig 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
Justin Solomon 2012년 10월 12일
Ok. That makes sense. I can't have my cake and eat it too it seems. Anyways, thanks a lot for your help. I learned a lot. I may search around the Opengl documentation for a solution. I'll post if I find anything.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by