mathe/Library/PackageCache/com.unity.shadergraph@14.0.8/Documentation~/Sample-Texture-3D-Node.md
2024-09-20 20:30:10 +02:00

4.3 KiB

Sample Texture 3D node

The Sample Texture 3D node samples a Texture 3D asset and returns a Vector 4 color value. You can specify the UV coordinates for a texture sample and use a Sampler State node to define a specific Sampler State.

For more information about Texture 3D assets, see 3D textures in the Unity User manual.

[!includenodes-sample-errors]

An image that displays the Graph window with a Sample Texture 3D node.

Create Node menu category

The Sample Texture 2D node is under the Input > Texture category in the Create Node menu.

Compatibility

The Sample Texture 3D [!includenodes-compatibility-all]

[!includenodes-sample-fragment-lod]

Inputs

The Sample Texture 3D [!includenodes-inputs]

[!include[nodes-sample-ss-table](./snippets/sample-nodes/nodes-sample-ss-table.md)] [!include[nodes-sample-lod-table](./snippets/sample-nodes/nodes-sample-lod-table.md)]
Name Type Binding Description
Texture Texture 3D None The 3D Texture asset to sample.
UV Vector 3 None The 3D UV coordinates to use to sample the Texture.

Additional node settings

The Sample Texture 3D [!includenodes-additional-settings]

Name Type Description
Mip Sampling Mode Dropdown Choose the sampling mode that the Sample Texture 3D node uses to calculate the mip level of the texture.
Standard The mip is calculated and selected automatically for the texture.
LOD Set an explicit mip for the texture. The texture will always use this mip, regardless of the DDX or DDY calculations between pixels. If the Mip Sampling Mode is set to LOD, you can connect the node to a Block node in the Vertex Context. For more information on Block nodes and Contexts, see Master Stack.

Outputs

The Sample Texture 3D [!includenodes-outputs]

[!includenodes-sample-rgba-output-table]

Example graph usage

In the following example, the Sample Texture 3D node samples a 3D fractal noise Texture asset. It takes its input UV coordinates from a Position node, set to Object Space.

The Sample Texture 3D node needs a Vector 3 for its UV coordinate input, rather than a Vector 2, because the Texture asset exists as a volume in imaginary 3D space. The node uses the default Sampler State because there is no Sampler State node connected.

This specific Texture 3D asset stores its Texture data in the Alpha channel, so the Sample Texture 3D node uses its A output port as an input for the Base Color Block node in the Fragment Context of the Master Stack:

An image of the Graph window, that displays a Position node connected to the UV input port on a Sample Texture 3D node. The Sample Texture 3D node's A output port connects to the Base Color Block node in the Fragment Context of the Master Stack.

Generated code example

[!includenodes-generated-code]:

float4 _SampleTexture3D_Out = SAMPLE_TEXTURE3D(Texture, Sampler, UV);

[!includenodes-related] Sample Texture 3D node: