---
title: "Raster3D"
language: "en"
type: "Symbol"
summary: "Raster3D[{{{a11, a12, ...}, ...}, ...}] is a three-dimensional graphics primitive that represents a cubical array of gray cells. Raster3D[{{{{r11, g11, b11}, ...}, ...}, ...}] represents an array of RGB color cells. Raster3D[{{{{r11, g11, b11, \\[Alpha]11}, ...}, ...}, ...}] represents an array of color cells with opacity \\[Alpha]ij. Raster3D[array, {{xmin, ymin, zmin}, {xmax, ymax, zmax}}] represents a three-dimensional graphics primitive by giving the coordinates of opposite corners. Raster3D[array, coordinates, {amin, amax}] represents a three-dimensional graphics primitive whose voxel values should be scaled so that amin corresponds to 0 and amax corresponds to 1."
keywords: 
- 3D image
- Raster3D
- volumetric data
- volumetric display
- volumetric rendering
- voxel
- voxel data
- volumetric pixel
- volumetric imaging
- 3D dicom
- 3D mri
canonical_url: "https://reference.wolfram.com/language/ref/Raster3D.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Graphics Objects"
    link: "https://reference.wolfram.com/language/guide/GraphicsObjects.en.md"
related_functions: 
  - 
    title: "Image3D"
    link: "https://reference.wolfram.com/language/ref/Image3D.en.md"
  - 
    title: "Raster"
    link: "https://reference.wolfram.com/language/ref/Raster.en.md"
  - 
    title: "Graphics3D"
    link: "https://reference.wolfram.com/language/ref/Graphics3D.en.md"
  - 
    title: "Cuboid"
    link: "https://reference.wolfram.com/language/ref/Cuboid.en.md"
---
# Raster3D

Raster3D[{{{a11, a12, …}, …}, …}] is a three-dimensional graphics primitive that represents a cubical array of gray cells. 

Raster3D[{{{{r11, g11, b11}, …}, …}, …}] represents an array of RGB color cells. 

Raster3D[{{{{r11, g11, b11, α11}, …}, …}, …}] represents an array of color cells with opacity αij.

Raster3D[array, {{xmin, ymin, zmin}, {xmax, ymax, zmax}}] represents a three-dimensional graphics primitive by giving the coordinates of opposite corners.

Raster3D[array, coordinates, {amin, amax}] represents a three-dimensional graphics primitive whose voxel values should be scaled so that amin corresponds to 0 and amax corresponds to 1.

## Details and Options

* ``Raster3D[…]`` displays in a notebook as a rendered solid volume.

* ``Raster3D[array]`` accepts three- or four-dimensional data arrays where the first dimension corresponds to the $z$ direction, the second dimension corresponds to the $y$ direction, and the third dimension corresponds to the $x$ direction, respectively.

* If ``array`` has dimensions ``{z, y, x}``, then ``Raster[array]`` is equivalent to ``Raster3D[array, {{0, 0, 0}, {x, y, z}}]``.

* ``Raster3D[array, {{xmin, ymin, zmin}, {xmax, ymax, zmax}}]`` occupies the same 3D space that ``Cuboid[{xmin, ymin, zmin}, {xmax, ymax, zmax}]`` would. The first voxel is mapped to ``{xmin, ymin, zmin}``, and the last voxel is mapped to ``{xmax, ymax, ymax}``.

* The coordinates of the corners of the volume can be given using ``Scaled``. »

* You can specify color and transparency of the volume using standard graphics directives.

* By default, elements of ``array`` are displayed as follows:

|              |                                                |
| ------------ | ---------------------------------------------- |
| v or {v}     | gray level from 0 (black) to 1 (white)         |
| {v, a}       | gray and alpha values from 0 to 1              |
| {r, g, b}    | red, green, and blue values from 0 to 1        |
| {r, g, b, a} | red, green, blue, and alpha values from 0 to 1 |

* ``Raster3D[array, coordinates, {amin, amax}]`` allows voxel values to be scaled so that ``amin`` corresponds to 0, and ``amax`` corresponds to 1. Voxel values outside this range are clipped to be 0 or 1.

