s&box
RustCounter-Strike 2s&boxDeadlock
Wiki
Get s&box on Steam
Browse
OverviewGetting StartedCreating GamesEngine & ToolsDocumentationCommunity GamesResources
s&boxDocumentationRenderingShadersSampler States
SOURCE 2 · C#
Build and play games with s&box.

Facepunch's game engine and creation platform — make games in C#, or jump straight into community games.

Get s&box on Steam

s&box Wiki

  • Overview
  • Getting Started
  • Creating Games
  • Engine & Tools
  • Documentation
  • Community Games
  • Resources

Tools & Community

  • Getting Started
  • Creating Games
  • Engine & Tools
  • Resources

Platforms

  • RustBattle
  • CSBattle
  • Rust Game Wiki
  • CS2 Skins Wiki
  • Deadlock Wiki

About

  • Official Site
  • Developer Wiki
  • GitHub
  • Get on Steam
NOT AFFILIATED WITH FACEPUNCH STUDIOS · © 2026 s&box Wiki (community)
Docs/Rendering
Rendering

Sampler States

Sampler states control how textures are sampled in shaders, how they're filtered and addressed.

Modern GPUs allow binding of 128 textures in a shader, however you are limited to only 16 bound samplers. This is generally more than enough if you reuse samplers for multiple textures.

Sampler states are defined as you normally would in HLSL, but should be annotated with the desired options.

Texture2D MyCoolTexture;
Texture2D MyOtherCoolTexture;
SamplerState MyPixelySampler < Filter( Point ); >;

// Using the samplers
float4 color1 = MyCoolTexture.Sample( MyPixelySampler, uv );
float4 color2 = MyOtherCoolTexture.Sample( MyPixelySampler, uv );

Annotations

AnnotationDescriptionPossible Values
FilterFiltering mode used for texture sampling.Point, Bilinear, Trilinear, Anisotropic, see Filters section for more
AddressUTexture coordinate addressing mode for the U direction.Wrap, Mirror, Clamp, Border, Mirror_Once
AddressVTexture coordinate addressing mode for the V direction.Wrap, Mirror, Clamp, Border, Mirror_Once
AddressWTexture coordinate addressing mode for the W direction.Wrap, Mirror, Clamp, Border, Mirror_Once
MaxAnisoMaximum anisotropy level allowed for anisotropic filtering.Integer value (e.g., 2, 4, 8, 16, etc.)

Address Modes

Address mode affects how texture sampling is handled outside of 0-1 UV range.

Address ModeDescription
WrapRepeats the texture infinitely
ClampExtrudes the edges of texture infinitely
BorderSimply cuts off everything outside of 0-1 range
MirrorRepeats the texture infinitely, but each repeat is mirrored
Mirror_OnceRepeats and mirrors the texture, but only once, and only in one direction, otherwise it's clamped

Filters

EnumDescription
PointSame as MinMagMipPoint
NearestSame as MinMagMipPoint
BilinearSame as MinMagLinearMipPoint
TrilinearSame as MinMagMipLinear
AnisotropicAnisotropic filtering, controlled by MaxAniso
AnisoSame as Anisotropic
MinMagMipPointMinify/magnify/mipmap using point sampling.
MinMagPointMipLinearMinify/magnify using point sampling, mipmap using linear interpolation.
MinPointMagLinearMipPointMinify using point sampling, magnify using linear sampling, mipmap using point sampling.
MinPointMagMipLinearMinify using point sampling, magnify using linear sampling, mipmap using linear interpolation.
MinLinearMagMipPointMinify using linear interpolation, magnify using point sampling, mipmap using point sampling.
MinLinearMagPointMipLinearMinify using linear interpolation, magnify using point sampling, mipmap using linear interpolation.
MinMagLinearMipPointMinify/magnify using linear sampling, mipmap using point sampling.
MinMagMipLinearMinify/magnify/mipmap using linear interpolation.
ComparisonMinMagMipPointComparison minify/magnify/mipmap using point sampling.
ComparisonMinMagPointMipLinearComparison minify/magnify using point sampling, mipmap using linear interpolation.
ComparisonMinPointMagLinearMipPointComparison minify using point sampling, magnify using linear sampling, mipmap using point sampling.
ComparisonMinPointMagMipLinearComparison minify using point sampling, magnify using linear sampling, mipmap using linear interpolation.
ComparisonMinLinearMagMipPointComparison minify using linear interpolation, magnify using point sampling, mipmap using point sampling.
ComparisonMinLinearMagPointMipLinearComparison minify using linear interpolation, magnify using point sampling, mipmap using linear interpolation.
ComparisonMinMagLinearMipPointComparison minify/magnify using linear sampling, mipmap using point sampling.
ComparisonMinMagMipLinearComparison minify/magnify/mipmap using linear interpolation.
ComparisonAnisotropicComparison anisotropic filtering.

Here are some common predefined sampler states you can use in your shaders.

Sampler StateDescription
g_sAnisoAnisotropic filtering with a maximum anisotropy level of 8.
g_sBilinearClampBilinear filtering with texture coordinate addressing mode set to clamp for U, V, and W directions.
g_sBilinearWrapBilinear filtering with texture coordinate addressing mode set to wrap for U, V, and W directions.
g_sBilinearMirrorBilinear filtering with texture coordinate addressing mode set to mirror for U, V, and W directions.
g_sTrilinearWrapTrilinear filtering with texture coordinate addressing mode set to wrap for U, V, and W directions.
g_sTrilinearClampTrilinear filtering with texture coordinate addressing mode set to clamp for U, V, and W directions.
g_sTrilinearMirrorTrilinear filtering with texture coordinate addressing mode set to mirror for U, V and W directions.
g_sTrilinearBorderTrilinear filtering with texture coordinate addressing mode set to border for U, V and W directions.
g_sPointClampPoint filtering with texture coordinate addressing mode set to clamp for U, V, and W directions.
g_sPointWrapPoint filtering with texture coordinate addressing mode set to wrap for U and V directions
g_sPointMirrorPoint filtering with texture coordinate addressing mode set to mirror for U and V directions

:::warning CreateTexture2D & Tex2D macros create and sample coupled textures and samplers, this is how it worked for older graphics APIs (DX9) and should be avoided due to it's limitations.

:::

Source: Facepunch/sbox-docs (CC-BY-4.0) · updated 2026-06-19. Read it rendered on the official docs.

More in Rendering

AmbientLight
Animated Effects
Attributes and Variables
BeamEffect
Beams
Bindless API
C# Shader Nodes
Classes
← All documentation

Community wiki — not affiliated with Facepunch Studios. For the latest and most authoritative information, see the official developer wiki.