| 1 |
\newpage |
| 2 |
\section{Lighting by a point light source} |
| 3 |
|
| 4 |
Two parameters, the first one positions the \Index{light source}, the second one sets the \Index{light intensity}: |
| 5 |
\begin{compactitem} |
| 6 |
\item \Lkeyword{lightsrc}=20 30 50 in Cartesian coordinates, or |
| 7 |
\texttt{\Lkeyword{lightsrc}=\Lkeyval{viewpoint}} to put the light source at the view point. |
| 8 |
\item \texttt{\Lkeyword{lightintensity}=2} (default value). |
| 9 |
\end{compactitem} |
| 10 |
\begin{center} |
| 11 |
\newcommand\LIGHTSRC[3]{% |
| 12 |
\pstVerb{ |
| 13 |
/xLIGHTSRC #1 def |
| 14 |
/yLIGHTSRC #2 def |
| 15 |
/zLIGHTSRC #3 def |
| 16 |
/RADIUS 4 def |
| 17 |
/THETA yLIGHTSRC xLIGHTSRC atan def |
| 18 |
/DISTANCE xLIGHTSRC dup mul yLIGHTSRC dup mul add zLIGHTSRC dup mul add sqrt def |
| 19 |
/PHI zLIGHTSRC DISTANCE div arcsin def |
| 20 |
/ALPHA RADIUS DISTANCE div arccos def |
| 21 |
/OH ALPHA cos RADIUS mul def |
| 22 |
/radius_cone ALPHA sin RADIUS mul def |
| 23 |
/Hauteur_cone DISTANCE OH sub def |
| 24 |
/X_C xLIGHTSRC OH mul DISTANCE div def |
| 25 |
/Y_C yLIGHTSRC OH mul DISTANCE div def |
| 26 |
/Z_C zLIGHTSRC OH mul DISTANCE div def |
| 27 |
/rotX_axe_cone PHI 90 sub def |
| 28 |
/rotZ_axe_cone THETA 90 sub def |
| 29 |
} |
| 30 |
\psset{Decran=50,viewpoint=50 10 15} |
| 31 |
\psSolid[object=sphere,r=RADIUS,fillcolor=blue,ngrid=18 36, |
| 32 |
lightsrc=xLIGHTSRC yLIGHTSRC zLIGHTSRC](0,0,0) |
| 33 |
\psPoint(xLIGHTSRC,yLIGHTSRC,zLIGHTSRC){LS} |
| 34 |
\psset{lightsrc=} |
| 35 |
\psSolid[object=cone,r=radius_cone,h=Hauteur_cone,fillcolor=yellow!50, |
| 36 |
ngrid=1 36,RotX=rotX_axe_cone,RotZ=rotZ_axe_cone,opacity=0.5, |
| 37 |
linecolor=yellow](X_C,Y_C,Z_C) |
| 38 |
\psdot(LS)} |
| 39 |
|
| 40 |
\begin{pspicture}(-2,-2.5)(5,5) |
| 41 |
\psset{unit=0.5} |
| 42 |
\LIGHTSRC{0}{8}{8} |
| 43 |
\uput[45](LS){Light Source} |
| 44 |
\axesIIID(4,4,4)(6,6,6) |
| 45 |
\end{pspicture} |
| 46 |
\begin{pspicture}(-4,-2.5)(5,2.5) |
| 47 |
\psset{unit=0.5} |
| 48 |
\LIGHTSRC{2}{-5}{0} |
| 49 |
\uput[l](LS){Light Source} |
| 50 |
\axesIIID(4,4,4)(6,6,6) |
| 51 |
\end{pspicture} |
| 52 |
|
| 53 |
\begin{pspicture}(-1,-2.5)(9,2.5) |
| 54 |
\psset{unit=0.5} |
| 55 |
\LIGHTSRC{0}{20}{0} |
| 56 |
\uput[r](LS){Light Source} |
| 57 |
\axesIIID(4,4,4)(6,6,6) |
| 58 |
\end{pspicture} |
| 59 |
\end{center} |
| 60 |
|
| 61 |
As you can see, the intersecting \Index{plane} (section of the sphere with the cone of |
| 62 |
\Index{light}) divides the object into two half spaces: the first half space |
| 63 |
(the one on the side of the \Index{light source}) is illuminated and the other half space is the shadow region referring to this light source position. |
| 64 |
|
| 65 |
Now it is clear, that if the view point is setup with the same coordiates as the light source, the object is illuminated uniquely. |
| 66 |
|
| 67 |
\encadre{In order to get some shadow regions to appear in the graphic---which |
| 68 |
emphasises the 3D character---we would suggest choosing the light source and the view point differently.} |
| 69 |
|
| 70 |
\newpage |
| 71 |
Here follow a few examples: |
| 72 |
|
| 73 |
\begin{pspicture}(-3,-2)(3,3) |
| 74 |
\psset{unit=0.3} |
| 75 |
\psset{Decran=1e3, |
| 76 |
viewpoint=500 0 1000, |
| 77 |
lightsrc=10 20 30,mode=3} |
| 78 |
\psSolid[object=sphere,r=5,fillcolor=blue](0,0,8) |
| 79 |
\rput(0,-3.5){\texttt{lightsrc=10 20 30}} |
| 80 |
\end{pspicture} |
| 81 |
\begin{pspicture}(-3,-2)(3,3) |
| 82 |
\psset{unit=0.3} |
| 83 |
\psset{Decran=1e3, |
| 84 |
viewpoint=500 0 1000, |
| 85 |
lightsrc=-10 -20 30,mode=3} |
| 86 |
\psSolid[object=sphere,r=5,fillcolor=blue](0,0,8) |
| 87 |
\rput(0,-3.5){\texttt{lightsrc=-10 -20 30}} |
| 88 |
\end{pspicture} |
| 89 |
\begin{pspicture}(-3,-2)(3,3) |
| 90 |
\psset{unit=0.3} |
| 91 |
\psset{Decran=1e3, |
| 92 |
viewpoint=500 0 1000, |
| 93 |
lightsrc=30 -20 30,mode=3} |
| 94 |
\psSolid[object=sphere,r=5,fillcolor=blue](0,0,8) |
| 95 |
\rput(0,-3.5){\texttt{lightsrc=30 -20 30}} |
| 96 |
\end{pspicture} |
| 97 |
|
| 98 |
When the option \verb+[lightsrc=value1 value2 value3]+ |
| 99 |
is not specified, the object is uniformly illuminated. |
| 100 |
|
| 101 |
\begin{center} |
| 102 |
\begin{pspicture}(-6,-2)(6,2) |
| 103 |
%\psframe(-6,-4)(6,4) |
| 104 |
\psset{viewpoint=50 50 30 rtp2xyz,Decran=40,unit=0.6} |
| 105 |
\psSolid[object=datfile,filename=data/tore1836,deactivatecolor] |
| 106 |
%\psSolid[r1=3.5,r0=1,object=tore,ngrid=18 36,fillcolor={[rgb]{.372 .62 .628}}]% |
| 107 |
\axesIIID(0,4.5,0)(6,6,4) |
| 108 |
\end{pspicture} |
| 109 |
\end{center} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
Here are some examples, where we always keep the same object, the same view point, the same light |
| 114 |
source coordinates and just vary the \Lkeyword{lightintensity} value: |
| 115 |
|
| 116 |
\begin{pspicture}(-3,-2)(3,3) |
| 117 |
\psset{unit=0.3} |
| 118 |
\psset{Decran=1e3, |
| 119 |
viewpoint=500 0 1000, |
| 120 |
lightsrc=-10 -20 30,mode=4,lightintensity=1} |
| 121 |
\psSolid[object=sphere,r=5,fillcolor=green](0,0,8) |
| 122 |
\rput(0,-3.5){\texttt{lightintensity=2}} |
| 123 |
\end{pspicture} |
| 124 |
\begin{pspicture}(-3,-2)(3,3) |
| 125 |
\psset{unit=0.3} |
| 126 |
\psset{Decran=1e3, |
| 127 |
viewpoint=500 0 1000, |
| 128 |
lightsrc=-10 -20 30,mode=4,lightintensity=3} |
| 129 |
\psSolid[object=sphere,r=5,fillcolor=green](0,0,8) |
| 130 |
\rput(0,-3.5){\texttt{lightintensity=3}} |
| 131 |
\end{pspicture} |
| 132 |
\begin{pspicture}(-3,-2)(3,3) |
| 133 |
\psset{unit=0.3} |
| 134 |
\psset{Decran=1e3, |
| 135 |
viewpoint=500 0 1000, |
| 136 |
lightsrc=-10 -20 30,mode=4,lightintensity=8} |
| 137 |
\psSolid[object=sphere,r=5,fillcolor=green](0,0,8) |
| 138 |
\rput(0,-3.5){\texttt{lightintensity=8}} |
| 139 |
\end{pspicture} |
| 140 |
|
| 141 |
Here we can see, that by increasing the \Lkeyword{lightintensity} value, the shading nuances of the solid are decreasing. |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
\endinput |