* ``Raster3D`` can take the following options:

|                        |           |                                                            |
| ---------------------- | --------- | ---------------------------------------------------------- |
| ClipRange              | None      | cut away a rectangular region from the view                |
| ColorFunction          | Automatic | how to determine the color of a voxel                      |
| Method                 | Automatic | options for rendering the color cells                      |
| PlotRange              | Automatic | range of the visualized volume                             |
| VertexDataCoordinates  | Automatic | how to map data into the cuboid range occupied by Raster3D |

* ``Raster3D[array, …, ColorFunction -> f]`` specifies that each cell should be colored using the graphics directives obtained by applying the function ``f`` to the value specified for that cell. The default value is ``Automatic``.

* The following predefined color functions can also be used:

GrayLevel	apply gray-level color space
      	RGBColor	apply RGB or RGBA color space
      	Hue	apply HSB color space
      	CMYKColor	apply CMYK color space
      	Opacity	apply opacities only with all colors set to White
      	"XYZ"	apply XYZ color space
      	"LUV"	apply LUV color space
      	"LAB"	apply LAB color space
      	ColorData["scheme"]	apply the specified ColorData function
      	"scheme"	equivalent to ColorData["scheme"]
      	"GrayLevelOpacity"	apply GrayLevel with Opacity; voxels with values near 0 will be transparent, while voxels with values near 1 will be opaque
      	"HueOpacity"	apply Hue with Opacity
      	"schemeOpacity"	apply ColorData["scheme"] with Opacity
      	"XRay"	approximate an X-ray effect
      	"WhiteBlackOpacity"	apply a white-to-black color component with opacity
      	{"HighRange",threshold}	make values less than threshold completely transparent and apply the Opacity function otherwise
      	{"LowRange",threshold}	make values greater than threshold completely transparent and apply the Opacity function otherwise

* ``Raster3D[array, …, ClipRange -> {{xmin, xmax}, {ymin, ymax}, {zmin, zmax}}]`` specifies the volume range that will be clipped. The default value is ``None``.

* ``Raster3D[array, …, PlotRange -> {{xmin, xmax}, {ymin, ymax}, {zmin, zmax}}]`` specifies the volume range that will be visualized.

* ``Raster3D[array, …, VertexDataCoordinates -> {{u1, v1, w1}, {u2, v2, w2}}]`` specifies the way the array data maps to the specified coordinates. By default, ``Raster3D[array, coordinates]`` is equivalent to ``Raster3D[array, coordinates, VertexDataCoordinates -> {{0, 0, 0}, {1, 1, 1}}]``, where ``{0, 0, 0}`` means the first row, column, and tube element in the array, and ``{1, 1, 1}`` means the last row, column, and tube element in the array.

* ``Raster3D[array, …, Method -> {"…" -> v1, "…" -> v2, …}]`` specifies the details of the rendering methods.

* The following settings can be applied using the ``Method`` option:

|     |     |     |
| --- | --- | --- |
| "HomogeneousOpacity" | True | adjust opacity so that rasters of differing dimensions exhibit approximately the same overall opacity characteristics |
| "InterpolateValues" | False | whether to render values with smooth interpolations |
| "MinSample" | 50  | minimal resampled voxel resolution |
| "SampleLayers" | Automatic | number of sampling layers to use for the volume |
| "VolumeLighting" | False | whether the raster should respond to Lighting settings |

## Examples (39)

### Basic Examples (2)

A gray-level volume:

```wl
In[1]:= Graphics3D[{Raster3D[RandomReal[1, {5, 5, 5}]]}]

Out[1]= [image]
```

---

A partially transparent volume with RGB-colored voxels:

```wl
In[1]:= Graphics3D[{Opacity[.5], Raster3D[RandomReal[1, {5, 5, 5, 3}]]}]

Out[1]= [image]
```

### Scope (9)

#### Specification (7)

For a $$z$$``×``$$y$$``×``$$x$$ array, the raster occupies the region ``{0, 0, 0}`` to ``{x, y, z}`` :

