is an option for graphics primitives that specifies the texture mapping to use.
TextureMapping
is an option for graphics primitives that specifies the texture mapping to use.
Details
- TextureMapping is also known as UV mapping or diffuse mapping.
- TextureMapping is typically used in modeling to project an image to a 2D polygon or 3D surface.
- Possible 3D projection mappings for 2D images include:
-
Automatic automatically choose the projectionNone no projection"Box" box projection"Cubic" cubic projection"Cylindrical" cylindrical projection"Front" planar project on the x–y plane"Planar" planar projection"Spherical" spherical projection"Stereographic" stereographic projection
- The projection is separately mapped to each individual primitive specified in the graphic. If a texture is mapped onto a Polygon expression containing multiple polygons, then the texture will be mapped over the entire region covered by the set of polygons. »
Examples
open all close allBasic Examples (3)
Apply texture mapping to a polygon in 2D:
Graphics[{Texture[[image]], Polygon[{{0, 0}, {1, 0}, {0.5, 1}}, TextureMapping -> "Planar"]}]Apply a texture mapping to a cube:
Graphics3D[{Texture[[image]], Cube[TextureMapping -> "Box"]}]Apply a texture mapping to a sphere:
Graphics3D[{Texture[Entity["Planet", "Earth"]["CylindricalEquidistantTexture"]], Sphere[TextureMapping -> "Spherical"]}, Lighting -> "Neutral"]Scope (8)
Apply a texture mapping to graphics primitives in 2D:
Graphics[{Texture[[image]], #[TextureMapping -> "Planar"]}]& /@ {Disk, Triangle, Rectangle}In 3D:
Graphics3D[{Texture[[image]], #[TextureMapping -> "Planar"]}, Lighting -> "Neutral"]& /@ {Sphere, Tetrahedron, Cube}Apply a "Planar" mapping to project coordinates along a single axis:
Graphics3D[{Texture[[image]], Cube[TextureMapping -> "Planar"]}, Boxed -> False, Lighting -> "Neutral"]Apply a "Cubic" mapping to selectively apply one of three planar mappings based on a point's surface direction:
Graphics3D[{Texture[[image]], Cube[TextureMapping -> "Cubic"]}, Boxed -> False, Lighting -> "Neutral"]Apply a "Box" mapping to selectively apply one of six planar mappings based on a point's surface direction:
Graphics3D[{Texture[[image]], Cube[TextureMapping -> "Box"]}, Boxed -> False, Lighting -> "Neutral"]Apply a "Cylindrical" mapping to use a cylindrical projection for the sides of the primitive and a planar projection for the top and bottom:
Graphics3D[{Texture[[image]], Cylinder[TextureMapping -> "Cylindrical"]}, Boxed -> False, Lighting -> "Neutral"]Apply a "Spherical" mapping to use a spherical projection:
Graphics3D[{Texture[[image]], Sphere[TextureMapping -> "Spherical"]}, Boxed -> False, Lighting -> "Neutral"]Apply a "Stereographic" projection to achieve a conformal mapping of the 2D plane to a sphere:
Graphics3D[{Texture[[image]], Sphere[TextureMapping -> "Stereographic"]}, Boxed -> False, Lighting -> "Neutral"]Apply mappings individual to each primitive in a graphic:
Graphics[{Texture[ExampleData[{"TestImage", "Flower"}]], Polygon[{{0, 0}, {0, 1}, {1, 0}}], Polygon[{{.5, .5}, {.5, 1.5}, {1.5, .5}}]}]Use multi-Polygon to apply a mapping to an entire region covered by polygons:
Graphics[{Texture[ExampleData[{"TestImage", "Flower"}]], Polygon[{{{0, 0}, {0, 1}, {1, 0}}, {{.5, .5}, {.5, 1.5}, {1.5, .5}}}]}]Applications (4)
Create a realistic background using a spherical texture:
env = {Texture[[image]], Black, Sphere[{0, 0, 0}, 100, TextureMapping -> "Spherical"]};Graphics3D[{env, Torus[]}, ViewVector -> {{-1, -2, 1}, {0, 0, 0}}, Method -> {"RotationControl" -> "Globe"}]Apply equirectangular textures to a sphere using the "Spherical" mapping:
Graphics3D[{Texture[Entity["PlanetaryMoon", "Moon"]["CylindricalEquidistantTexture"]], Sphere[TextureMapping -> "Spherical"]}, Lighting -> "Accent", Boxed -> False, ViewPoint -> Front]Use a "Spherical" mapping to create a star map as the background:
Graphics3D[{{Texture[[image]], Black, Sphere[{0, 0, 0}, 100, TextureMapping -> "Spherical"]}, Texture[Entity["Planet", "Earth"]["CylindricalEquidistantTexture"]], Sphere[{0, 0, 0}, TextureMapping -> "Spherical"]}, Method -> {"RotationControl" -> "Globe"}, Lighting -> "Accent", Boxed -> False, ViewVector -> {{-3, -1, 0.75}, {0, 0, 0}}]Display geographical data from GeoGraphics on an interactive globe:
Graphics3D[{Texture[GeoGraphics[GeoBackground -> #, ImageSize -> Large, GeoProjection -> "Equirectangular"]], Black, Sphere[{0, 0, 0}, TextureMapping -> "Spherical"]}, Boxed -> False, ViewPoint -> {2, 1, 0}]& /@ {"CountryBorders", "VectorMinimal", "ReliefMap"}Properties & Relations (2)
VertexTextureCoordinates can be used to explicitly apply texture coordinates to the vertices of some primitives:
Graphics[{Texture[[image]],
Polygon[{{0, 0}, {1, 0}, {1 / 2, 1}},
VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1 / 2, 1}}]}]TextureCoordinateFunction is used by plots to compute texture coordinates based on certain values at a given point:
ParametricPlot[{r t Cos[t], r t Sin[t]}, {t, 0, 2 Pi}, {r, 0, 1}, ..., TextureCoordinateFunction -> ({#1, #2}&)]Possible Issues (1)
Primitives with a "Cubic" mapping will show the mapped texture as reversed on three of the size sides:
Graphics3D[{Texture[[image]], Cube[TextureMapping -> "Cubic"]}, Lighting -> "Neutral", Boxed -> False, ViewPoint -> #]& /@ {Front, Right, Above, Back, Left, Bottom}Use the "Box" mapping to flip the texture based on the sign of the projection axis:
Graphics3D[{Texture[[image]], Cube[TextureMapping -> "Box"]}, Lighting -> "Neutral", Boxed -> False, ViewPoint -> #]& /@ {Front, Right, Above, Back, Left, Bottom}History
Text
Wolfram Research (2024), TextureMapping, Wolfram Language function, https://reference.wolfram.com/language/ref/TextureMapping.html.
CMS
Wolfram Language. 2024. "TextureMapping." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TextureMapping.html.
APA
Wolfram Language. (2024). TextureMapping. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TextureMapping.html
BibTeX
@misc{reference.wolfram_2026_texturemapping, author="Wolfram Research", title="{TextureMapping}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/TextureMapping.html}", note=[Accessed: 05-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_texturemapping, organization={Wolfram Research}, title={TextureMapping}, year={2024}, url={https://reference.wolfram.com/language/ref/TextureMapping.html}, note=[Accessed: 05-September-2026]}