1

I am trying to create a graphic similar to the following one from another question on here: transparent planes

But already when i try to render a colored transparent surface of a simple plane, something is not looking right. With the following code

import bsp;

size(15cm,0);

settings.outformat = "pdf"; settings.render = 5; currentprojection=orthographic(5,4,3);

path3 pl = plane((0,-6,0),(-6,0,0),(0,3,0));

draw(pl); draw(surface(pl), red+opacity(0.5), nolight);

I am getting the output

the surface of the plane is not colored correctly

although the surface of the plane should be rendered fully in red with opacity 0.5. When I remove the opacity(0.5) option, as in

draw(surface(pl), red, nolight);

i get the desired output:

when the opacity option is removed, the surface is rendered correctly

But even when I straight up copy the code from the answer to the other stackexchange question, the described issue remains:

even when running the code from another answer, I still run into the same issue

I already tried searching for an explanation for this behavior in the documentation and in other posts on this stackexchange but so far wasn't successful in finding any answers. What am I doing wrong?

EDIT: I am rendering the asymptote code in a .asy file with the asymptote CLI, not in an asy environment in a latex document. I would also want to keep it that way, i.e. render my asymptote graphics separately with the CLI and later insert them into my latex document.

EDIT 2: When I compile the asymptote code in an asy environment in a latex file with pdflatex, the resulting plane.asy file is:

if(!settings.multipleView) settings.batchView=false;
settings.tex="pdflatex";
defaultfilename="asymptote-1";
if(settings.render < 0) settings.render=4;
settings.outformat="";
settings.inlineimage=true;
settings.embed=true;
settings.toolbar=false;
viewportmargin=(2,2);

import bsp;

size(15cm,0);

settings.outformat = "pdf"; settings.render = 5; currentprojection=orthographic(5,4,3);

path3 pl = plane((0,-6,0),(-6,0,0),(0,3,0));

draw(pl); draw(surface(pl), red+opacity(0.5), nolight);

and the output is locally compiling the .tex file still causes the same issues as just rendering with asy Thus, the plane is still not being rendered correctly. Previously I compiled a test .tex file with my asymptote code in it on Overleaf (also with pdflatex) and the plane was rendered correctly to the produced pdf. I should have clarified that in my first edit. In conclusion, my issue must be a local issue. I want to compile everything on a MacBook Pro (M1) and cannot remember changing any of the default settings of the asymptote CLI.

EDIT 3: Now I tried installing a different version of asymptote on my Mac. I was using version 2.85 (which comes preinstalled with texlive/mactex). Today, I installed version 2.89 separately with homebrew and compiled my code again - sadly, the issue still remains. Also, since I posted this question, I reinstalled MacTex (and thus texlive), yet I am still running into the same issue. And of course, I also tried the old "Restarting your PC" trick.

EDIT 4: I edited the title a little as I found this to be a more general issue on my machine when trying to compile different surfaces from the documentation. Namely, I found a similar (as I think related) issue, when I compile a surface from page 138 of the documentation: Compiling

import bsp;

settings.outformat = "pdf"; settings.render = 5;

size(15cm,0);

draw(surface((0,0)--E+2N--2E--E+N..0.2E..cycle), red);

produces correctly rendered surface from the documentation as expected. But adding +opacity(0.5) as in

draw(surface((0,0)--E+2N--2E--E+N..0.2E..cycle), red+opacity(0.5));

produces when adding opacity(0.5) to the surface from the documentation, the issue remains

derdu
  • 11
  • 4
  • Welcome! If I compile the code given in that answer with updated TeX Live 2023, I still get the output shown in that answer. I compiled the first lot of code with pdflatex, asy and pdflatex to reproduce my original result. So it is hard to know what you're doing wrong without knowing what you're doing. Are you sure this is not just a view artefact? – cfr Mar 04 '24 at 03:55
  • Also, if I compile your code, I get the expected output i.e. the whole plane is rendered in 50% red. So whatever is wrong, it isn't in the code you've posted here. – cfr Mar 04 '24 at 03:59
  • @cfr thank you very much for the fast reply! sorry, I should have clarified how I am rendering the output in my question, I will add that once I sent off this comment: I was not rendering the asymptote code in a asy environment in a latex-document but separately in a .asy file with the asymptote CLI. Indeed, when I copy your code into a latex document and render it that way, everything works as intended. still, I'd want to render my asymptote graphics separately with the CLI and later insert them into my latex document. – derdu Mar 04 '24 at 22:08
  • If I paste the code from your question into a clean prawf-2b.asy and run asy prawf-2b.asy, I get the expected result and still cannot reproduce the output you show. Even if I compile it using the asy environment in a document, I'm still rendering separately using asy. However, some extra stuff gets added to the .asy in that case. But, as I say, it does not seem to affect the rendered result in the case of your 50% transparent red plane, at least. – cfr Mar 05 '24 at 01:15
  • @cfr, thank you. sorry for the confusion, I had to clarify where and how I compiled what in my question. I now think this is a local issue to my machine. But in that case I have no idea on where to look or what to try to fix this issue. – derdu Mar 05 '24 at 12:55
  • Hmm. It could be a version or configuration difference, I guess. Or it could be Mac specific. Or it could be a difference in a dependency. It would be good if somebody on a Mac could test their results. – cfr Mar 05 '24 at 18:57

1 Answers1

0

As I noticed this issue may be more general and after more digging, I found another question having what seems to be the same issue. As a result, @Nat Kuhn opened an issue on github. So far, based on a reply on the github issue, as stated in @Nat Kuhn's answer, MacOS is missing certain software support for rendering transparent surfaces correctly. I will accept this answer once the issue is finally solved.

derdu
  • 11
  • 4
  • 1
    Any idea why it used to work? That is, I gather from that report it used to work on Macs, but the response indicates Macs don't have something necessary. Did they used to or has it actually never worked on Macs? – cfr Mar 06 '24 at 03:22