Sample Element Texture node
Note
Use this node only in shaders with Material set to UI for UI Toolkit. Using it elsewhere can lead to unexpected behavior or errors. For information on how to create shaders for UI Toolkit, refer to UI Shader Graph.
The Sample Element Texture node samples a texture at specific UV coordinates. You can use this node to get multiple samples of the texture assigned to the element, for example to create complex visual effects or manipulate the texture.
Sampling multiple times with this node is more efficient than using several separate nodes for individual samples. This is because each node introduces overhead by traversing internal branches to select the correct texture slot. By combining multiple samples into a single node, you reduce this overhead and improve performance. Use the Sample Count setting to control how many samples the node takes.
Limitations
With its default settings, this node can only connect to a Block node in the Fragment Context of a Shader Graph. To sample a Texture for the Vertex Context of a Shader Graph, set the Mip Sampling Mode to LOD.
Ports
The node has a pair of UV input and Color output ports for each sample. The number of pairs matches the Sample Count setting, and the ports are numbered from 0 to Sample Count − 1. By default, the node has four samples (UV 0 to UV 3 and Color 0 to Color 3).
| Name | Direction | Type | Description |
|---|---|---|---|
| UV n | Input | Vector2 | The UV coordinates for sample n. |
| Sampler | Input | Sampler State | The Sampler State to use when sampling. If you leave this port unconnected, the node uses the element texture's own sampler. |
| LOD | Input | Float | The mip level to sample. This port only appears when Mip Sampling Mode is LOD. |
| Color n | Output | Color | The color sampled at UV n. |
Additional node settings
The Sample Element Texture node has some additional settings that you can access from the Graph Inspector:
| Name | Description |
|---|---|
| Sample Count | The number of samples the node takes, between 1 and 32. The node displays one UV input port and one Color output port per sample. |
| Mip Sampling Mode | Controls how the node selects the texture mip level. The options are:
|