Transparency Ghosting Effect in Rendering of Ellipsoid Surfaces
20 次查看(过去 30 天)
显示 更早的评论
I have been attempting to render ellipsoids of various scales and rotations in MATLAB using the built-in ellipsoid() function; however, I have run into repeated graphical errors when rendering these for which I have been unable to pin down a cause.
Specifically, some ellipsoids will display a sort of "ghosting" effect, in which the opacity of the ellipsoid will change suddenly despite a constant FaceAlpha value. Attached are several screenshots of the issue:
![An ellipsoid showing ghosting effects.](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1740981/An%20ellipsoid%20showing%20ghosting%20effects.png)
![An ellipsoid showing ghosting effects.](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1740986/An%20ellipsoid%20showing%20ghosting%20effects.png)
![An ellipsoid showing ghosting effects.](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1740991/An%20ellipsoid%20showing%20ghosting%20effects.png)
I have noticed the following patterns with the ghosting:
- The ghosting effect appears to depend on window size
- Ellipsoids can be fully ghosted (i.e., much more transparent than expected)
- The ghosting appears to happen when one axis of the ellipsoid is much shorter than the other two
- The ghosting is very dependent on the camera angle
- The ghosting appears to be dependent on the rotation of the ellipsoid (I have yet to generate a single axis-aligned ellipsoid that suffers from ghosting)
- The ghosting happens for a wide range of FaceAlpha values
I have tested ellipsoid generation on both Windows and Linux, as well as using both R2019b and R2024a, and all display this ghosting effect for some cases (it is not predictable when or for which view angles as far as I can tell). I am using OpenGL hardware rendering on Windows.
My questions are as follows:
- What is the root cause of this issue?
- Is there a workaround that will work for any orientation and size of ellipsoid?
Thank you for your time.
The following script was used to generate the ellipsoids in the images above (on a Windows machine running R2019b with OpenGL hardware rendering and Intel UHD Graphics 620 graphics unit):
% Generate a random rotation matrix
L = randn(3);
C = L * L';
[V, ~] = eig(C);
if det(V) == -1
V(:, 2) = -V(:, 2);
end
% Ellipsoid axis sizes
D = [20, 5, 0.01];
% Generate 101 x 101 meshgrids for ellipsoid coordinates
[X, Y, Z] = ellipsoid(0, 0, 0, D(1), D(2), D(3), 100);
% Rotate ellipsoid into frame defined by rotation matrix
coords = (V * [X(:)'; Y(:)'; Z(:)'])';
% Convert points back into meshgrids
X = reshape(coords(:, 1), size(X));
Y = reshape(coords(:, 2), size(Y));
Z = reshape(coords(:, 3), size(Z));
figure();
hold on;
surf(X, Y, Z, 'EdgeColor', 'none', 'FaceColor', 'b', 'FaceAlpha', 0.5);
1 个评论
DGM
2024-7-26
FWIW, I see the same effect in R2019b/linux/softwaregl. I don't know that it's an issue with ellipsoid(), but more of a rendering problem.
I am really unsure what's going on, but I wonder if it has something to do with the extreme aspect ratio of the ellipsoid and accuracy of the projection calculations during rendering. Considering the edge regions (where the ellipsoid is thinnest), it's almost like the front/back faces are swapped, discarded or something else. That doesn't really make sense, but I'm trying to figure out why there would be a sudden decrease in the total opacity along that path.
I havent done any work to test that, but if I "fatten" the aspect ratio a bit (or keep it grid-aligned as you say), the issue seems to be subdued.
回答(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!