Search public documentation:


Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > Materials & Textures > Shader Model 2 Fallback
UE3 Home > Graphics Programming > Shader Model 2 Fallback

Shader Model 2 Fallback

Document Changelog: Created by Daniel Wright.


UE3 no longer supports shader model 2 cards, as of cl 538899.


Basic support for Shader Model 2 cards was added in QA_APPROVED_BUILD_DEC_2006. The main changes were to add a fallback for lack of floating point blending on SM2 cards, add compatible global shaders and create a fallback material system.

As of QA_APPROVED_BUILD_FEB_2007, fallback materials are now exposed in the material editor, and GPU morph vertex factories are temporarily disabled.

In QA_APPROVED_BUILD_APR_2007 a DOFAndBloomGather fallback was implemented.

In QA_APPROVED_BUILD_OCT_2007 the SM2 Fallback was changed to use a LDR render target for scene color and has been greatly optimized.

In cl 538899, SM2 support was removed. This page persists for licensees on older versions.

Choosing Paths

The SM2 path will be used automatically on supporting hardware. On SM3 hardware, the SM2 path can be chosen by specifying the -forceshadermodel2 command-line argument after other parameters.



HDR in the SM2 pathway is handled differently than in the SM3 pathway, since no SM2 cards support alpha blending to floating point render targets. The BasePass of the World DPG is rendered to a floating point 'scratch' render target. HDR color is stored in rgb, and scene depth is stored in a. Immediately after the BasePass, scene color is copied to an LDR render target so that hardware blending can be used for the rest of the frame. Scene depth is still read from the scratch render target for the rest of the frame. The scene color render target is stored in linear space. This results in extreme banding in dark colors, but is necessary since no SM2 cards support alpha blending in linear space when the render target is in gamma space. The LDR scene color render target stores a luminance factor in its alpha channel which is used by the bloom post process effect. The luminance factor is just an approximation and can be very wrong, so it needs some tweaking to avoid excessive blooming.

Note that the LDR scene color pathway is almost 2x faster than the previous floating point blending emulation, mostly due to greatly reduced number of resolves.


Emulated Stages

In UE3, Scene Color is stored in a floating point format to allow for HDR colors. Currently all hardware that supports SM3 also supports floating point blending, (with the exception of some low end cards like the 6200) so blending to scene color is not a problem. On the other hand, no SM2 cards support blending to a floating point render target, although they all support rendering and sampling (but not filtering) from floating point targets. UE3 still uses HDR in the SM2 path, and performs floating point blending in the shader. Here is a comprehensive list of the emulated stages:

  • Height fog
  • Fog Volumes
  • Bloom effect (but not the combined versions)
  • All modulative shadows
  • Every light pass
  • Translucency

Translucency is the special case. It is now blended to an LDR buffer and combined with the HDR scene color in a final pass. This means that no translucency can emit colors with any components higher than 1, but the results of the combine with scene color can be higher than 1. As a result, objects viewed through a transparent surface (ie window) will not be as bright. Translucency also has less precision in this path and banding may occur for example on god rays. Another limitation of this method is that modulative blending is not supported at all, except on decals and modulative shadows (where it is known that there will only be one layer per draw call).

Performance implications

Performing floating point blending in the shader requires an extra texture lookup and some additional arithmetic instructions, which is a relatively small hit. Currently the output surface from the previous stage is copied to the input texture of the next stage, which happens after every light, modulated shadow and decal. This is very inefficient and has been optimized in QA_APPROVED_BUILD_OCT_2007.

Global shader fallbacks

  • No Branching PCF shaders are used in the SM2 path. The only capable shadow filtering shader does a 4 tap Uniform PCF, and uses Hardware PCF if supported.
  • The texture density viewmode is disabled in this path, as it requires screenspace gradient functions not available in PS2.0.
  • The shader complexity viewmode is disabled in this path.
  • DOFAndBloomGather does 16 point samples and then calculates bloom color off of the average, instead of calculating bloom color off of each sample and averaging. This results in visible aliasing but is necessary to fit the shader into 64 ALU instructions.

The other global shaders are used unchanged.

Material fallbacks

When compiling materials for shader model 2, each material is compiled unchanged. If this fails due to shader model restrictions, (over 64 ALU or 32 Tex instructions, texture dependency length greater than 4, etc) then the specular, normal, diffuse and emissive are dropped, one at a time, in that order, until the material compiles. This is called the automatic or generated fallback. Artists can override this process by specifying the Fallback Material, in which case the generation process will be skipped completely and the Fallback Material will be used on shader model 2 cards instead.