Wolfram Technology Guide: Real-Time 3D Graphics  previous | next 
Full Real-Time Lighting Models
Mathematica includes support for multiple lighting models that can be used in real time.
In[1]:=

Click for copyable input
p1[\[Theta]_] := RotationTransform[\[Theta], {0, 0, 1}][{0, 2, 0}];
In[2]:=

Click for copyable input
p2[\[Theta]_] := 

  RotationTransform[\[Theta] + Pi/2, {1, 0, 1}][{0, 2, 0}];
In[3]:=

Click for copyable input
p3[\[Theta]_] := 

  RotationTransform[\[Theta] + Pi, {1, 0, 0}][{0, 2, 0}];
In[4]:=

Click for copyable input
p4[\[Theta]_] := 

  RotationTransform[\[Theta] + 3 Pi/2, {1, 0, -1}][{0, 2, 0}];
In[5]:=

Click for copyable input
Animate[Graphics3D[{Specularity[White, 30], Sphere[], 

   Sphere[p1[\[Theta]], .4], Sphere[p2[\[Theta]], .4], 

   Sphere[p3[\[Theta]], .4], Sphere[p4[\[Theta]], .4]}, 

  Lighting -> {{"Ambient", GrayLevel[.1]}, {"Point", Red, 

     p1[\[Theta]]}, {"Point", Green, p2[\[Theta]]}, {"Point", Blue, 

     p3[\[Theta]]}, {"Point", Yellow, p4[\[Theta]]}}, 

  PlotRange -> 2.5, Boxed -> False], {\[Theta], 0, 2 Pi}, 

 SaveDefinitions -> True]
Out[5]=