# How can I use Lighting for specific surface of a 3D object?

Graphics3D[{Cylinder[{{(-0.1 + 10.128)/2, (13 + 1.3)/2,
0}, {(-0.1 + 10.128)/2, (13 + 1.3)/2, 0.001}}, 3.2]},
Lighting -> {{"Spot", Red}}]


I would like to use Lighting on the top surface ofCylinder above to produce the same lighting profile as this one

plane = DiscretizeRegion[
InfinitePlane[{0, 0, 0}, {{1, 0, 0}, {0, 1, 0}}], {{-1, 1}, {-1,
1}, {0, 1}}, MaxCellMeasure -> {"Length" -> 0.01},
BaseStyle -> {EdgeForm[], White}];
gty = Show[{plane},
Lighting -> {{"Spot", Red, {{0, 0, 1}, {0, 0, 0}}, {Pi/2, 4}}}]


You have a very thin cylinder. Ellipsoid seems to perform better if you are trying to emulate a disk.

cyl = Cylinder[{{(-0.1 + 10.128)/2, (13 + 1.3)/2,
0}, {(-0.1 + 10.128)/2, (13 + 1.3)/2, 0.001}}, 3.2];
centroid = RegionCentroid@cyl;
bnds = First@Differences@Transpose@RegionBounds@cyl;
ell = Ellipsoid[centroid, bnds];
Manipulate[
Graphics3D[{Specularity[White, 5], Style[ell, c]},
Lighting -> {{"Spot",
Red, {centroid + {0, 0, 3}, centroid}, θ}},
ImageSize -> Small], {{θ, π/2.5}, π/40, π/2}, {c,
White, ColorSlider}]


The following shows how the image changes at discrete surface colors with constant lighting.

Grid[{Graphics3D[{Style[ell, #]},
Lighting -> {{"Spot", Red, {centroid + {0, 0, 3}, centroid},
Pi/2.5}}] & /@ {White, Yellow, LightBlue, Blue}}]


The following shows how the image changes with underlying surface color under a White, Red, Green, and Blue spotlight.

mean = First@Mean@Transpose@RegionBounds@cyl;
tt = TranslationTransform /@ (DeleteCases[
Tuples[{0, #}, 3], {_, _, #}] &@bnds[[1]]*2.5);
ctt = Transpose[{{"White", "Red", "Blue", "Green"}, tt}];
Manipulate[
Graphics3D[{Specularity[White, 5],
Flatten@({Lighting -> {{"Spot",
ToExpression@#[[1]], #[[2]] /@ {centroid + {0, 0, 3},
centroid}, s}},
GeometricTransformation[
Style[{ell, Text[#[[1]], {mean, bnds[[1]]*2.3, 0}]}, c], #[[
2]]]} & /@ ctt)},
ViewPoint -> Top], {{s, Pi/5, "Spotlight Angle"}, Pi/20,
Pi/2.5}, {{c, Yellow, "Underlying Object Color"}, ColorSlider},
ControlPlacement -> Top]


• Thanks a lot @Tim Laska! Is it possible to assign a specific color for the desk instead of Black? Commented May 9, 2020 at 2:21
• @HD2006 The disk is black due to the lack of lighting. I added the ability to change the surface color through the Style command and specularity if desired. Commented May 9, 2020 at 2:54
• it is not working with me, it gives black disk without lighting once I change the color inside style to blue. May you please let the disk blue while lighting is red as it is and add a picture of the new shape? Commented May 9, 2020 at 3:09
• @HD2006 I added a ColorSlider to the Manipulate function to show that the image changes with changes in the surface color. Commented May 9, 2020 at 3:43
• @HD2006 I am pretty sure the black you are seeing is a function of the lighting. If evaluate Graphics3D[{Style[ell, Yellow]}], then you should see a Yellow disk. If you add lighting by evaluating Graphics3D[{Style[ell, Yellow]}, Lighting -> {{"Spot", Red, {centroid + {0, 0, 3}, centroid}, Pi/2.5}}], then the disk appears darker because less light is reflecting back. Commented May 9, 2020 at 4:24