2

I encounter this bug with Asymptote (latest version on Windows):

enter image description here

These horizontal lines are not from my code, they underisably appear.

I have found only this link reporting the same problem, but no answer is given (I have tried the option -glOptions=-indirect, as suggested in a comment, but it does not prevent the bug).

Any idea? My code is below.

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

// -----------------------------------------------------------------------------
import three;
import solids;

// -----------------------------------------------------------------------------
real[] circumsphere(triple p1, triple p2, triple p3, triple p4){
  real a = orient(p1,p2,p3,p4);
  real q1 = p1.x*p1.x + p1.y*p1.y + p1.z*p1.z;
  real q2 = p2.x*p2.x + p2.y*p2.y + p2.z*p2.z;
  real q3 = p3.x*p3.x + p3.y*p3.y + p3.z*p3.z;
  real q4 = p4.x*p4.x + p4.y*p4.y + p4.z*p4.z;
  real Dx = orient((q1,p1.y,p1.z),(q2,p2.y,p2.z),(q3,p3.y,p3.z),(q4,p4.y,p4.z));
  real Dy = orient((q1,p1.x,p1.z),(q2,p2.x,p2.z),(q3,p3.x,p3.z),(q4,p4.x,p4.z));
  real Dz = orient((q1,p1.x,p1.y),(q2,p2.x,p2.y),(q3,p3.x,p3.y),(q4,p4.x,p4.y));
  triple center = 0.5/a * (Dx,-Dy,Dz);
  real r = length(p1-center);
  real[] out = {center.x,center.y,center.z,r};
  return out;
}

// -----------------------------------------------------------------------------
triple inversion(triple pnt, real r, triple center){
  triple omega = (2*r, 0, 0);
  real k = 3*r*r;
  triple v = pnt - omega - center;
  return omega + center - k/(v.x*v.x+v.y*v.y+v.z*v.z)*v;
}

// -----------------------------------------------------------------------------
real[] oneSphere(triple center, real r, real beta){
  triple pnt = center + (r*cos(beta)*2/3, r*sin(beta)*2/3, 0);
  real thRadius = r/3;
  triple p1 = pnt + (thRadius,0,0);
  triple p2 = pnt + (0,thRadius,0);
  triple p3 = pnt + (-thRadius,0,0);
  triple p4 = pnt + (0,0,thRadius);
  triple q1 = inversion(p1, r, center);
  triple q2 = inversion(p2, r, center);
  triple q3 = inversion(p3, r, center);
  triple q4 = inversion(p4, r, center);
  real[] cs = circumsphere(q1,q2,q3,q4);
  cs[0] = cs[0] - 4*r;
  return cs;
}

// -----------------------------------------------------------------------------
void hexlet(){
  for(int i=0; i<6; ++i){
    real[] s = oneSphere((0,0,0), 1, i*pi/3);
    draw(surface(sphere((s[0],s[1],s[2]), s[3])), red);
  }
}

// -----------------------------------------------------------------------------
currentprojection=orthographic(0,0,6);
viewportmargin=(10,10);
size(10cm);
currentlight=((0,0,100));

hexlet(); 
  • 1
    hmm... it seems that the bug does not occur anymore with settings.render=2 – Stéphane Laurent Jun 19 '18 at 14:27
  • @marmot Thanks for your review. No there is no problem with these formulas. I implemented the same graphic in R, Haskell OpenGL, and POV-Ray, and never got an issue. – Stéphane Laurent Jun 19 '18 at 15:15
  • Just to let you know that I compiled your code by wrapping it into an asypicture using the asypictureB package, and the issue does not arise (I kept settings.render=4, of course). On the one hand, this confirms what you are saying, i.e. nothing seems to blow up, but it also makes it impossible for me to reproduce the issue. How did you embed the asymptote code in your TeX document? – user121799 Jun 19 '18 at 16:19
  • Thanks @marmot. I don't embed the code in a TeX document, I just compile it with asy myfile.asy. Are you using Windows? – Stéphane Laurent Jun 19 '18 at 17:12
  • 1
    It is not a code problem but an OpenGL/Asymptote driver problem. Usually the -glOptions=-indirect option could be a solution. But I know that sometimes it does not work (I produced the pictures for a StackExchange user). For an standalone asy file, what happens with asy -V yourfile.asy, then choose export. Also could you try asy -maxtile '(256,256)' yourfile.asy, asy -offscreen... – O.G. Jun 19 '18 at 20:23
3

This bug is usual and is related to some driver problems. An research "Asymptote black lines" returns a lot of links. In the documentation it is written that the option -glOptions=-indirect can help. However it appears that sometimes it does not work as here or Drawing 3D crystal lattice with Asymptote 2.38

Another possibility is to use -maxtile option (which is related to rendering tile size). In fact to render a large scene OpenGl with tiles cuts the scene into parts. By default the value is (1024,768). asy -maxtile "(256,256)" (a smaller value) can help.

I have to admit that I gave the -maxtile option by a pure chance !

Edit : in fact the -maxtile workaround is in the documentation, the three.asy module part, in the second choice for 3D Renderer !

O.G.

| improve this answer | |
  • @ O.G. (or someone) Could you please explain in more details: how the option -glOptions=-indirect can help? how to use -maxtile option? (I am using Windows 10) – Black Mild Nov 11 '18 at 18:52
  • 1
    @BlackMild I think that the 'maxtile' option is better to avoid the black lines problem. Under Linux, I simply use in a terminal the command asy -maxtile "(256,256)". Under Windows I do not know. Another possibilty is to add to your asy file the option line command settings.maxtile=(100,100); – O.G. Nov 12 '18 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.