Texture
更多信息
- 纹理贴图亦称为 UV 贴图或漫反射贴图.
- Texture 通常用于建模,将图像投影到 2D 多边形或 3D 曲面上.
- Texture 可用在 Graphics 和 Graphics3D 中.
- 在 Texture[obj,…] 中,对象 obj 可以是图像、图形或颜色数组.
- 以下形式可用于显式指定纹理的颜色值:
-
Texture[{c1,c2,…}] 颜色的 1D 纹理 Texture[{{c11,c12,…},…}] 颜色的 2D 纹理 Texture[{{{c111,c112,…},…},…}] 颜色的 3D 纹理 - 每个颜色可以是对应于 RGBColor[r,g,b] 的 {r,g,b} 列表,或对应于 RGBColor[r,g,b,a] 的 {r,g,b,a} 列表.
- Texture[obj] 等价于 Texture[Rasterize[obj]],将以通常在笔记本中显示的大小和分辨率光栅化 obj.
- Texture[obj,map] 提供一个纹理 obj,通过把坐标分配给投影映射 map 的顶点将纹理应用于多边形和曲面的面.
- 可用的 2D 图像的 3D 投影映射包括:
-
Automatic 自动选择投影 None 不进行投影 "Box" 盒体投影 "Cubic" 是立方体投影 "Cylindrical" 圆柱投影 "Front" 在 x–y 平面上的平面投影 "Planar" 平面投影 "Spherical" 球面投影 - VertexTextureCoordinates 可用于指定给定图形基元的投影映射.
- Opacity 可与 Texture 一起使用,指定纹理的不透明度.
- Texture 可用在 FaceForm 中,为正面和背面指定不同的纹理.
- 与 Lighting 互相作用时,Texture 中的颜色被视为漫反射颜色.
范例
打开所有单元 关闭所有单元基本范例 (4)
Graphics[{Texture[[image]], Polygon[{{0, 0}, {1, 0}, {0.5, 1}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {0.5, 1}}]}]ParametricPlot[{(v + u) Cos[u], (v + u) Sin[u]}, {u, 0, 2 Pi}, {v, 0, 5}, PlotStyle -> {Opacity[1], Texture[[image]]}]Graphics3D[{Texture[[image], "Cubic"], Cube[]}]Graphics3D[{Texture[[image]], EdgeForm[], Polygon[«3»]}]范围 (20)
基本用法 (3)
Graphics[{Texture[[image], "Planar"], #}]& /@ {Triangle[], RegularPolygon[5], Disk[]}Graphics3D[{Texture[[image], "Planar"], #}, Lighting -> "Neutral"]& /@ {Tetrahedron[], Icosahedron[], Sphere[]}RegionPlot[Sin[x] Sin[y] > 1 / 10, {x, -3, 6}, {y, -3, 6}, PlotStyle -> Texture[[image]]]Plot3D[Sin[x + y ^ 2], {x, -3, 3}, {y, -2, 2}, PlotStyle -> {Texture[[image]]}, Mesh -> False, Lighting -> "Neutral"]对 GraphicsComplex 应用纹理:
coords = CirclePoints[{0, 0}, 2, 20];
vtcoords = CirclePoints[{0.5, 0.5}, 0.5, 20];
Graphics[{Texture[[image]], GraphicsComplex[coords, {Polygon[Range[20], VertexTextureCoordinates -> vtcoords]}]}]纹理规范 (8)
data = Table[{c, 0, 0}, {c, 0, 1, 1 / 100}];Graphics[{Texture[data], Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexTextureCoordinates -> {{0}, {0}, {1}, {1}}]}]使用梯度 ColorData 的一维纹理:
data = Table[ColorData["Rainbow", t] /. RGBColor -> List, {t, 0, 1, 1 / 100}];Graphics[{Texture[data], Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexTextureCoordinates -> {{0}, {0}, {1}, {1}}]}]Graphics3D[{Texture[data], Polygon[{{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1},
{0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}},
{{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}},
... }, VertexTextureCoordinates ->
{{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}}]}, Lighting -> "Neutral"]Plot3D 曲面的一维纹理:
Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, PlotStyle -> Texture[data], Lighting -> "Neutral"]data = Table[{r, g, 0}, {r, 0, 1, 1 / 100}, {g, 0, 1, 1 / 100}];Graphics[{Texture[data], Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}]Graphics3D[{Texture[data], Polygon[{{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1},
{0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}},
{{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}},
... }, VertexTextureCoordinates ->
{{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}}]}, Lighting -> "Neutral"]Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, PlotStyle -> Texture[data], Lighting -> "Neutral"]Graphics[{Texture[[image], "Planar"], Polygon[{{0, 0}, {1, 0}, {1 / 2, 1}}]}]Graphics3D[{Texture[[image], "Box"], Cube[]}, Lighting -> "Neutral"]Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, PlotStyle -> Texture[[image]], Mesh -> None, Lighting -> "Neutral"]Graphics[{Texture[[image], "Planar"], Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}, Background -> Black]text = Style[" Text ", 300];Graphics[{Texture[text, "Planar"], EdgeForm[Gray], Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}]Graphics3D[{Texture[text, "Box"], Cube[]}, Lighting -> "Neutral"]Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, PlotStyle -> Texture[text], Mesh -> None, Lighting -> "Neutral"]{t2, t3} = {Graphics[{Blue, Disk[], Red, Rectangle[]}], Graphics3D[{Sphere[], Cuboid[]}]}Table[Graphics[{Texture[t], EdgeForm[Gray], Polygon[{{0, 0}, {1, 0}, {1 / 2, 1}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1 / 2, 1}}]}], {t, {t2, t3}}]Table[Graphics3D[{Texture[t], Polygon[{{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1},
{0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}},
{{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}},
... }, VertexTextureCoordinates ->
{{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}}]}, Lighting -> "Neutral"], {t, {t2, t3}}]t = ContourPlot[Cos[2x] + y, {x, 0, 2Pi}, {y, 0, 2Pi}, ColorFunction -> "Rainbow", Frame -> False, PlotRangePadding -> None]Graphics[{Texture[t], EdgeForm[Gray], Polygon[{{0, 0}, {1, 0}, {1 / 2, 1}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1 / 2, 1}}]}]Graphics3D[{Texture[t], Polygon[{{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1},
{0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}},
{{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}},
... }, VertexTextureCoordinates ->
{{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}}]}, Lighting -> "Neutral"]Plot3D[Cos[x] + y, {x, 0, 4Pi}, {y, 0, 4Pi}, PlotStyle -> Texture[t], Mesh -> None, Lighting -> "Neutral"]data = Table[{r, g, b}, {r, 0, 1, 1 / 20}, {g, 0, 1, 1 / 20}, {b, 0, 1, 1 / 20}];Graphics3D[{Opacity[1 / 3], Texture[data], EdgeForm[], Polygon[Table[{{0, 0, z}, {1, 0, z}, {1, 1, z}, {0, 1, z}}, {z, 0, 1, 1 / 20}], VertexTextureCoordinates -> Table[{{0, 0, s}, {1, 0, s}, {1, 1, s}, {0, 1, s}}, {s, 0, 1, 1 / 20}]]}, Lighting -> "Neutral"]Graphics3D[{Texture[data], EdgeForm[], Table[With[{pts = RotateRight[#, k]& /@ {{1 / 2, 0, 0}, {1 / 2, 1, 0}, {1 / 2, 1, 1}, {1 / 2, 0, 1}}}, Polygon[pts, VertexTextureCoordinates -> pts]], {k, 3}]}, Lighting -> "Neutral"]纹理坐标 (5)
对应于 Polygon 每个顶点的纹理坐标可由 VertexTextureCoordinates 指定:
data = Table[{c, 0, 1 - c}, {c, 0, 1, 1 / 100}];Graphics[{Texture[data], Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexTextureCoordinates -> {{0}, {0}, {1}, {1}}]}]Graphics[{Texture[data], Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexTextureCoordinates -> {{1 / 3}, {1 / 3}, {2 / 3}, {2 / 3}}]}]Graphics[{Texture[data], Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexTextureCoordinates -> {{-1}, {-1}, {2}, {2}}]}]image = [image];Graphics[{Texture[image], EdgeForm[StandardBrown], Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}]通过使用范围 {0,0} 到{1,1} 之内的坐标指定二维纹理部分:
Graphics[{Texture[image], EdgeForm[StandardBrown], Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexTextureCoordinates -> {{1 / 3, 1 / 3}, {2 / 3, 1 / 3}, {2 / 3, 2 / 3}, {1 / 3, 2 / 3}}]}]通过使用 {0,0} 和 {1,1} 之外的坐标值重复二维纹理:
Graphics[{Texture[image], EdgeForm[StandardBrown], Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexTextureCoordinates -> {{0, 0}, {4, 0}, {4, 4}, {0, 4}}]}]假设三维纹理坐标范围为 {0,0,0} 到 {1,1,1}:
data = Table[{r, g, b}, {r, 0, 1, 1 / 20}, {g, 0, 1, 1 / 20}, {b, 0, 1, 1 / 20}];Graphics3D[{Texture[data], EdgeForm[], Polygon[{{0, 0, 0}, {1, 0, 0}, {1, 1, 1}, {0, 1, 1}}, VertexTextureCoordinates -> {{0, 0, 0}, {1, 0, 0}, {1, 1, 1}, {0, 1, 1}}] }, Lighting -> "Neutral"]FilledCurve 分量映射到纹理坐标的子列表上:
a = {{-1, 0}, {0, 1}, {1, 0}}; b = {{0, -2 / 3}, {-1, 0}};Graphics[{Texture[[image]],
FilledCurve[{{BezierCurve[2a], Line[2b]}, {BezierCurve[a], Line[b]}},
VertexTextureCoordinates -> {{{0, 1 / 2}, {1 / 2, 1}, {1, 1 / 2}, {1 / 2, 1 / 12}, {0, 1 / 2}}, {{1 / 4, 1 / 2}, {1 / 2, 3 / 4}, {3 / 4, 1 / 2}, {1 / 2, 7 / 24},
{1 / 4, 1 / 2}}}]}]绘制函数的纹理坐标可由 TextureCoordinateFunction 指定:
ParametricPlot[{r t Cos[t], r t Sin[t]}, {t, 0, 2Pi}, {r, 0, 1}, PlotRange -> All, Mesh -> False, Axes -> False, PlotStyle -> {Opacity[1], Texture[ExampleData[{"ColorTexture", "Roof"}]]}]ParametricPlot[{r t Cos[t], r t Sin[t]}, {t, 0, 2Pi}, {r, 0, 1}, PlotRange -> All, Mesh -> False, Axes -> False, PlotStyle -> {Opacity[1], Texture[ExampleData[{"ColorTexture", "Roof"}]]}, TextureCoordinateFunction -> ({#1, #2}&)]Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, PlotStyle -> Texture[ExampleData[{"TestImage", "House"}]], TextureCoordinateFunction -> ({#1, #2}&), Lighting -> "Neutral", Mesh -> None]纹理样式 (4)
使用 Opacity 设置纹理的整体不透明度:
Table[Graphics3D[{Opacity[o], Texture[[image]], Polygon[{{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1},
{0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}},
{{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}},
... }, VertexTextureCoordinates ->
{{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}}]}, Lighting -> "Neutral", Boxed -> False], {o, {1 / 4, 1 / 2, 2 / 3, 1}}]使用 FaceForm 设置不同的前后纹理:
vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
coords = {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}}, {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}}};Graphics3D[{FaceForm[Texture[[image]], Texture[[image]]], Polygon[coords, VertexTextureCoordinates -> Table[vtc, {6}]]}, Lighting -> "Neutral"]纹理表面的反射度可由 Specularity 设置:
Table[ParametricPlot3D[{Cos[u] (3 + Cos[v]), Sin[u] (3 + Cos[v]), Sin[v]}, {u, 0, 2 π}, {v, 0, 2 π}, TextureCoordinateFunction -> ({2#4, #5}&), PlotStyle -> Directive[Specularity[White, s], Texture[ExampleData[{"ColorTexture", "WhiteMarble"}]]], Axes -> False, Lighting -> "Neutral", Mesh -> None, ImageSize -> Small], {s, {5, 20, 50, 100}}]在与 Lighting 交互时,纹理的色彩为漫反射色彩;
Table[Graphics3D[{Texture[[image]], Polygon[{{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1},
{0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}},
{{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}},
... }, VertexTextureCoordinates ->
{{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {{0, 0}, {1, 0}, {1, 1}, {0, 1}}}]}, Lighting -> {{"Point", c, {4, -4, 4}}}, Boxed -> False], {c, {White, Red, Green, Blue}}]推广和延伸 (1)
使用 {r,g,b,a} 格式列表指定纹理单个像素的透明度:
data = Table[{1, 0, 0, a}, {u, 0, 1, 1 / 100}, {a, 0, 1, 1 / 100}];vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
coords = {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}}, {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}}, {{0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}}};Graphics3D[{Texture[data], Polygon[coords, VertexTextureCoordinates -> Table[vtc, {6}]]}, Lighting -> "Neutral", Boxed -> False]data1 = Table[{1, 2 / 3, 0, If[u^2 + v^2 < 1 / 2, 0, 1]}, {u, -1, 1, 1 / 100}, {v, -1, 1, 1 / 100}];
data2 = Table[{0, 0, 1, If[u^2 + v^2 < 1 / 2, 0, 1]}, {u, -1, 1, 1 / 100}, {v, -1, 1, 1 / 100}];Graphics3D[{FaceForm[Texture[data1], Texture[data2]], Polygon[coords, VertexTextureCoordinates -> Table[vtc, {6}]]}, Lighting -> "Neutral", Boxed -> False]应用 (13)
基本应用 (1)
mapPolygon[p : Polygon[_, idx_, VertexTextureCoordinates -> vtc_], img_] :=
Block[...]mapPolygon[Polygon[{{0, 0, 0}, {1, 0, 0}, {0.5, 1, 0}}, {1, 2, 3}, VertexTextureCoordinates ->
{{0.2, 0.2}, {0.8, 0.2}, {0.5, 0.8}}], [image]]mapPolygon[Polygon[{{-100, -100, -100}, {100, -100, -100}, {100, 100, -100}, {-100, 100, -100},
{-100, -100, -100}, {100, -100, -100}, {100, -100, 100}, {-100, -100, 100}, {100, -100, -100},
{100, 100, -100}, {100, 100, 100}, {100, -100, 100}, {100, 100 ... 7525, 0.33666666666666667}, {0.9975, 0.33666666666666667}, {0.9975, 0.6633333333333333},
{0.7525, 0.6633333333333333}, {0.2525, 0.6699999999999999}, {0.4975, 0.6699999999999999},
{0.4975, 0.9966666666666666}, {0.2525, 0.9966666666666666}}], [image]]mapPolygon[Polygon[{{0., 0., 1.}, {-0.2777182317483142, 0.20177410616759886, 0.9392336204772784},
{-0.5554364634966285, 0.4035482123351977, 0.7270757700126067},
{-0.7236067977499789, 0.5257311121191336, 0.44721359549995787},
{0.10607892523233588, 0.3 ... 71705951760442, 0.4450936361588238},
{0.6328294048239558, 0.4450936361588237}, {0.3, 0.43993157242460157},
{0.5, 0.43993157242460157}, {0.7, 0.43993157242460157}, {0.9, 0.43993157242460157},
{0.09999999999999998, 0.43993157242460157}}], [image]]环境贴图 (3)
env = {Texture[[image], "Spherical"], Black, Sphere[{0, 0, 0}, 100]};Graphics3D[{env, Torus[]}, ViewVector -> {{-1, -2, 1}, {0, 0, 0}}, Method -> {"RotationControl" -> "Globe"}]env = {Texture[[image]], Black, EdgeForm[], Polygon[{{-100, -100, -100}, {100, -100, -100}, {100, 100, -100}, {-100, 100, -100},
{-100, -100, -100}, {100, -100, -100}, {100, -100, 100}, {-100, -100, 100}, {100, -100, -100},
{100, 100, -100}, {100, 100, 100}, {100, -100, 100}, {100, 100 ... 7525, 0.33666666666666667}, {0.9975, 0.33666666666666667}, {0.9975, 0.6633333333333333},
{0.7525, 0.6633333333333333}, {0.2525, 0.6699999999999999}, {0.4975, 0.6699999999999999},
{0.4975, 0.9966666666666666}, {0.2525, 0.9966666666666666}}]};Graphics3D[{env, Torus[]}, ViewVector -> {{-1, -2, 1}, {0, 0, 0}}, Method -> {"RotationControl" -> "Globe"}]images = {[image], [image], [image], [image], [image], [image]};
sides = {Polygon[{{-100, -100, -100}, {100, -100, -100}, {100, 100, -100}, {-100, 100, -100}},
VertexTextureCoordinates -> {{0.01, 0.01}, {0.99, 0.01}, {0.99, 0.99}, {0.01, 0.99}}], Polygon[{{-100, -100, -100}, {100, -100, -100}, {100, -100, 100}, {-100, -100, 100}},
VertexTextureCoordinates -> {{0.01, 0.01}, {0.99, 0.01}, {0.99, 0.99}, {0.01, 0.99}}], Polygon[{{100, -100, -100}, {100, 100, -100}, {100, 100, 100}, {100, -100, 100}},
VertexTextureCoordinates -> {{0.01, 0.01}, {0.99, 0.01}, {0.99, 0.99}, {0.01, 0.99}}], Polygon[{{100, 100, -100}, {-100, 100, -100}, {-100, 100, 100}, {100, 100, 100}},
VertexTextureCoordinates -> {{0.01, 0.01}, {0.99, 0.01}, {0.99, 0.99}, {0.01, 0.99}}], Polygon[{{-100, 100, -100}, {-100, -100, -100}, {-100, -100, 100}, {-100, 100, 100}},
VertexTextureCoordinates -> {{0.01, 0.01}, {0.99, 0.01}, {0.99, 0.99}, {0.01, 0.99}}], Polygon[{{100, -100, 100}, {100, 100, 100}, {-100, 100, 100}, {-100, -100, 100}},
VertexTextureCoordinates -> {{0.01, 0.01}, {0.99, 0.01}, {0.99, 0.99}, {0.01, 0.99}}]};
env = {Black, EdgeForm[], Riffle[Texture /@ images, sides]};Graphics3D[{env, Torus[]}, ViewVector -> {{-1, -2, 1}, {0, 0, 0}}, Method -> {"RotationControl" -> "Globe"}]天文学 (2)
将纹理贴图与 MaterialShading 一起使用,创建逼真的行星和卫星:
celestialMaterial[entity_Entity] :=
Block[{albedo, normals},
albedo = entity["CylindricalEquidistantTexture"];
normals = Image[ResourceFunction[ResourceObject[Association["Name" -> "NormalTexture",
"ShortName" -> "NormalTexture", "UUID" -> "5fc5ea7f-f287-4d4c-b400-df80515487af",
"ResourceType" -> "Function", "Version" -> "1.0.0",
"Description" -> "Generate a no ... ,
"SymbolName" -> "FunctionRepository`$faee06013a97443aa16264966d8cbdba`NormalTexture",
"FunctionLocation" -> CloudObject[
"https://www.wolframcloud.com/obj/f283570d-7972-41db-bf62-7f0a750d8410"]],
ResourceSystemBase -> Automatic]][GeoElevationData["World", GeoRange -> All, GeoModel -> entity, GeoZoomLevel -> 2], 0.1]];
MaterialShading[<|"BaseColor" -> Texture[albedo], "SurfaceNormals" -> Texture[normals], "RoughnessCoefficient" -> 1, "MetallicCoefficient" -> 0|>]
]Graphics3D[{celestialMaterial[#], Sphere[]}, Lighting -> "Accent", Boxed -> False, ViewPoint -> Front]& /@ {Entity["PlanetaryMoon", "Moon"], Entity["Planet", "Mars"], Entity["Planet", "Earth"]}Graphics3D[{{Texture[[image], "Spherical"], Black, Sphere[{0, 0, 0}, 100]}, Texture[Entity["Planet", "Earth"]["CylindricalEquidistantTexture"], "Spherical"], Sphere[{0, 0, 0}]}, ViewVector -> {{2, -2, 0}, {0, 0, 0}}, Method -> {"RotationControl" -> "Globe"}, Lighting -> "Accent", Boxed -> False]地理 (2)
在江交互式地球仪上显示来自 GeoGraphics 的地理数据:
Graphics3D[{Texture[GeoGraphics[GeoBackground -> #, ImageSize -> Large, GeoProjection -> "Equirectangular"], "Spherical"], Black, Sphere[{0, 0, 0}]}, Boxed -> False, ViewPoint -> Front]& /@ {"CountryBorders", "VectorMinimal", "SatelliteWithLabels"}countries = With[{coords = Reverse /@ First[CountryData[#, "Coordinates"]]},
{Texture[#["Flag"]], Polygon[coords, VertexTextureCoordinates -> Transpose[Rescale /@ Transpose[coords]]]}
]& /@ CountryData["SouthAmerica"];
Graphics[{EdgeForm[StandardGray], #}, ImageSize -> Tiny]& /@ countriesShow[%]纹理模型 (1)
可视化 (2)
ParametricPlot3D[{1.16 ^ v Cos[v](1 + Cos[u]), -1.16 ^ v Sin[v](1 + Cos[u]), -2 1.16 ^ v(1 + Sin[u])}, {u, 0, 2Pi}, {v, -15, 6}, PlotStyle -> Directive[Specularity[White, 100], Texture[ExampleData[{"ColorTexture", "WhiteMarble"}]]], TextureCoordinateFunction -> ({#4, 3#5}&), Lighting -> "ThreePoint", Mesh -> None, PlotRange -> All, Boxed -> False, Axes -> False]将纹理应用到 ListSurfacePlot3D:
bunny = MeshCoordinates[ResourceData["Stanford Bunny"]];ListSurfacePlot3D[bunny, MaxPlotPoints -> 35, Mesh -> None, Boxed -> False, Axes -> None, Ticks -> None, TextureCoordinateFunction -> (Normalize[{#1, #2, #3}]&), PlotStyle -> Directive[Specularity[White, 20], Texture[ExampleData[{"ColorTexture", "WhiteMarble"}]]], Lighting -> "Neutral"]纹理范例 (1)
ExampleData 包括灰度图和彩色纹理样本:
Short[ExampleData["Texture"]]Short[ExampleData["ColorTexture"]]torus[t_] := ParametricPlot3D[{Cos[u] (3 + Cos[v]), Sin[u] (3 + Cos[v]), Sin[v]}, {u, 0, 2 π}, {v, 0, 2 π}, TextureCoordinateFunction -> ({2#4, #5}&), PlotStyle -> Directive[Specularity[White, 50], Texture[ExampleData[{"ColorTexture", t}]]], Axes -> False, Lighting -> "Neutral", Mesh -> None, Boxed -> False, ImageSize -> 120];Table[torus[t], {t, {"Ash", "CheetahFur", "Kingwood", "Metal4", "Vavona", "WhiteMarble"}}]实体渲染 (1)
slices = {[image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image]};data = Developer`ToPackedArray[Map[ImageData, slices]];Manipulate[Graphics3D[{Opacity[Dynamic[o]], Texture[data], EdgeForm[None],
Dynamic[{Polygon[{{x, 0, 0}, {x, 1, 0}, {x, 1, 1}, {x, 0, 1}}, VertexTextureCoordinates -> {{x, 0, 0}, {x, 1, 0}, {x, 1, 1}, {x, 0, 1}}], Polygon[{{0, y, 0}, {1, y, 0}, {1, y, 1}, {0, y, 1}}, VertexTextureCoordinates -> {{0, y, 0}, {1, y, 0}, {1, y, 1}, {0, y, 1}}],
Polygon[{{0, 0, z}, {1, 0, z}, {1, 1, z}, {0, 1, z}}, VertexTextureCoordinates -> {{0, 0, z}, {1, 0, z}, {1, 1, z}, {0, 1, z}}]}]}, Background -> Black, RotationAction -> "Clip"], {{x, 0.5}, 0, 1}, {{y, 0.5}, 0, 1}, {{z, 0.5}, 0, 1}, {{o, 0.75, "opacity"}, 0, 1}]属性和关系 (4)
可用 TextureMapping 为每个对象指定投影映射:
{Graphics3D[{Texture[[image], "Box"], Cube[]}], Graphics3D[{Texture[[image]], Cube[TextureMapping -> "Box"]}]}"Spherical" 映射将曲面上的笛卡尔点转换为球坐标:
ℛ1 = GeodesicPolyhedron[3];
vtc = Table[
{r, θ, ϕ} = ToSphericalCoordinates[c];{Rescale[ϕ - Pi / 2, {-Pi, Pi}], 1 - Rescale[θ, {0, Pi}]}, {c, PolyhedronCoordinates[ℛ1]}];
ℛ2 = Append[ℛ1, VertexTextureCoordinates -> vtc]Graphics3D[{Texture[[image]], EdgeForm[], ℛ2}, Lighting -> "Neutral"]"Cylindrical" 映射将曲面上的笛卡尔点转换为圆柱坐标:
ℛ1 = BoundaryDiscretizeRegion[Cylinder[]];
vtc = Table[
{ρ, ϕ, z} = CoordinateTransform["Cartesian" -> "Cylindrical", c];{Rescale[ϕ, {-Pi, Pi}], Rescale[z, {-5, 1}]}, {c, MeshCoordinates[ℛ1]}];
ℛ2 = GraphicsComplex[MeshCoordinates[ℛ1], MeshCells[ℛ1, 2], VertexTextureCoordinates -> vtc];Graphics3D[{Texture[[image]], EdgeForm[], ℛ2}, Lighting -> "Neutral"]ℛ1 = GeodesicPolyhedron[3];
vtc = Table[c[[1 ;; 2]], {c, PolyhedronCoordinates[ℛ1]}];
ℛ2 = Append[ℛ1, VertexTextureCoordinates -> vtc]Graphics3D[{Texture[[image]], EdgeForm[], ℛ2}, Lighting -> "Neutral"]可能存在的问题 (1)
VertexColors 优先于纹理映射:
Graphics3D[{Texture[[image]], Polygon[{{-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
VertexColors -> {Red, Green, Blue, Purple}]}, Lighting -> "Neutral"]巧妙范例 (3)
动画纹理 (2)
DynamicModule[{}, Graphics3D[{Dynamic[Texture[clock, "Box"], UpdateInterval -> 1], Cube[]}, Lighting -> "Neutral", Boxed -> False], Initialization :> (clock := Module[{hour, min, sec, ht, mt, st}, {hour, min, sec} = Take[DateList[], -3];ht = Pi / 2 - 2 π hour / 12 - (2 π) min / 720;mt = Pi / 2 - 2 π min / 60;st = Pi / 2 - 2 π Floor[sec] / 60;Graphics[{Thick, Arrowheads[Large], Arrow[{{0, 0}, 0.6{Cos[ht], Sin[ht]}}], Arrow[{{0, 0}, 0.9{Cos[mt], Sin[mt]}}], PointSize[Large], Table[Point[0.9{Cos[i], Sin[i]}], {i, 0, 2Pi, π / 6}], Point[{0, 0}], Circle[], Red, Line[{{0, 0}, 0.85{Cos[st], Sin[st]}}]}]])]Graphics[{Dynamic[Texture[frames[[Ceiling[Clock[{1, Length[frames], 1}, 10]]]]], UpdateInterval -> 0.5, Initialization :> (frames = {[image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image]};
quad = Polygon[{{0, 0}, {2, 0}, {2, 2}, {0, 2}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}];)], quad}]DynamicModule[{chickens},
chickens = Table[Translate[quad, pos], {pos, {{5, 6}, {13, 2}, {10, 4}, {6, 1}, {11, 7}, {2, 5}, {3, 2}, {8, 3}, {5, 4}}}];
Graphics[Table[{With[{idx = i}, Dynamic[Texture[frames[[Mod[Ceiling[2 * Clock[100]] + idx * 27, Length[frames], 1]]]], UpdateInterval -> 0.5]], chickens[[i]]}, {i, Length[chickens]}]]
]多面体上的纹理 (1)
Manipulate[Graphics3D[{Specularity[White, 20], Texture[ImageCrop[ExampleData[{"ColorTexture", "WhiteMarble"}], {128, 128}]], EdgeForm[Opacity[1 / 10]], (Append[#1, {VertexTextureCoordinates -> With[{n = Length[First[#1]]}, Table[1 / 2 {Cos[2 π i / n], Sin[2 π i / n]} + {1 / 2, 1 / 2}, {i, 0, n - 1}]]}]&) /@ Flatten[PolyhedronData[p, "Faces", "Polygon"]]}, Lighting -> "Neutral"], {{p, "RhombicHexecontahedron", "polyhedron"}, PolyhedronData[]}]
| |
| |
文本
Wolfram Research (2010),Texture,Wolfram 语言函数,https://reference.wolfram.com/language/ref/Texture.html (更新于 2024 年).
CMS
Wolfram 语言. 2010. "Texture." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2024. https://reference.wolfram.com/language/ref/Texture.html.
APA
Wolfram 语言. (2010). Texture. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/Texture.html 年
BibTeX
@misc{reference.wolfram_2026_texture, author="Wolfram Research", title="{Texture}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/Texture.html}", note=[Accessed: 13-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_texture, organization={Wolfram Research}, title={Texture}, year={2024}, url={https://reference.wolfram.com/language/ref/Texture.html}, note=[Accessed: 13-November-2026]}