Problem with rendering patch object when FaceVertexAlphaData is given
4 次查看(过去 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!