# How may I remedy this erroneous lighting pattern?

What I did:

cylinderPlot3D[f_ ,xys_:1] :=   ParametricPlot3D[{z,f[t,z] Cos[t],f[t,z]
Sin[t]}, {t,-Pi, Pi},{z,-Pi,Pi}, Mesh->None,PlotPoints->50,PlotRange ->
All,Exclusions->None, AxesLabel->{x,y,z},Lighting ->
{{"Directional",RGBColor[1, 1, 1], {-4,0,4}}},PlotStyle ->
Specularity[0]]

f[t_,z_] := Cos[z/2]^0.5 * (0.9+HeavisideTheta[z-0.25 Pi]);cylinderPlot3D[f,0.6]


What I got, after reorientation:

showing dark at the pointer, as opposed to light as is correct, given that the ring is planar (reorient to see), the illumination is directional hence rays to all points on the ring should have the same angle of incidence hence intensity of illumination.

What I want: Correct illumination.

• 1) What exactly would you consider "correct" lighting in this context? 2) Have you taken a look at reference.wolfram.com/language/ref/Lighting.html ? Jul 29 '15 at 3:16
• 1) In accord with "Directional light sources ... are taken to yield parallel simulated light rays" reference.wolfram.com/language/ref/Lighting.html 2) Yes :-) Jul 29 '15 at 22:24

It appears to be a bug in computing the vertex normals at the step. Here's are the vertex normals:

c = cylinderPlot3D[f, 0.6];

normals = FirstCase[c, GraphicsComplex[pts_, __, VertexNormals -> vn_, ___] :>
Line[Transpose@{pts, pts + vn}], -1];

Show[c, Graphics3D[{Opacity[0.1], normals}]]


It looks like the HeavisideTheta function is not being handled properly. A simple but imperfect workaround is to use a soft step function in its place. For example

step[x_] := (1 + Tanh[10 x])/2

f[t_, z_] := Cos[z/2]^0.5*(0.9 + step[z - 0.25 Pi]);

cylinderPlot3D[f, 0.6]


To get a more accurate result you should probably remove the Exclusions -> None and supply the missing part as a separate surface. I suggest reporting the problem to Wolfram if you haven't already.

• Jul 29 '15 at 21:47
• @Simon Thanks. The workaround suffers a lesser but still significant discrepancy in incident intensity, and supplying the missing part would need to be computationally, give f can vary. I'll report the bug and fingers crossed. Jul 30 '15 at 0:02
• @Simon, as an aside, is your first graphic really from the code shown? Here (on Programming Cloud) I get different: i.imgur.com/r59pAIm.png Jul 30 '15 at 0:03
• @Simon. Ah, I get that only after reorientation. I guess this bug: mathematica.stackexchange.com/questions/89472/… Jul 30 '15 at 0:08