Search code examples
matlabplot3dtransparencygeometry-surface

How to emphase some region on a spherical surface


Introduction

I'm trying to emphase some region on a spherical surface saying that this region should be colored as not transparent (alpha = 1.0) and other parts of the sphere should be colored as semi-transparent (alpha = 0.5).

Problem

Considering WAlpha(Data >= DummyValue) = 1.0 and WAlpha(Data < DummyValue) = 0.5, the following command does not work as expected:

surf(X, Y, Z, Data, 'AlphaData', WAlpha, 'FaceAlpha', 'interp');

It draws all non-selected region as fully-transparent:

Wrong transparency

Note

I have no issue when setting 'FaceAlpha' to scalar value (i.e its not an issue with my graphic card):

surf(X, Y, Z, Data, 'AlphaData', WAlpha, 'FaceAlpha', 0.5);

Semi transparent everywhere

Source code

Here is the link to the very short and dummy code I created to reproduce the issue: link

Please let me know if you have any other idea for emphasing selected region rather than using transparency.


Solution

  • Here is quick test:

    %# surface data
    Z = membrane;
    
    %# alpha-transparency matrix
    A = ones(size(Z))*0.3;          %# transparent by default
    A(abs(Z)>0.5) = 1;              %# make certain region opaque
    
    %# plot
    figure('Renderer','opengl')
    surf(Z, 'AlphaData',A, 'AlphaDataMapping','none', ...
        'FaceAlpha','interp', 'EdgeColor','none')
    

    Result:

    screenshot