1

I need to render a translucid sphere so I can render and visualize solid lines inside it and generate images for a publication. But when rendering a sphere with FaceAlpha lesser than 1, a weird artifact appears. Sure, the sphere is still translucid, but that's not a good quality. Light source position doesn't change anything. The problem only appears when transparency is on. 1.Why this is happening? 2.How can I get rid of this artifact?

This is the code, used in Octave 8.1.0:

% Define the sphere parameters
radius = 1;
resolution = 50;

% Generate the coordinates for the sphere surface
theta = linspace(0, 2*pi, resolution);
phi = linspace(0, pi, resolution);
[theta, phi] = meshgrid(theta, phi);
x = radius * sin(phi) .* cos(theta);
y = radius * sin(phi) .* sin(theta);
z = radius * cos(phi);

% Plot the sphere with adjusted shading
figure;
surf(x, y, z, 'FaceAlpha', 0.5);
shading interp;  % Adjust the shading mode

% Set the axis aspect ratio to 1:1:1
axis equal;

% Add labels and title
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Sphere');

% Adjust the viewpoint if needed
view(45, 30);

And this is the weird result. I have rotated the sphere to better visualize the sphere artifact.

RodrigoCns
  • 111
  • 4
  • After asking help from a friend, it seems that this is a problem of "self-transparency" (we found something about it here: https://www.shapediver.com/blog/solving-a-common-webgl-issue-transparency-fixed ). Still no idea how to solve it, and I am not sure if this is indeed a self-transparency problem. – RodrigoCns May 23 '23 at 18:48
  • **(a)** Is this `view( azimuth, elevation )`-vector specific, not showing these artifacts from some directions? If yes, the artifacts seem to be specific to certain `meshgrid()`-`view()`. Given an outcome of **[a]**, have you tried **(b)** any other sampling ( via smaller | larger value of `resolution` )? **(c)** any additional phase-shift ( via adding some small, sub-`linspace()`-resolution, phase-shift pos- | neg- values to `phi` and `theta` for a slightly pre-"turned" `meshgrid()` generation )? – user3666197 May 26 '23 at 13:40
  • **(d)** does the same reproduce once a true `surfl()`-function calls are used ( light-model was not used in a `surf()`-call above, only in `surfl()` ). Documentation explains currently supported light-models *"(...) Supported values are "`none`" (no lighting effects), "`flat`" (facetted look) and "`gouraud`" (linear interpolation of the lighting effects between the vertices)."* Does the same happen after using the `gouraud`-mode in different `view()`-angles and `meshgrid()`-sub-sampled/-super-sampled + phase-shifted mesh-data generated? – user3666197 May 26 '23 at 14:00
  • (a) There are some specific directions that "hide" the artifact, if I align the ZX plane with the screen, for example, but this severely limits the perspective notion of the object. (b)Yes! These "disc shades" seems like "orange segments" and the resolution defines how much segments there are, but only the segments on the right of a given view show this artifact. I will test (c) and (d) soon and then I will update the post with complete information. – RodrigoCns May 28 '23 at 22:19

0 Answers0