docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Sample Texture2D

    Menu Path : Operator > Sampling > Sample Texture2D

    The Sample Texture2D Operator samples a Texture2D for a specified UV and Mip level. This Operator uses the same Filter Mode and Wrap Mode as the input texture’s import settings.

    This translates to a Sample() call on the texture in High-Level Shading Language (HLSL). For information on the differences between loading and sampling, see Loading and sampling.

    Loading and sampling

    In the Visual Effect Graph, there are multiple Operators that can read texel values from a texture. In the underlying (HLSL), some of them use Load() and others use Sample().

    The differences between the Operators that use Load() and Operators that use Sample() is as follows:

    • Load() does not apply any filtering to the final texel value whereas Sample() uses the same Filter Mode as the target Texture's import settings.
    • Load() does not apply any wrapping and instead returns 0 for coordinates that specify a texel outside the texture. Sample() uses the same Wrap Mode as the target Texture's import settings.
    • Load() uses texel coordinates (in the range of 0 to the texture's width/height minus 1) whereas Sample() uses UV coordinates (in the range of 0-1).

    Operator properties

    Input Type Description
    Texture Texture2D The texture this Operator samples from.
    UV Vector2 The UV to samples the Texture at.
    Mip Level float The mip level to read from.
    Output Type Description
    s Vector4 The sampled value from the texture

    Limitations

    This Operator only runs on the GPU, therefore it does not work when plugged into Spawner Context ports.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)