I'm having a problem using subplot to show the difference between lighting on two separate graphs
이전 댓글 표시
I'm trying to demonstrate the difference between phong and flat lighting on a sphere but when I try to plot them together using subplot both of my graphs are in flat lighting. If you plot the two spheres individually there is nothing wrong with the lighting but when plotted together they are both flat. What is the correct way to plot both of these with the correct lighting?
[xx,yy,zz]=sphere(30);
subplot(1,2,1)
surf(xx,yy,zz);
h = findobj('Type', 'surface');
set(h, 'FaceLighting','phong', 'FaceColor', 'interp')
light('Position', [1 3 2]);
light('Position', [-3 -1 3]);
material shiny;
axis equal;
title('phong');
subplot(1,2,2)
surf(xx,yy,zz);
h = findobj('Type', 'surface');
set(h, 'FaceLighting','flat', 'FaceColor', 'interp')
light('Position', [1 3 2]);
light('Position', [-3 -1 3]);
material shiny;
axis equal;
title('flat');
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!