DreamShaderLang
Plugin referenceParameters

SamplerType

SamplerType

SamplerType

DreamShader » Parameters » SamplerType

The metadata key that sets how a texture node interprets its texture: EMaterialSamplerType on the generated UMaterialExpressionTextureBase subclass.

Declared in.dsm, .dsf — a [ … ] metadata block on a texture-valued Properties declaration
Kindmetadata key
Generatesa write to SamplerType on the generated node
Since1.2.4

Synopsis

<texture-token> <name> [ = <default> ] [ SamplerType = "<value>" [ ; <entry> … ] ] ;

(since 2.0.0) SamplerType has a path of its own on a declaration: on a compact texture token or TextureObjectParameter it becomes the 2.0 /// @sampler directive, a SAMPLERTYPE_ prefix removed, and is resolved by the emitter's enum-literal matcher (DSH8235 when nothing matches; an empty value is DSH7222). On a texture-sample token, which is expanded at its uses, it is an argument of the reflected node, checked against the engine catalog when the source is bound.

Applicable to every declaration whose generated node derives from UMaterialExpressionTextureBase:

DeclarationNodeSamplerType applies
Texture2D / TextureCube / Texture2DArray / Texture3D / VolumeTextureTextureObjectParameteryes
const Texture2D and the other four compact texture tokensTextureObjectyes
TextureObjectParameterTextureObjectParameteryes
TextureSampleParameter2D … TextureSampleParameterSubUVthe matching sample parameteryes
RuntimeVirtualTextureSampleParameter, SparseVolumeTextureSampleParameter—no — these classes have no SamplerType (DSH5213)
SpriteTextureSampler, TextureCollectionParameter, SparseVolumeTextureObjectParameter—the token has no 2.0 form (DSH3253)

Values

17 values. Each row is one enumerator; all four spellings in the row select it, and the comparison strips spaces, _, -, :, . and / and ignores case — so "linear color", "Linear-Color" and "linearcolor" are the same value as LinearColor.

ValueEnum constantFully qualifiedDisplayName spelling
ColorSAMPLERTYPE_ColorEMaterialSamplerType::SAMPLERTYPE_ColorColor
GrayscaleSAMPLERTYPE_GrayscaleEMaterialSamplerType::SAMPLERTYPE_GrayscaleGrayscale
AlphaSAMPLERTYPE_AlphaEMaterialSamplerType::SAMPLERTYPE_AlphaAlpha
NormalSAMPLERTYPE_NormalEMaterialSamplerType::SAMPLERTYPE_NormalNormal
MasksSAMPLERTYPE_MasksEMaterialSamplerType::SAMPLERTYPE_MasksMasks
DistanceFieldFontSAMPLERTYPE_DistanceFieldFontEMaterialSamplerType::SAMPLERTYPE_DistanceFieldFontDistance Field Font
LinearColorSAMPLERTYPE_LinearColorEMaterialSamplerType::SAMPLERTYPE_LinearColorLinear Color
LinearGrayscaleSAMPLERTYPE_LinearGrayscaleEMaterialSamplerType::SAMPLERTYPE_LinearGrayscaleLinear Grayscale
DataSAMPLERTYPE_DataEMaterialSamplerType::SAMPLERTYPE_DataData
ExternalSAMPLERTYPE_ExternalEMaterialSamplerType::SAMPLERTYPE_ExternalExternal
VirtualColorSAMPLERTYPE_VirtualColorEMaterialSamplerType::SAMPLERTYPE_VirtualColorVirtual Color
VirtualGrayscaleSAMPLERTYPE_VirtualGrayscaleEMaterialSamplerType::SAMPLERTYPE_VirtualGrayscaleVirtual Grayscale
VirtualAlphaSAMPLERTYPE_VirtualAlphaEMaterialSamplerType::SAMPLERTYPE_VirtualAlphaVirtual Alpha
VirtualNormalSAMPLERTYPE_VirtualNormalEMaterialSamplerType::SAMPLERTYPE_VirtualNormalVirtual Normal
VirtualMasksSAMPLERTYPE_VirtualMasksEMaterialSamplerType::SAMPLERTYPE_VirtualMasksVirtual Mask
VirtualLinearColorSAMPLERTYPE_VirtualLinearColorEMaterialSamplerType::SAMPLERTYPE_VirtualLinearColorVirtual Linear Color
VirtualLinearGrayscaleSAMPLERTYPE_VirtualLinearGrayscaleEMaterialSamplerType::SAMPLERTYPE_VirtualLinearGrayscaleVirtual Linear Grayscale

There is no virtual counterpart for DistanceFieldFont or External.

[!NOTE] On a texture-sample token the value is checked against the 17 enumerator names the engine catalog lists (since 2.0.0). A spelling that normalizes to one of them (SAMPLERTYPE_Normal, linear color) is accepted with a DSH5278 warning; a DisplayName that is not also an enumerator name — Virtual Mask — is DSH5215. On a declaration all four spellings work.

[!NOTE] The enumerator list ends with the sentinel SAMPLERTYPE_MAX. It carries no Hidden metadata, so on a declaration [SamplerType="SAMPLERTYPE_MAX"] and [SamplerType="MAX"] resolve rather than erroring, and write a value that is not a sampler type. It is not a usable value. The catalog a texture-sample token is checked against does not list it (DSH5215).

Inference and override order

StepWhat happens
1The node is created and its texture asset is assigned — from = Path(…), from the engine fallback asset for the declared dimension, or by SetDefaultTexture() for a sampler parameter with no asset
2If the source gives no SamplerType, AutoSetSampleType() derives one from the assigned texture's compression settings and sRGB flag
3If it does, that value is written

