PostFx SMAA Anti-Aliasing
Enhanced Subpixel Morphological Anti-Aliasing (SMAA) post-processing effect. Three-pass pipeline: edge detection, blending weight calculation, and neighborhood blending.
Enhanced Subpixel Morphological Anti-Aliasing (SMAA) post-processing effect. Three-pass pipeline: edge detection, blending weight calculation, and neighborhood blending.
Overview
Declarative setup script (no M module). Registers a 3-pass SMAA pipeline:
- Edge Detection - Finds edges using luma/color differences
- Blending Weight - Calculates blend weights using area/search lookup textures
- Neighborhood Blending - Final anti-aliased composite
Scene Objects
| Object | Type | Description |
|---|---|---|
SMAA_StateBlock | GFXStateBlockData | 3 linear clamp samplers |
SMAA_EdgeDetectionShaderData | ShaderData | Edge detection pass |
SMAA_BlendingWeightShaderData | ShaderData | Blending weight calculation |
SMAA_NeighborhoodBlendingShaderData | ShaderData | Final neighborhood blend |
SMAA_PostEffect | PostEffect | Root (edge detection), disabled by default |
SMAA_PostEffect1 | PostEffect | Blending weight child |
SMAA_PostEffect2 | PostEffect | Neighborhood blending child |
Global Callbacks
| Global | Callback | Description |
|---|---|---|
SMAA_PostEffectCallbacks | onEnabled() | Disables FXAA_PostEffect (mutual exclusion) |
SMAA_PostEffectCallbacks | preProcess() | Updates SMAA_RT_METRICS shader macro when render target size changes |
Pipeline
$backBuffer → Edge Detection → Blending Weight (+ AreaTex + SearchTex) → Neighborhood Blend → $backBufferLookup Textures
-- Pre-computed lookup textures for blending weight calculation
smaaPostEffect1:setField("texture", 1, "shaders/common/postFx/smaa/AreaTexDX9.dds")
smaaPostEffect1:setField("texture", 2, "shaders/common/postFx/smaa/SearchTex.dds")Resolution Tracking
The preProcess callback dynamically updates the SMAA_RT_METRICS macro when resolution changes:
local rtSize = smaaPostEffect:getRenderTargetSize()
local rtResolution = string.format("float4(1.0 / %d, 1.0 / %d, %d, %d)",
rtSize.x, rtSize.y, rtSize.x, rtSize.y)
smaaPostEffect:setShaderMacro("SMAA_RT_METRICS", rtResolution)Notes
- Mutually exclusive with FXAA - enabling SMAA disables FXAA and vice versa
- All passes clear their targets on draw (
PFXTargetClear_OnDraw) - Renders after diffuse (
PFXAfterDiffuse) preProcess()is called once at load time after object creation- Shader pixel version 5.0
See Also
- PostFx FXAA - Alternative anti-aliasing (mutually exclusive)
- PostFx Utils - Preset management
Advanced Lighting - Shadow Visualization
Provides a shader and custom material for visualizing shadow maps in the editor/debug views.
PostFx SSAO (Screen-Space Ambient Occlusion)
Dual-radius screen-space ambient occlusion effect. Provides small-radius detail occlusion and large-radius contact shadows with configurable quality levels.