Problem with rendering patch object when FaceVertexAlphaData is given
조회 수: 3 (최근 30일)
이전 댓글 표시
When I create a single patch object with different transparency and color per face, Matlab R2016b under OSX seems having a bug in rendering it. A simple example with two cubes gives the following plot, see Matlab code below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159960/image.png)
The main problem with this image is, that the red cube should be in the front, and it is non-transparent (alpha=1), still I see the green cube behind. I tested the same code on R2015b and the rendering looks the same.
% vertices for a cube
Vcube = [0 0 0;1 0 0;1 1 0;0 1 0;0 0 1;1 0 1;1 1 1;0 1 1];
% faces for a cube
Fcube = [1:4;1 2 6 5;2 3 7 6;3 4 8 7;4 1 5 8;5:8];
% red color for the faces of the cube
Cred = repmat([1 0 0],[6 1]);
% green color for the faces of the second cube
Cgreen = repmat([0 1 0],[6 1]);
% non-transparent first cube (defined on all 6 faces)
A = ones(6,1);
% two cubes
V2 = [Vcube;bsxfun(@plus,Vcube,[2 2 -1])];
F2 = [Fcube;Fcube+8];
% color for the 2 cube
C2 = [Cred;Cgreen];
% different transparency for the two cubes, red one is non-transparent,
% green is semi transparent
A2 = [A;A/2];
clf
hPatch = patch('Vertices',V2,'Faces',F2,...
'FaceColor','flat','FaceVertexCData',C2,...
'FaceAlpha','flat','FaceVertexAlphaData',A2,...
'AlphaDataMapping','none');
axis off
axis equal
axis([-1 4 -1 4 -2 2])
view(3)
If this is a bug (I believe it is), is there any known workaround?
Thanks!
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!