An explicit SamplerType always wins: the inference does not run at all on a node that has one. Omitting the key means the value follows the asset — which changes if the asset's compression settings change.

[!NOTE] The decompiler always emits SamplerType explicitly, even when it equals the inferred value, so a UMaterial → .dsm → UMaterial round trip does not drift when an asset is later recompressed.

SamplerSource

The companion key on UMaterialExpressionTextureSample subclasses — which sampler state the sample uses. It applies to the texture-sample tokens only, so its value is checked against the catalog as above.

ValueEnum constantDisplayName spellingMeaning
FromTextureAssetSSM_FromTextureAssetFrom texture assetTake the sampler from the texture; consumes one of the shader's limited sampler slots
Wrap_WorldGroupSettingsSSM_Wrap_WorldGroupSettingsShared: WrapShared sampler, wrap addressing, filter from the world texture group; consumes no slot
Clamp_WorldGroupSettingsSSM_Clamp_WorldGroupSettingsShared: ClampShared sampler, clamp addressing, filter from the world texture group; consumes no slot
TerrainWeightmapGroupSettingsSSM_TerrainWeightmapGroupSettings—Not selectable — tagged UMETA(Hidden), and not in the catalog

The default is FromTextureAsset. Write the enumerator name — [SamplerSource="Wrap_WorldGroupSettings"]; SSM_Wrap_WorldGroupSettings is accepted with DSH5278. The display names Shared: Wrap and Shared: Clamp normalize to nothing in the catalog and are DSH5215 (since 2.0.0; 1.x accepted them).

These are the keys the decompiler emits on every texture-sample parameter, with the value it treats as the default. All are ordinary reflected metadata.

KeyTypeDefault
SamplerTypeEMaterialSamplerTypederived from the asset
SamplerSourceESamplerSourceModeFromTextureAsset
MipValueModeETextureMipValueModeNone
GatherMode (since UE 5.6)enumNone
AutomaticViewMipBiasbooltrue
ConstCoordinateuint80
ConstMipValueint32-1
IsDefaultMeshpaintTextureboolfalse
SortPriorityint3232

MipValueMode is the one key that changes the node's pin names, and therefore which names the call form can match on the live node.

Dimension validation and inference

SamplerType describes interpretation; the texture's dimension is a separate check.

DeclarationDeclares a dimensionWhat is checked
Texture2D, TextureCube, Texture2DArray, Texture3D, VolumeTextureyesa Class'…' shell of another dimension (DSH1044); the loaded asset is not checked (since 2.0.0)
const forms of the same five tokensyesas above
TextureObjectParameternothe dimension is taken from the loaded asset
TextureSampleParameter2D / 2DArray / Cube / Volume / SubUVyes, from the token's suffixthe shell, as for a compact token
TextureSampleParameterCubeArraynoonly that a shell names a texture (DSH1043)

TextureObjectParameter's dimension is read off the asset its default loads: UTextureCube → TextureCube, UTexture2DArray → Texture2DArray, UVolumeTexture → VolumeTexture, anything else — or a default that does not load — Texture2D.

[!WARNING] A TextureSampleParameterCube pointed at a 2D texture by its plain object path generates cleanly and fails later inside Unreal's shader compiler. See Parameter node tokens.

Diagnostics

CodeRaised when
DSH8235a declaration's SamplerType matches no enumerator under any of the four spellings
DSH7222a declaration's SamplerType is empty
DSH5215a texture-sample token's SamplerType or SamplerSource is no enumerator the catalog lists
DSH5278a texture-sample token's value is a 1.x spelling of an enumerator (warning)
DSH5213the node class has no SamplerType (or no SamplerSource)
DSH1043 / DSH1044a texture default's Class'…' names a non-texture / a texture of another dimension

Example

Shader(Name="Docs/M_SamplerType")
{
    Properties = {
        // Explicit: linear data, shared sampler, no slot consumed.
        TextureSampleParameter2D MaskMap = Path(Game, "Textures/T_Mask") [
            SamplerType   = "LinearColor";
            SamplerSource = "Wrap_WorldGroupSettings";
            MipValueMode  = "None";
        ];

        // Inferred: SamplerType follows the asset's compression settings.
        TextureSampleParameter2D BaseMap = Path(Game, "Textures/T_Base");

        // A 1.x spelling: accepted, with DSH5278.
        TextureSampleParameterCube Env = Path(Engine, "EngineResources/DefaultTextureCube") [
            SamplerType = "linear color"
        ];

        const Texture2D Lut = Path(Game, "Textures/T_Lut") [SamplerType = "Data"];
    }

    Settings = { Domain = "Surface"; ShadingModel = "DefaultLit"; BlendMode = "Opaque"; }
    Outputs  = { vec3 Color; Base.BaseColor = Color; }

    Graph = {
        vec2 UV = UE.TexCoord(Index = 0);
        vec4 B  = BaseMap(Coordinates = UV);
        vec4 M  = MaskMap(Coordinates = UV);
        Color = B.rgb * M.r;
    }
}

Applied values:

MaskMap  SamplerType = SAMPLERTYPE_LinearColor  SamplerSource = SSM_Wrap_WorldGroupSettings
BaseMap  SamplerType = <AutoSetSampleType from /Game/Textures/T_Base>
Env      SamplerType = SAMPLERTYPE_LinearColor  ("linear color" normalizes to LinearColor; DSH5278)
Lut      SamplerType = SAMPLERTYPE_Data         on a TextureObject (const) node

Env and Lut are applied when a body reads them; this Graph does not, so they build nothing.

See also

On this page