DirectionalLight[col,pt]
是一个三维图形指令,它指定颜色为 col、从点 pt 到边界框中心的定向光,用于对 3D 曲面着色.
DirectionalLight[col,{pt1,pt2}]
使用沿(从 pt1 点 pt2 的)向量的定向光.
DirectionalLight
DirectionalLight[col,pt]
是一个三维图形指令,它指定颜色为 col、从点 pt 到边界框中心的定向光,用于对 3D 曲面着色.
DirectionalLight[col,{pt1,pt2}]
使用沿(从 pt1 点 pt2 的)向量的定向光.
更多信息
- DirectionalLight 亦称为自由定向光.
- DirectionalLight 通常用于通过从给定方向均匀地投射光线来在物体上造成更亮的高光和更暗的阴影.
- DirectionalLight[col,{pt1,pt2}]在由 {pt1,pt2} 定义的方向向量上产生颜色为 col 的平行模拟光线.
- 光源 col 的颜色可以由 RGBColor、Hue 或任何其他颜色规范定义.
- DirectionalLight 的设置只影响与 3D 曲面上的漫反射和镜面反射相关的颜色.
- 颜色指定形式为 {dcol,Specularity[scol]} 的 col 光源在漫反射情况下实际上被视为颜色是 dcol 的光源,而在镜面反射情况下则被视为颜色是 scol 的光源.
- 漫反射遵循朗伯定律,光实际上从曲面的各个方向均匀散射.
- 镜面反射实际上认为光只在接近镜面反射的方向上散射,如 Specularity 的注释中所述.
- 可用以下方式指定光源位置和瞄准点 pti:
-
{x,y,z} 随图形移动的显式坐标 Scaled[{x,y,z}] 随图形移动的缩放坐标 ImageScaled[{x,y,z}] 相对于最终显示的图像固定的坐标 - 在 ImageScaled[{x,y,z}] 中,在最终显示图像的边界框的宽度和高度上,
和
从 0 到 1.
坐标垂直于显示的平面,在 3D 区域的后面为 0,前面为 1. - Scaled 和 ImageScaled 中指定的坐标通常不在 0 和 1 之间.
范例
打开所有单元 关闭所有单元基本范例 (3)
Graphics3D[{DirectionalLight[Orange, {1, 1, 1}], Sphere[], Cuboid[{1, 2, -1}, {2, 3, 1}], Cylinder[{{3, -1, 0}, {3, -1, 1}}]}, Lighting -> None]Plot3D[Sin[x + y ^ 2], {x, -3, 3}, {y, -2, 2}, PlotStyle -> DirectionalLight[RGBColor[1, 0.7, 0.1], {{5, 5, 4}, {5, 5, 0}}]]ListPlot3D[RandomReal[1, {9, 9}], InterpolationOrder -> 2, Mesh -> None, PlotStyle -> {Specularity[50], DirectionalLight[RGBColor[1, 0.7, 0.1], {{5, 5, 4}, {5, 5, 0}}]}]范围 (5)
照明规范 (4)
Graphics3D[{DirectionalLight[Green, {{0, 0, 1}, {0, 0, 0}}], White, Sphere[]}, Lighting -> None]Table[Graphics3D[{DirectionalLight[c, {{0, 0, 1}, {0, 0, 0}}], White, Sphere[]}, Lighting -> None], {c, {Red, Yellow, Blue}}]Table[Graphics3D[{DirectionalLight[Orange, {p, {0, 0, 0}}], Sphere[]}, Lighting -> None], {p, {{1, 0, 0}, {0, -1, 0}, {1, -1, 0}, {0, 0, 1}}}]Table[Graphics3D[{DirectionalLight[Orange, {p, {0, 0, 0}}], Specularity[White, 50], Sphere[]}, Lighting -> None], {p, {{1, 0, 0}, {0, -1, 0}, {1, -1, 0}, {0, 0, 1}}}]光源的位置 (1)
用 ImageScaled 在视图坐标系中指定光源位置:
Graphics3D[{DirectionalLight[Red, ImageScaled[{2, 2, 2}]], DirectionalLight[Green, ImageScaled[{-2, 2, 2}]], DirectionalLight[Blue, ImageScaled[{-2, -2, 2}]], Sphere[]}, Lighting -> None]Table[Graphics3D[{DirectionalLight[Red, ImageScaled[{2, 2, 2}]], DirectionalLight[Green, ImageScaled[{-2, 2, 2}]], DirectionalLight[Blue, ImageScaled[{-2, -2, 2}]], Sphere[]}, Lighting -> None, ViewPoint -> v], {v, {{0, -2, 2}, {2, 0, 2}, {2, -2, 0}}}]推广和延伸 (8)
Graphics3D[Sphere[], Lighting -> Automatic]Graphics3D[{Sphere[], AmbientLight[RGBColor[{0.4, 0.2, 0.2}]], DirectionalLight[RGBColor[{0., 0.18, 0.5}], ImageScaled[{2, 0, 2}]], DirectionalLight[RGBColor[{0.18, 0.5, 0.18}], ImageScaled[{2, 2, 3}]], DirectionalLight[RGBColor[{0.5, 0.18, 0.}], ImageScaled[{0, 2, 2}]], DirectionalLight[RGBColor[{0., 0., 0.18}], ImageScaled[{0, 0, 2}]]}]Graphics3D[{Sphere[]}, Lighting -> "Accent"]Graphics3D[{DirectionalLight[RGBColor[{1, 1, 1}], ImageScaled[{1, 1, 4}]], Sphere[]}, Lighting -> None]Graphics3D[{Sphere[]}, Lighting -> "Neutral"]Graphics3D[{AmbientLight[RGBColor[{.35, .35, .35}]], DirectionalLight[RGBColor[{.37, .37, .37}], ImageScaled[{2, 0, 2}]], DirectionalLight[RGBColor[{.37, .37, .37}], ImageScaled[{2, 2, 2}]], DirectionalLight[RGBColor[{.37, .37, .37}], ImageScaled[{0, 2, 2}]], Sphere[]}, Lighting -> None]Graphics3D[{Sphere[]}, Lighting -> "ThreePoint"]Graphics3D[{DirectionalLight[GrayLevel[.85], ImageScaled[{1, 1, 2}]], DirectionalLight[GrayLevel[.4], ImageScaled[{-1, -2, 2}]], DirectionalLight[GrayLevel[.1], ImageScaled[{.5, 2, -2}]], Sphere[]}, Lighting -> None]o1 = Style[{PointLight[Red, {0, 0, 2}], Sphere[]}];
o2 = Style[{SpotLight[Yellow, {{3, 0, 2}, {3, 0, 0}}, Pi / 8], Sphere[{3, 0, 0}]}];
o3 = Style[{DirectionalLight[Blue, {{0, 3, 2}, {0, 3, 0}}], Sphere[{0, 3, 0}]}];
o4 = Style[{PointLight[White, {3, 3, 2}], Sphere[{3, 3, 0}]}];Graphics3D[{o1, o2, o3, o4}, Lighting -> None]Graphics3D[{{PointLight[Red, {0, 0, 2}], Sphere[]}, {SpotLight[Yellow, {{3, 0, 2}, {3, 0, 0}}, Pi / 8], Sphere[{3, 0, 0}]}, {DirectionalLight[Blue, {{0, 3, 2}, {0, 3, 0}}], Sphere[{0, 3, 0}]}, {PointLight[White, {3, 3, 2}], Sphere[{3, 3, 0}]}}, Lighting -> None]Graphics3D[{DirectionalLight[LightRed, {0, 0, 4}], Specularity[White, 50], Sphere[], Sphere[{3, 0, 0}], Sphere[{0, 3, 0}], Sphere[{3, 3, 0}]}, Lighting -> None]Graphics3D[{DirectionalLight[{Red, Specularity[Yellow]}, {0, 0, 3}], Specularity[White, 20], Sphere[]}, Lighting -> None]应用 (3)
obj = Graphics3D[{Specularity[White, 50], Sphere[], Sphere[{4, 0, 0}], Sphere[{0, 4, 0}], Sphere[{4, 4, 0}]}, Lighting -> None];
plane = ParametricPlot3D[{u, v, -1}, {u, -2, 6}, {v, -2, 6}, PlotPoints -> 40, MaxRecursion -> 0, Mesh -> None, PlotRange -> 1, Axes -> False];light = Graphics3D[{DirectionalLight[Yellow, {2, 2, 10}], Glow[Yellow], EdgeForm[Gray], Opacity[.2], Cuboid[{-2, -2, -1}, {6, 6, 3}]}];Show[light, obj, plane, Boxed -> False]lights = {PointSize[Large], Yellow, Point[Tuples[{-1, 1}, 3]]};Graphics3D[{DirectionalLight[Hue[RandomReal[]], #]& /@ Tuples[{-1, 1}, 3], lights, Sphere[]}]col = {Red, Green, Blue};
objs = Graphics3D[{Specularity[White, 2], EdgeForm[], Cylinder[{{2, 2, 0}, {2, 2, 4}}], Cylinder[{{6, 2, 0}, {6, 2, 4}}], Cylinder[{{10, 2, 0}, {10, 2, 4}}]}];
walls = ParametricPlot3D[{{u, v - 2, 0}, {u, 4, 2v}}, {u, -2, 14}, {v, 0, 6}, PlotPoints -> 15, MaxRecursion -> 0, PlotStyle -> Specularity[White, 2], Mesh -> None, Axes -> False];
srcs[pos_] := Graphics3D[MapThread[{DirectionalLight[#1, {{0, -1, 0}, {0, 0, 0}}], Sphere[{#2, 0, 8}, .3]}&, {col, pos}]];
lights[pos_] := Join[{AmbientLight[GrayLevel[.1]]}, Sequence@@MapThread[{SpotLight[#1, {{#2, 0, 8}, {#2, 3, 0}}, {Pi / 2, 20}], {PointLight[#1, {#2, 0, 8}, {0, 8, 0}]}}&, {col, pos}]];Animate[With[{rx = -6Cos[t] + 6, gx = 6Sin[t] + 6, bx = 6Cos[t] + 6}, Show[objs, walls, srcs[{rx, gx, bx}], Lighting -> lights[{rx, gx, bx}], Background -> Black, Boxed -> False, ImageSize -> 300]], {t, 0, 2Pi}, SaveDefinitions -> True, AnimationRunning -> False]属性和关系 (1)
文本
Wolfram Research (2021),DirectionalLight,Wolfram 语言函数,https://reference.wolfram.com/language/ref/DirectionalLight.html.
CMS
Wolfram 语言. 2021. "DirectionalLight." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/DirectionalLight.html.
APA
Wolfram 语言. (2021). DirectionalLight. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/DirectionalLight.html 年
BibTeX
@misc{reference.wolfram_2026_directionallight, author="Wolfram Research", title="{DirectionalLight}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/DirectionalLight.html}", note=[Accessed: 11-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_directionallight, organization={Wolfram Research}, title={DirectionalLight}, year={2021}, url={https://reference.wolfram.com/language/ref/DirectionalLight.html}, note=[Accessed: 11-September-2026]}