I have a question regarding the Asymptote module "Smoothcontour3" which is used to create implicitly defined surfaces. In general, the module works well for me, but I have a small issue when drawing transparent surfaces. When the implicitly defined surface is transparent, the gridlines on the surface become very visible (much more visible than I would like them to be).
I have included my Asymptote code below. This is essentially the example of an implicitly defined surface from the Asymptote tutorial by Charles Staats (section 4.6.1 on page 97 in the tutorial). When I disable transparency by setting opac = 1
, everything looks beautiful. If I enable transparency by setting opac = 0.75
, the image still looks pretty good, but now the gridlines on the surface are very apparent. I can remove the gridlines by setting overlapedges=false
, but then I am missing out on the attractive benefits of the overlapedges
functionality.
Can anybody provide some advice on this issue? Is it possible to get rid of the gridlines while still having both transparency and overlapedges
enabled? Any help would be greatly appreciated.
settings.outformat="png";
settings.render=8;
import smoothcontour3;
size(5cm, 0);
currentprojection=perspective((18,20,10));
real tuberadius = 0.69;
real opac = 0.75;
// Convert to cylindrical coordinates to draw
// a circle revolved about the z axis.
real toruscontour(real x, real y, real z) {
real r = sqrt(x^2 + y^2);
return (r-2)^2 + z^2 - tuberadius^2;
}
// Take the union of the two tangent tori (by taking
// the product of the functions defining them). Then
// add (or subtract) a bit of noise to smooth things
// out.
real f(real x, real y, real z) {
real f1 = toruscontour(x - 2 - tuberadius, y, z);
real f2 = toruscontour(x + 2 + tuberadius, y, z);
return f1 * f2 - 0.1;
}
// The smoothed function extends a bit farther than the union of
// the two tori, so include a bit of extra space in the box.
triple max = (2*(2+tuberadius), 2+tuberadius, tuberadius) + (0.1, 0.1, 0.1);
// Draw the implicit surface.
surface s = implicitsurface(f, -max, max, overlapedges=true, nx=20, nz=5);
draw(s, surfacepen=palegreen + opacity(opac));
To illustrate my question, I have included the graphics generated from the code above. The first image is without transparency, and the second is with transparency enabled (opac = 0.75
). As seen in the pictures, the gridlines are quite apparent for a transparent surface (and absent on the opaque surface).