Edge lines not drawn when adjacent patch is transparent
Hi!
I have a problem when rendering large 3D patches of cubes. Some of my patches are transparent and some are not. The edges drawn between vertices shared by a transparent face and a opaque face is not always shown. I’ve attached a small example of code showing this behaviour below, which mimics my full plot function.
clear; clc
FirstElementAlpha = 0.;
SecondElementAlpha = 0.8;
verts = [
0 0 0;
0 1 0;
0 0 1;
0 1 1;
1 0 0;
1 1 0;
1 0 1;
1 1 1;
2 0 0;
2 1 0;
2 0 1;
2 1 1;
];
faces = [
1 2 4 3;
2 4 8 6;
1 3 7 5;
5 6 8 7;
1 2 6 5;
3 4 8 7;
5 6 8 7;
6 8 12 10;
5 7 11 9;
9 10 12 11;
5 6 10 9;
7 8 12 11;
];
facealp = [
FirstElementAlpha*ones(6,1);
SecondElementAlpha*ones(6,1);
];
colormap pink
p = patch(‘Faces’,faces,’Vertices’,verts,’Facecolor’,’flat’,’EdgeAlpha’,’flat’,’FaceAlpha’,’flat’, …
‘FaceVertexAlphaData’,facealp,’FaceVertexCData’,1-facealp,’Linewidth’,2);
p.Parent.CLim = [0 1];
view(3)
axis equal
However, if flipping the transparancy of the two elements, all edges are shown.
I want the edges to always be drawn around faces, and the transparancy of this edge to be defined by the facealpha value. Im guessing that patch defines lines between vertices, and i overwrite a opaque line with a transparant line in my code.
Is there a way to keep the line with the largest alpha value?
Can i modify my plot function, to achieve this in another way?Hi!
I have a problem when rendering large 3D patches of cubes. Some of my patches are transparent and some are not. The edges drawn between vertices shared by a transparent face and a opaque face is not always shown. I’ve attached a small example of code showing this behaviour below, which mimics my full plot function.
clear; clc
FirstElementAlpha = 0.;
SecondElementAlpha = 0.8;
verts = [
0 0 0;
0 1 0;
0 0 1;
0 1 1;
1 0 0;
1 1 0;
1 0 1;
1 1 1;
2 0 0;
2 1 0;
2 0 1;
2 1 1;
];
faces = [
1 2 4 3;
2 4 8 6;
1 3 7 5;
5 6 8 7;
1 2 6 5;
3 4 8 7;
5 6 8 7;
6 8 12 10;
5 7 11 9;
9 10 12 11;
5 6 10 9;
7 8 12 11;
];
facealp = [
FirstElementAlpha*ones(6,1);
SecondElementAlpha*ones(6,1);
];
colormap pink
p = patch(‘Faces’,faces,’Vertices’,verts,’Facecolor’,’flat’,’EdgeAlpha’,’flat’,’FaceAlpha’,’flat’, …
‘FaceVertexAlphaData’,facealp,’FaceVertexCData’,1-facealp,’Linewidth’,2);
p.Parent.CLim = [0 1];
view(3)
axis equal
However, if flipping the transparancy of the two elements, all edges are shown.
I want the edges to always be drawn around faces, and the transparancy of this edge to be defined by the facealpha value. Im guessing that patch defines lines between vertices, and i overwrite a opaque line with a transparant line in my code.
Is there a way to keep the line with the largest alpha value?
Can i modify my plot function, to achieve this in another way? Hi!
I have a problem when rendering large 3D patches of cubes. Some of my patches are transparent and some are not. The edges drawn between vertices shared by a transparent face and a opaque face is not always shown. I’ve attached a small example of code showing this behaviour below, which mimics my full plot function.
clear; clc
FirstElementAlpha = 0.;
SecondElementAlpha = 0.8;
verts = [
0 0 0;
0 1 0;
0 0 1;
0 1 1;
1 0 0;
1 1 0;
1 0 1;
1 1 1;
2 0 0;
2 1 0;
2 0 1;
2 1 1;
];
faces = [
1 2 4 3;
2 4 8 6;
1 3 7 5;
5 6 8 7;
1 2 6 5;
3 4 8 7;
5 6 8 7;
6 8 12 10;
5 7 11 9;
9 10 12 11;
5 6 10 9;
7 8 12 11;
];
facealp = [
FirstElementAlpha*ones(6,1);
SecondElementAlpha*ones(6,1);
];
colormap pink
p = patch(‘Faces’,faces,’Vertices’,verts,’Facecolor’,’flat’,’EdgeAlpha’,’flat’,’FaceAlpha’,’flat’, …
‘FaceVertexAlphaData’,facealp,’FaceVertexCData’,1-facealp,’Linewidth’,2);
p.Parent.CLim = [0 1];
view(3)
axis equal
However, if flipping the transparancy of the two elements, all edges are shown.
I want the edges to always be drawn around faces, and the transparancy of this edge to be defined by the facealpha value. Im guessing that patch defines lines between vertices, and i overwrite a opaque line with a transparant line in my code.
Is there a way to keep the line with the largest alpha value?
Can i modify my plot function, to achieve this in another way? patch, alpha, edges, plotting MATLAB Answers — New Questions