Is there a way to define more than one "spot" of light for one shading? Two (default white highlight and a big pink reflected light spot) were good and three were just great.

photorealistic radial shading in TikZ

I'm using

\shadedraw[line width=0.15mm, white, ball color=black] (0, 0, 0) circle (1.75mm); 

This modification:


looks pretty good:


  • 1
    Is there a question here?
    – cfr
    Sep 19, 2015 at 15:58

1 Answer 1


It can be done with fadings:

{color(0bp)=(pgftransparent!0); color(50bp)=(pgftransparent!0);
 color(75bp)=(pgftransparent!25); color(100bp)=(pgftransparent!25)}
\pgfdeclareradialshading{thick ring}{\pgfpointorigin}{
  color(0pt)=(pgftransparent!100); color(15pt)=(pgftransparent!100); 
  color(25bp)=(pgftransparent!100); color(50bp)=(pgftransparent!100)}
\pgfdeclarefading{thick ring}{\pgfuseshading{thick ring}}    
\shade [shading=ball, ball color=black] circle [radius=1];
\fill [white, path fading=thick ring] circle [radius=1];
\fill [black, path fading=up, fading angle=215] circle [radius=1];

\tikzset{shiny ball/.style={
  fill=none, draw=none, shading=ball, shading angle=-15,
  postaction={fill=white, path fading=ball, opacity=0.75, fading angle=45},
  postaction={fill=white, path fading=ring}
\tikz\foreach \c [count=\i]
  in {red, yellow, green!50!black, brown, blue, pink!50!purple, black, white}
    \path [shiny ball, ball color=\c] (360/8*\i:3) circle [radius=1];

enter image description here

And it is rather hard to resist reusing the code above and adding this:

  color(0pt)=(pgftransparent!0); color(25bp)=(pgftransparent!100)}
\tikzset{pics/ball/.style args={#1 : #2}{code={
\fill [path fading=shadow, fit fading=true]
  (300:#2*1/3) ellipse [x radius=#2*2/3, y radius=#2*1/3];
\path [shiny ball, ball color=#1] circle [radius=#2/2];
\clip [preaction={top color=green!50!olive, bottom color=green!50!black}]
  (-12,-8) -- (-6,8) -- (6,8) -- (12,-8) -- cycle;
\draw [green!50!olive!75!white, ultra thick] 
  (-8,6-1/9) -- (8,6-1/9) (-2,6-1/9) arc (180:0:2 and 1.125);
\pic at (-2,6) {ball=yellow : 5/9};
\pic at (0,6)  {ball=green!50!black : 5/9};
\pic at (2,6)  {ball=brown!75!red : 5/9};
\pic at (0,3)  {ball=blue : 7/9};
\pic at (0,0)  {ball=pink : 1};
\foreach \i [evaluate={\k=1+\i/25;}] in {1,...,5}
   \foreach \j in {1,...,\i}
     \pic at ({\k*(-\i/2-1/2+\j)},-\k*\i/2) {ball=red : \k};
\pic at (0,-6) {ball=black : 10/9};
\pic at (3,3/2) {ball=white : 8/9};

enter image description here

But as fadings are not very portable (i.e., pdf output only and even then fadings may only be visible if the pdf viewer supports them), here is an alternative which sort of does it without fadings. As long as you don't look too closely. Works better with some colors than others.

\foreach \c in {black, red, yellow, green, blue}{
\begin{tikzpicture}[ball color=\c]
\foreach \i in {0,0.25,...,10}
   \fill [black, opacity=1/50] (270:1) 
     ellipse [x radius=\i/10, y radius=\i/20];
\shade [shading=ball, shading angle=-15]
  circle [radius=1];
\foreach \i in {0,0.25,...,10}
   \fill [white, opacity=1/75] (180:0.5) circle [radius=\i/30];

\foreach \i [evaluate={\j=\i*3;}] in {0,0.25,...,10}
  \draw [white, opacity=1/200, line width=\i, line cap=round]
   (0+\j:0.875) arc (0+\j:-90-\j:0.875);

enter image description here

You must log in to answer this question.

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