18

I'm trying to display a white 3D ball with Asymptote (3D PDF), but it always turns up gray:

enter image description here

import graph3;
import solids;

defaultrender.merge=true;
size(10cm,0);

currentprojection=orthographic(-Z);

//currentlight=Headlamp;
//currentlight=light(-10,1,1);
//currentlight=White;
currentlight=Viewport;

draw(unitsphere,rgb(1,1,1));

I understand it's a lighting issue, and I've tried playing with its settings (the lines commented out in my source are some of my attempts), but I never manage to have white be white. If I understand correctly, I need a whiter diffuse component in my light, but I cannot see how to achieve that. And the documentation is not very clear…


This will be part of a molecular model, and the rendering I'm going for it something like this:

enter image description here

3
  • 2
    Check out the material in docs. You can try, for example: material surfpen; surfpen.p=new pen[]{white,white,yellow,white}; draw(unitsphere,surfpen);
    – g.kov
    Commented Mar 23, 2014 at 1:58
  • 1
    @g.kov: (off topic) Any chance you could throw in an answer to this question? Right now there isn't a viable candidate for the bounty, and I know you're at least as good at these things as I am. Commented Mar 27, 2014 at 14:11
  • @Charles Staats (off topic): I sincerely appreciate the offer and I'd like to, as I agree that a translation to Asymptote from TikZ/PSTricks is not difficult in most cases, but I can't promise, sorry.
    – g.kov
    Commented Mar 27, 2014 at 17:35

3 Answers 3

14
+50

As g.kov suggests, you may be better off playing with the material rather than the lighting. In particular, ambient light tends to be rather subtle; you're better off using emissivepen, which essentially adds exactly that color to the entire sphere regardless of the lighting.

import three;

defaultrender.merge=true;
size(10cm,0);

currentprojection=orthographic(-Z);

draw(unitsphere, surfacepen=material(diffusepen=gray(0.5), emissivepen=gray(0.6), specularpen=black) );

The result:

5

This is probably going to be too white for you, but you can decrease emissivepen and diffusepen as needed. I enclose the code and a change in parameter emissivepen from 1.0 to 0.5 with step of 0.1.

import settings;
outformat="eps";
// interactiveView=false;
// batchView=false;

import three;
size(200);
//currentprojection=orthographic(5,4,3);
//defaultrender=render(compression=Zero,merge=true);
currentlight.background=blue;
material White=material(diffusepen=gray(1.0),emissivepen=gray(1.0));
draw(unitsphere,White);

mwe

0

nolight makes white is white! nolight makes yellow is yellow!

enter image description here

enter image description here

enter image description here

// http://asymptote.ualberta.ca/
import three;
size(8cm,0);
draw(Label("$x$",EndPoint),O--1.5X,Arrow3);
draw(Label("$y$",EndPoint),O--1.5Y,Arrow3);
draw(Label("$z$",EndPoint),O--1.3Z,Arrow3);

//pen p=yellow+opacity(.9)+5pt;
pen p=white;

//draw(unitsphere,p);
draw(unitsphere,p,nolight);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .