Colour interference when two surfaces overlap

Respuestas (1)

Piyush Kumar
Piyush Kumar el 18 de Jun. de 2024
Editada: Piyush Kumar el 18 de Jun. de 2024
Hi @xin,
If you are talking about the blending of colours at the point where surfaces intersect or overlap, I will try to explain with an example.
[X,Y] = meshgrid(linspace(-2, 2, 50));
Z = @(x,y,c) x.^2 + y.^2 + c;
figure(1)
surf(X, Y, +Z(X,Y,-4), 'FaceColor','g', 'FaceAlpha',0.5, 'EdgeColor','none')
hold on
surf(X, Y, -Z(X,Y,-4), 'FaceColor','r', 'FaceAlpha',0.5, 'EdgeColor','none')
hold off
grid on
I have specified only 2 colours for the 2 surfaces repectively, but multiple colours are visible. This blending effect is a result of the rendering process in MATLAB, where the semi-transparent (due to 'FaceAlpha',0.5) surfaces allow for the underlying color to show through, creating a visual effect of color mixing or interference.
To avoid this color blending effect and maintain the solid colors you've specified without seeing a mix at the intersections, you can:
  • Increase the Opacity: Setting 'FaceAlpha' to 1 (or removing the 'FaceAlpha' setting, as its default value is 1) will make the surfaces fully opaque, preventing the underlying color from showing through.
[X,Y] = meshgrid(linspace(-2, 2, 50));
Z = @(x,y,c) x.^2 + y.^2 + c;
figure(1)
% Making the surfaces opaque by removing 'FaceAlpha'
surf(X, Y, +Z(X,Y,-4), 'FaceColor','g', 'EdgeColor','none')
hold on
surf(X, Y, -Z(X,Y,-4), 'FaceColor','r', 'EdgeColor','none')
hold off
grid on

4 comentarios

Piyush Kumar
Piyush Kumar el 18 de Jun. de 2024
Additionaly, you can explore the properties of chart surface objects here
xin
xin el 18 de Jun. de 2024
Thanks for your answer, but I try to remain semi-transparent with FaceAlpha=0.8, colour overlapping still exists.Is there any other way of rendering it?
Piyush Kumar
Piyush Kumar el 18 de Jun. de 2024
Can you share the code you are using?
xin
xin el 19 de Jun. de 2024
Of course,please import the data into the workspace at first.

Iniciar sesión para comentar.

Productos

Versión

R2018b

Etiquetas

Preguntada:

xin
el 18 de Jun. de 2024

Comentada:

xin
el 19 de Jun. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by