```wl
In[1]:= Graphics3D[Raster3D[RandomReal[1, {4, 4, 4}]], Axes -> True]

Out[1]= [image]
```

---

Specify the shape of the ``Raster3D`` explicitly:

```wl
In[1]:= Graphics3D[Raster3D[RandomReal[1, {4, 4, 4}], {{0, 0, 0}, {1, 2, 3}}], Axes -> True]

Out[1]= [image]
```

---

Use ``Scaled`` coordinates:

```wl
In[1]:= Graphics3D[Raster3D[RandomReal[1, {5, 10, 15}], {Scaled[{0, .2, .4}], Scaled[{1, .8, .6}]}], PlotRange -> {{0, 10}, {0, 10}, {0, 10}}]

Out[1]= [image]
```

---

Scale the resulting values to a nondefault range:

```wl
In[1]:= Graphics3D[Raster3D[{{{1, 5, 10}, {1, 5, 10}}, {{10, 5, 1}, {10, 5, 1}}}, Automatic, {0, 10}]]

Out[1]= [image]
```

---

An array of pairs of numbers is treated as gray level with opacity:

```wl
In[1]:=
data = {{{{0, 0}, {0, .2}, {0, .4}, {0, .6}, {0, .8}, {0, 1.}}}};
Graphics3D[Raster3D[data]]

Out[1]= [image]
```

---

An array of triples is treated as an ``RGBColor`` specification:

```wl
In[1]:= Graphics3D[Raster3D[Table[{i, j, k}, {i, 5}, {j, 5}, {k, 5}], Automatic, {1, 5}]]

Out[1]= [image]
```

---

An array of four values is treated as ``RGBColor`` with opacity:

```wl
In[1]:= Graphics3D[Raster3D[Table[{i, j, k, RandomReal[{1, 5}]}, {i, 5}, {j, 5}, {k, 5}], Automatic, {1, 5}]]

Out[1]= [image]
```

#### Styling (2)

Color directives specify the colors of volumes:

```wl
In[1]:= Table[Graphics3D[{c, Raster3D[RandomReal[1, {5, 5, 5}]]}], {c, {Red, Green, Blue, Yellow}}]

Out[1]= {[image], [image], [image], [image]}
```

---

``Opacity`` specifies the volume opacity:

```wl
In[1]:= Table[Graphics3D[{Opacity[o], Raster3D[RandomInteger[1, {5, 5, 5, 3}]]}, Boxed -> False], {o, {0.1, 0.3, 0.9}}]

Out[1]= {[image], [image], [image]}
```

### Generalizations & Extensions (1)

Use ``NumericArray`` to compress data for better performance of a large dataset:

```wl
In[1]:= Graphics3D[{Raster3D[NumericArray[RandomInteger[255, {256, 256, 256}], "Byte"], {{0, 0, 0}, {1, 1, 1}}, {0, 255}]}]

Out[1]= [image]
```

### Options (16)

#### ClipRange (2)

A volume with clipping:

```wl
In[1]:=
Graphics3D[{
	Raster3D[RandomReal[1, {4, 4, 4}], {{0, 0, 0}, {1, 1, 1}}, ClipRange -> {{.25, 1}, {.25, 1}, {.25, 1}}]}, Axes -> True]

Out[1]= [image]
```

---

Use ``All`` to clip the entire range in a given dimension:

```wl
In[1]:=
Graphics3D[{
	Raster3D[RandomReal[1, {4, 4, 4}], {{0, 0, 0}, {1, 1, 1}}, ClipRange -> {All, {.25, 1}, {.25, 1}}]}, Axes -> True]

Out[1]= [image]
```

#### ColorFunction (5)

A volume with the ``GrayLevel`` color function:

```wl
In[1]:=
data = RandomReal[1, {5, 5, 5}];
Graphics3D[Raster3D[data, ColorFunction -> GrayLevel]]

Out[1]= [image]
```

The same volume with other color functions:

```wl
In[2]:= Table[Graphics3D[Raster3D[data, ColorFunction -> f], ImageSize -> Tiny], {f, {Hue, "Pastel", "XRay"}}]

Out[2]= {[image], [image], [image]}
```

