It wasn't possible to define a SamplerState
from C# which forced users to create workarounds. You can now define one and use the Attributes
API to pass it to your shader. This is also available on the CommandList
API.
Shader
SamplerState mySampler < Attribute( "mySampler" ); >;
C#
var anisotropicSampler = new SamplerState
{
Filter = FilterMode.Anisotropic,
AddressU = AddressMode.Wrap,
AddressV = AddressMode.Wrap,
AddressW = AddressMode.Clamp,
MipLodBias = 0.0f,
MaxAnisotropy = 16
};
var pointSampler = sampler with { Filter = FilterMode.Point };
Graphics.Attributes.Set( "mySampler", pointSampler);