vectorgraphics / asymptote

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

commit 43ee1f02932d1569db65628202461d4e5977fd72 breaks draw(surface(...)...) #347

Closed balducci closed 1 year ago

balducci commented 1 year ago

hello

this commit:

43ee1f02932d1569db65628202461d4e5977fd72 is the first bad commit
commit 43ee1f02932d1569db65628202461d4e5977fd72
Author: John Bowman <bowman@ualberta.ca>
Date:   Wed Feb 9 16:53:23 2022 -0700

    Fix tensorshade fillrule.

 base/three_surface.asy | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

breaks the following script for me:

import three;
unitsize(50);
draw(surface(O--(1,0,0)--(1,0,1)--(0,0,1)--cycle),yellow);
draw(surface(O--(0,1,0)--(0,1,1)--(0,0,1)--cycle),yellow);
path3[] the_path=unitbox;
draw(the_path);

run as either:

asy  -render=0 -f eps  -noprc tester.asy

or:

asy  -render=0 -f pdf  -noprc tester.asy

The color of the first draw(surface(... looks wrong; the second draw(surface(... command produces a black surface; eg, for -f eps and using gv:

image

Reverting the above commit fixes things:

image

Attaching a shell script which you can use to reproduce the problem testit.txt

Running on GNU/linux:

##> uname -srvmo
Linux 5.19.12 #1 SMP Thu Sep 29 08:41:58 CEST 2022 x86_64 GNU/Linux

Configuring asy with:

--enable-lsp=yes

Building with:

##> gcc --version
gcc (GCC) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Rendering the output on screen with:

-f eps       gv
-f pdf       mupdf

thanks a lot for your valuable work ciao -gabriele

johncbowman commented 1 year ago

First of all, remember that -render=0 is an experimental attempt at flattening 3D images to 2D PostScript and is not recommended for normal use. See https://asymptote.sourceforge.io/doc/three.html

If you remove -render=0 you will see that the first image perfectly captures 3D lighting effects (in this simple planar case. To achieve the second image with or without -render=0, either use emissive lighting or disable lighting completely:

draw(surface(O--(1,0,0)--(1,0,1)--(0,0,1)--cycle),emissive(yellow));
draw(surface(O--(0,1,0)--(0,1,1)--(0,0,1)--cycle),yellow,nolight);

Finally, since PRC is deprecated, the default is now -noprc.