---

Opacity variants of color functions allow visualization of volume interiors:

```wl
In[1]:= Table[Graphics3D[Raster3D[{{{0, .1}, {.2, .3}}, {{.7, .8}, {.9, 1.}}}, ColorFunction -> f]], {f, {Hue, "HueOpacity"}}]

Out[1]= {[image], [image]}
```

---

``Hue`` color function:

```wl
In[1]:= Graphics3D[{Opacity[.1], Raster3D[NumericArray[Import["ExampleData/CTengine.tiff", "Data"], "UnsignedInteger8"], {{0, 0, 0}, {1, 1, 1}}, {0, 255}, ColorFunction -> Hue, Method -> {"InterpolateValues" -> True}]}]

Out[1]= [image]
```

Apply ``Hue`` color function while keeping the opacity:

```wl
In[2]:= Graphics3D[{Opacity[.1], Raster3D[NumericArray[Import["ExampleData/CTengine.tiff", "Data"], "UnsignedInteger8"], {{0, 0, 0}, {1, 1, 1}}, {0, 255}, ColorFunction -> (Append[ColorConvert[Hue[#], "RGB"], #]&), Method -> {"InterpolateValues" -> True}]}]

Out[2]= [image]
```

---

A 3D image with different color functions:

```wl
In[1]:=
Table[Graphics3D[{Raster3D[NumericArray[Import["ExampleData/CThead.tiff", "Data"], "UnsignedInteger8"], {{0, 0, 0}, {1, 1, 1}}, {0, 255}, ColorFunction -> f, Method -> {"SampleLayers" -> 1000, "InterpolateValues" -> True}]}, ViewPoint -> Right], {f, {"GrayLevelOpacity", 
	(Blend[{{1, RGBColor[1., 1., 1., 1.]}, {0, RGBColor[0., 0., 0., 0]}, {0.32, RGBColor[0.5, 0.5, 0.5, 0.65]}, {0.66, RGBColor[ 0.66, 0.66, 0.66, 0.66]}, {0.07, RGBColor[0.12, 0.12, 0.12, 0]}}, #]& ), (Blend[{{0, RGBColor[0.035, 0.058, 0, 0]}, {0.1, RGBColor[0.015, 0, 0.035, 0]}, {0.2, RGBColor[0, 0, 0, 0.032]}, {0.3, RGBColor[0.103, 0.032, 0, 0]}, {0.4, RGBColor[0, 0, 0, 0]}, {0.5, RGBColor[0.202, 0.203, 0.218, 0.337]}, {0.6, RGBColor[0.403, 0.405, 0.400, 0.457]}, {0.7, RGBColor[0.485, 0.474, 0.603, 0.682]}, {0.8, RGBColor[0.861, 0.836, 0.838, 0.794]}, {0.9, RGBColor[0.459, 0.475, 0.458, 0.842]}, {1, RGBColor[0.562, 0.519, 0.554, 0.962]}}, #] &), (Blend[{{1, RGBColor[1., 1., 1., 0]}, {0, RGBColor[0., 0., 0., 0.]}, {0.35, RGBColor[0.33, 0.33, 0.33, 0]}, {0.66, RGBColor[0.66, 0.66, 0.66, 0]}, {0.21, RGBColor[0.19, 0.19, 0.19, 0.34]}, {0.19, RGBColor[0.17, 0.17, 0.17, 0]}, {0.27, RGBColor[0.25, 0.25, 0.25, 0]}}, #]&)}}]

Out[1]= [image]
```

---

A customized color function applied to four-dimensional data arrays:

```wl
In[1]:= Graphics3D[Raster3D[RandomReal[1, {5, 5, 5, 3}], ColorFunction -> (RGBColor[#[[1]], #[[2]], #[[3]], 0.299 #[[1]] + 0.587 #[[2]] + 0.114 #[[3]]]&)]]

Out[1]= [image]
```

#### PlotRange (1)

Specify the range of volume to be visualized:

