vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
533 stars 89 forks source link

Rendering issues (Maybe only on Mac M1?) #462

Closed kellertuer closed 2 weeks ago

kellertuer commented 2 weeks ago

Hi, first of all thanks for proving such a nice package – it has helped me generating great 3D graphics for a lot of years.

However, a while back, rendering on M1 Macs stopped working correctly. I already posted bout it here, but though maybe posting it as an issue here as well might draw some attention, since I seem to not be the only one having the problem.

If I take the code

import three;
import solids;unitsize(4cm);

currentprojection=perspective( camera = (1.0, 0.5, 0.5), target = (0.0, 0.0, 0.0) );
currentlight=nolight;

revolution S=sphere(O,0.995);
pen SpherePen = rgb(0.85,0.85,0.85)+opacity(0.6);
pen SphereLinePen = rgb(0.75,0.75,0.75)+opacity(0.6)+linewidth(0.5pt);
draw(surface(S), surfacepen=SpherePen, meshpen=SphereLinePen);

/*
  Colors
*/
pen pointStyle1 = rgb(0.0,0.4666666666666667,0.7333333333333333)+linewidth(3.5pt)+opacity(1.0);

/*
  Exported Points
*/
dot( (0.9837117687894378,-0.17755131744105618,0.0280479165019622), pointStyle1);
dot( (0.9838420262712789,-0.05982681995903209,-0.1687472042909554), pointStyle1);
dot( (-0.0917525024594581,0.20000514884698506,0.9754893227130282), pointStyle1);
dot( (0.07844742532720095,0.5643971870536215,0.8217674955274712), pointStyle1);
dot( (0.8640095918651447,-0.32042627848327054,0.3883483297535702), pointStyle1);
dot( (0.09891843208768877,-0.3385482932829229,0.9357351104391312), pointStyle1);
dot( (0.5391307236127518,0.6639024159319173,0.518238984423744), pointStyle1);

and would like to render this with asy -render 4 -f png temp.asy (in order to get a high resolution result for a paper say), I get

temp

So the sphere is cut off and (persistently) only the bottom left part is (a bit) rendered, the rest is not.

What might be the reasons?

johncbowman commented 2 weeks ago

Thank you for your bug report. This bug was introduced well over 2 years ago, in version 2.79, so it is strange that it went unreported for so long. The root of the problem is that MacOS does not give you access to the key architectural feature (SSBO) required for transparency. A very approximate work around is implemented that can handle some very simple cases, but unfortunately this bug prevented this fallback code from working at all.

The best solution would be to abandon OpenGL (which has not been maintained by Apple for about a decade now) and switch over to the Vulkan version of Asymptote, which is currently in the branch vulkan. However, it doesn't work yet on all MacOS platforms. Help from users in testing the vulkan branch under MacOS platforms would be appreciated, as I don't have access to a machine with Metal support.

kellertuer commented 2 weeks ago

I am sadly just a mere mortal, but the stack exchange post is actually 1.5 years old, I was just not aware of this repository here.

For a mere mortal who would even have to check whether I have asymptote installed via home-brew or the LaTeX package manager, how would I “switch over”? In my current works I have completely abandoned Asymptote, since I considered myself too stupid to use it (good to know after all that time that it was/is a bug), but every now and then I would like to be able to rerun old experiments that still use Asymptote. For your description, I have no clue how to best continue from here.

edit: I do not even see what or where a “vulkcan” version is, since this repo does not even have any readme. But it is also c/c++ code and I would have zero clues how to compile that (again, I am merely a poor mortal born a bit late to speak assembler as my mother tongue).

johncbowman commented 2 weeks ago

Stack exchange isn't really meant for posting bug reports; we don't automatically get notified of issues posted there. So thank you again for your report. Within the next day or so I will be releasing Asymptote 2.90, which includes this bug fix, and hopefully that version will appear on macports shortly thereafter. The vulkan port is still in a beta stage, so don't worry about it right now.

kellertuer commented 2 weeks ago

Well until 8. hours ago I did not think that was a but, but mainly me being too stupid to use Asymptote.