Blend & Sampler States
Blend states
Section titled “Blend states”Set the blend mode in begin():
import { BlendState } from 'webgpu-spritebatch'
batch.begin({ blendState: BlendState.additive })| Preset | Description |
|---|---|
BlendState.alphaBlend | Standard alpha blending (default) |
BlendState.additive | Additive blending — great for glow and particles |
BlendState.opaque | No blending — source overwrites destination |
BlendState.premultipliedAlpha | For pre-multiplied alpha textures |
Sampler states
Section titled “Sampler states”Set the texture filtering/wrapping in begin():
import { SamplerState } from 'webgpu-spritebatch'
batch.begin({ samplerState: SamplerState.pointClamp })| Preset | Description |
|---|---|
SamplerState.linearClamp | Bilinear filtering, clamp to edge (default) |
SamplerState.linearWrap | Bilinear filtering, repeat/wrap |
SamplerState.pointClamp | Nearest-neighbor, clamp to edge (pixel art) |
SamplerState.pointWrap | Nearest-neighbor, repeat/wrap |
Combining them
Section titled “Combining them”A common pattern for pixel-art rendering:
batch.begin({ samplerState: SamplerState.pointClamp, blendState: BlendState.alphaBlend, sortMode: 'frontToBack', effect: SpriteEffect.alphaCutout,})