```wl
In[1]:=
Graphics3D[{
	Raster3D[RandomReal[1, {4, 4, 4}], {{0, 0, 0}, {1, 1, 1}}, PlotRange -> {{.25, 1}, {.25, 1}, {.25, 1}}]}, Axes -> True]

Out[1]= [image]
```

#### VertexDataCoordinates (1)

A unit volume with customized volume coordinates assigned:

```wl
In[1]:= Graphics3D[{Raster3D[NumericArray[Import["ExampleData/CThead.tiff", "Data"], "UnsignedInteger8"], {{0, 1, 0}, {1, 0, 1}}, {0, 255}, ColorFunction -> "GrayLevelOpacity", VertexDataCoordinates -> {{0.15, 0.5, 0.25}, {0.65, .97, 0.75}}, Method -> {"InterpolateValues" -> True}]}]

Out[1]= [image]
```

#### Method Options (7)

##### "InterpolateValues" (2)

By default, color cells are shown as discrete cells:

```wl
In[28]:= Graphics3D[Raster3D[{{Range[0, 1, .2]}}]]

Out[28]= [image]
```

Use ``"InterpolateValues"`` to smooth color cell drawing:

```wl
In[2]:= Graphics3D[Raster3D[{{Range[0, 1, .2]}}, Method -> {"InterpolateValues" -> True}]]

Out[2]= [image]
```

---

Set ``"InterpolateValues" -> True`` for continuous data:

```wl
In[1]:= Graphics3D[{Opacity[.5], Raster3D[NumericArray[Import["ExampleData/CThead.tiff", "Data"], "UnsignedInteger8"], {{0, 1, 0}, {1, 0, 1}}, {0, 255}, ColorFunction -> "GrayLevelOpacity", Method -> { "InterpolateValues" -> True}]}]

Out[1]= [image]
```

##### "MinSample" (1)

Customize the minimal resampled voxel resolution:

```wl
In[3]:= Graphics3D[{Raster3D[Reverse@CellularAutomaton[{14, {2, 1}, {1, 1}}, {{{1}}, 0}, 10], ColorFunction -> (RGBColor[0.87, 0.94, 1, #]&), Method -> {"FastRendering" -> True, "VolumeLighting" -> "EnhancedEdge", "MinSample" -> #, "InterpolateValues" -> True}]}]& /@ {15, 50, 256}

Out[3]= {[image], [image], [image]}
```

##### "SampleLayers" (1)

A unit volume with customized samplings assigned for better rendering result:

```wl
In[1]:= Graphics3D[{Opacity[.5], Raster3D[NumericArray[Import["ExampleData/CThead.tiff", "Data"], "UnsignedInteger8"], {{0, 1, 0}, {1, 0, 1}}, {0, 255}, ColorFunction -> "GrayLevelOpacity", Method -> {"SampleLayers" -> 1000, "InterpolateValues" -> True}]}]

Out[1]= [image]
```

##### "VolumeLighting" (3)

A unit volume with lighting off and on:

```wl
In[1]:= Table[Graphics3D[{Specularity[White, 6], Raster3D[Import["ExampleData/CThead.tiff", "Data"], {{-1, -1, -1}, {1, 1, 1}}, {0, 255}, ColorFunction -> "GrayLevelOpacity", Method -> {"VolumeLighting" -> t, "InterpolateValues" -> True}]}, Lighting -> {{"Directional", White, ImageScaled[{0, 0, 2}]}}, ViewPoint -> {-3.2, 0.89, -0.34}], {t, {False, True, "EnhancedEdge"}}]

Out[1]= [image]
```

---

A spot light source:

```wl
In[1]:= Graphics3D[{Specularity[White, 6], Raster3D[Import["ExampleData/CThead.tiff", "Data"], {{-1, -1, -1}, {1, 1, 1}}, {0, 255}, ColorFunction -> "GrayLevelOpacity", Method -> {"VolumeLighting" -> True}]}, Lighting -> {{"Spot", Green, {{-1, 1, 0}, {0, 0, 0}}, Pi / 6, {0, 1, 0}}}, ViewPoint -> {-3.2, 0.9, -0.4}]

Out[1]= [image]
```

---

A point light source:

