How to| 改变图形的光照
在 Wolfram 语言中,三维图形的外观可以通过改变图形光照的方向和颜色而得到改善. Lighting,作为 Graphics3D 及其相关函数的一个选项,可与其它函数及选项组合使用,得到用户自定义的高品质图形.
Graphics3D[Sphere[]]Graphics3D[Sphere[], Lighting -> Automatic]此处,Automatic 的显式设置被显示出来:
Graphics3D[Sphere[], Lighting -> {{"Ambient", RGBColor[0.4, .2, .2]}, {"Directional", RGBColor[0, .18, .5], ImageScaled[{2, 0, 2}]}, {"Directional", RGBColor[.18, .5, .18], ImageScaled[{2, 2, 3}]}, {"Directional", RGBColor[.5, .18, 0], ImageScaled[{0, 2, 2}]}, {"Directional", RGBColor[0, 0, .18], ImageScaled[{0, 0, 2}]}}]设置 Lighting 为中性,采用白光源:
Graphics3D[Sphere[], Lighting -> "Neutral"]Graphics3D[Sphere[], Lighting -> {{"Ambient", RGBColor[{0.35, 0.35, 0.35}]}, {"Directional", RGBColor[{0.37, 0.37, 0.37}], ImageScaled[{2, 0, 2}]}, {"Directional", RGBColor[{0.37, 0.37, 0.37}], ImageScaled[{2, 2, 2}]}, {"Directional", RGBColor[{0.37, 0.37, 0.37}], ImageScaled[{0, 2, 2}]}}]Graphics3D[Sphere[], Lighting -> None]Graphics3D[Sphere[], Lighting -> {{"Point", Blue, {0, -1, 1}}}]Graphics3D[Sphere[], Lighting -> {{"Point", Blue, {0, -1, 1}}, {"Point", Green, {1, -1, 0}}}]Graphics3D[Sphere[], Lighting -> {{"Ambient", Red}}]Graphics3D[Sphere[], Lighting -> {{"Ambient", Red}, {"Point", Blue, {1, -1, 0}}}]Graphics3D[Sphere[], Lighting -> {{"Directional", Green, {0, 0, 1}, {1, 0, 0}}}]根据光源位置、在对象上的目标位置以及半角,指定一个蓝色聚光:
Graphics3D[Sphere[], Lighting -> {{"Spot", Blue, {{1, -1, 0}, {0, -1, -1}}, Pi / 3}}]Plot3D[Sin[x y], {x, -2, 2}, {y, -4, 4}, Mesh -> None, Lighting -> {{"Spot", Red, {{-1, -1, 0}, {1, -1, -1}}, Pi / 3}, {"Point", Blue, {0, 0, 1}}}]GraphicsRow[Table[Graphics3D[{Specularity[Red, 50], Sphere[]}, Lighting -> {{"Spot", Orange, {{0, t, 1.5}, {0, 0, 0}}, Pi / 12}, {"Spot", Blue, {{0, t, 1.5}, {0, 0, 0}}, Pi / 12}}, Boxed -> False, ViewPoint -> {1, 0, -2}, ImageSize -> {150, 150}, Background -> Black], {t, 3.2, 12, 3}]]Manipulate[Graphics3D[{Specularity[White, 20], Sphere[]}, Lighting -> {{"Directional", {Red, Specularity[Yellow]}, {0, 0, 3}}, {"Point", {Blue, Specularity[Green]}, {2.4 t, -t / 2, 1.5}}}, ImageSize -> {200, 200}], {{t, 2.5}, -1, 3}]