```wl
In[1]:= Graphics3D[{Specularity[White, 6], Raster3D[Import["ExampleData/CThead.tiff", "Data"], {{-1, -1, -1}, {1, 1, 1}}, {0, 255}, ColorFunction -> "GrayLevelOpacity", Method -> {"VolumeLighting" -> True, "InterpolateValues" -> True}]}, Lighting -> {{"Point", Yellow, {-1, 0, -0.5}}}, ViewPoint -> {-3.2, 0.89, -0.34}]

Out[1]= [image]
```

### Applications (3)

Explore medical data:

```wl
In[1]:= Graphics3D[Raster3D[NumericArray[Import["ExampleData/CThead.tiff", "Data"], "UnsignedInteger8"], {{0, 1, 0}, {1, 0, 1}}, {0, 255}, ColorFunction -> "GrayLevelOpacity", Method -> {"InterpolateValues" -> True}]]

Out[1]= [image]
```

---

Extrude 2D images:

```wl
In[1]:= Graphics3D[{Raster3D[List@ImageData[ImageResize[ExampleData[{"TestImage", "House2"}], 200]], {{0, 0, 0.4}, {1, 1, 0.6}}]}, PlotRange -> {0, 1}]

Out[1]= [image]
```

---

Apply a filter using ``ListCorrelate``, then display it:

```wl
In[1]:= data = Import["ExampleData/CTengine.tiff", "Data"];

In[2]:= Graphics3D[Raster3D[NumericArray[data, "UnsignedInteger8"], {{-1, -1, -1}, {1, 1, 1}}, {0, 255}, ColorFunction -> "GrayLevelOpacity", Method -> {"SampleLayers" -> 1000, "InterpolateValues" -> True}]]

Out[2]= [image]

In[3]:= ker = {{{-1, -1, -1}, {-1, 8, -1}, {-1, -1, -1}}, {{-1, -1, -1}, {-1, 8, -1}, {-1, -1, -1}}, {{-1, -1, -1}, {-1, 8, -1}, {-1, -1, -1}}};

In[4]:= f = Abs@ListCorrelate[ker, data];

In[5]:= Graphics3D[Raster3D[f, {{-1, -1, -1}, {1, 1, 1}}, {0, Max[f] / 4}, ColorFunction -> "SunsetColorsOpacity", Method -> {"SampleLayers" -> 1000, "InterpolateValues" -> True}]]

Out[5]= [image]
```

### Properties & Relations (2)

``GeometricTransformation`` can be applied to ``Raster3D`` :

```wl
In[1]:=
engine = Raster3D[NumericArray[Import["ExampleData/CTengine.tiff", "Data"], "UnsignedInteger8"], {{-1, -1, -1}, {1, 1, 1}}, {0, 255}, ColorFunction -> "GrayLevelOpacity"];
Graphics3D[GeometricTransformation[engine, ShearingTransform[Pi / 7, {1, 0, 0}, {0, 0, 1}]]]

Out[1]= [image]
```

---

``ClipPlanes`` can be used to slide a ``Raster3D`` :

```wl
In[1]:= Graphics3D[{Raster3D[Import["ExampleData/CTengine.tiff", "Data"], {{0, 0, 0}, {1, 1, 1}}, {0, 255}, ColorFunction -> "GrayLevelOpacity"]}, ClipPlanes -> InfinitePlane[{{0, 0, 0}, {0, 1, 0}, {1, 1, 1}}]]

Out[1]= [image]
```

### Possible Issues (2)

The default rendering might be affected by the data resolution:

```wl
In[1]:= (Graphics3D[{Opacity[.3], Raster3D[Table[If[x^2 + y^2 + z^2 < 1, 0.1, 0], {x, -1, 1, 2 / #}, {y, -1, 1, 2 / #}, {z, -1, 1, 2 / #}], {{-1, -1, -1}, {1, 1, 1}}, ColorFunction -> "GrayLevelOpacity"]}, ImageSize -> 120])& /@ {5, 10, 20, 30, 70, 100}

Out[1]= [image]
```

Set the "HomogenousOpacity" method option to normalize the appearance:

```wl
In[2]:= (Graphics3D[{Opacity[.3], Raster3D[Table[If[x^2 + y^2 + z^2 < 1, 0.1, 0], {x, -1, 1, 2 / #}, {y, -1, 1, 2 / #}, {z, -1, 1, 2 / #}], {{-1, -1, -1}, {1, 1, 1}}, ColorFunction -> "GrayLevelOpacity", Method -> {"HomogenousOpacity" -> True}]}, ImageSize -> 120])& /@ {5, 10, 20, 30, 70, 100}

Out[2]= [image]
```

---

There might be rendering artifacts if the sample layer is low:

```wl
In[1]:= Graphics3D[Raster3D[NumericArray[Import["ExampleData/CTengine.tiff", "Data"], "UnsignedInteger8"], Automatic, {0, 255}, ColorFunction -> "GrayLevelOpacity", Method -> {"SampleLayers" -> 100}], ImageSize -> 300]

Out[1]= [image]
```

### Neat Examples (4)

Visualize a Menger sponge:

```wl
In[1]:=
spongeArray[n_] := Nest[ArrayFlatten[Replace[#, {
	1 -> {{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}, {{1, 0, 1}, {0, 0, 0}, {1, 0, 1}}, {{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}}, 
	0 -> Table[0, {3}, {3}, {3}]}, {3}], 3]&, {{{1}}}, n]

In[2]:= showSponge[n_] := Graphics3D[{Raster3D[spongeArray[n], Automatic, {-.03, 1}, ColorFunction -> "GrayLevelOpacity"]}]

In[3]:= showSponge[#]& /@ {2, 3, 4}

Out[3]= {[image], [image], [image]}
```

---

Visualize cellular automata:

```wl
In[1]:= Graphics3D[{Raster3D[NumericArray[Last[CellularAutomaton[{#, {2, 1}, {1, 1, 1}}, {{{{1}}}, 0}, {{60}}]] * 100 + 25, "UnsignedInteger8"], {{0, 0, 0}, {1, 1, 1}}, {0, 255}]}]& /@ {6, 14, 26}

Out[1]= [image]
```

---

Visualize fonts in 3D space:

```wl
In[1]:= Graphics3D[{Raster3D[{Rasterize[ExpressionCell[Style["Hello", 80, Red], "Output", Background -> None], "Data", Background -> None]}, {{0, 1, 0.4}, {1, 0, 0.6}}, Method -> {"InterpolateValues" -> True}]}, PlotRange -> {0, 1}, ViewPoint -> {-1.54, 0.35, 3}, ViewVertical -> {-0.23, 0.86, 0.46}]

Out[1]= [image]
```

---

Light an image with many colored spotlights:

```wl
In[1]:= lights = {PointSize[Large], Yellow, Point[Tuples[{-1, 1}, 3]]};lighting = ({"Spot", Hue[RandomReal[]], #, {Pi / 12, 8}}& /@ Tuples[{-1, 1}, 3]);

In[2]:= Graphics3D[{lights, Specularity[White, 6], Raster3D[Import["ExampleData/CThead.tiff", "Data"], {{-1, -1, -1}, {1, 1, 1}}, {0, 255}, ColorFunction -> "GrayLevelOpacity", Method -> {"VolumeLighting" -> True, "InterpolateValues" -> True}]}, Lighting -> lighting, ViewPoint -> {-0.7, 2.8, 0.2}]

Out[2]= [image]
```

## See Also

* [`Image3D`](https://reference.wolfram.com/language/ref/Image3D.en.md)
* [`Raster`](https://reference.wolfram.com/language/ref/Raster.en.md)
* [`Graphics3D`](https://reference.wolfram.com/language/ref/Graphics3D.en.md)
* [`Cuboid`](https://reference.wolfram.com/language/ref/Cuboid.en.md)

## Related Guides

* [Graphics Objects](https://reference.wolfram.com/language/guide/GraphicsObjects.en.md)

## History

* [Introduced in 2012 (9.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn90.en.md) \| [Updated in 2016 (11.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn110.en.md) ▪ [2019 (12.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn120.en.md)