Windows Phone 7 Shaders Cheat Sheet

While Windows phones 7 hardware includes a graphics chip that allows truely programable shaders (one of Adreno 205, 220, 225),  XNA 4.0 for WP7 accomodates for only five canned shaders:

  • BasicEffect (lighting with a single texture)
  • DualTextureEffect (base texture modulate 2x with overlay texture, no lighting)
  • EnvironmentMapEffect (Overlay cube map on base texture)
  • AlphaTestEffect (useful for render targets and multiple passes)
  • SkinnedEffect (mesh animation, not discussed here)

These effects expose what was available to most graphics chipsets with fixed function hardware, but with render targets and multiple passes some nice results can be achieved.

The msdn documentation splits the properties available for each effect over five classes with no real overview. Fuctionality exposed is as follows:

Property Description / DataType Basic Dual AlphaTest EnvMap
LightingEnabled bool X     X
PreferPerPixelLighting bool X      
AmbientLightColor Vector3 X     X
SpecularColor  Vector3 X      
SpecularPower  float X      
EmissiveColor Vector3 X     X
DirectionalLight0.Direction Vector3 X     X
DirectionalLight0.DiffuseColor Vector3 X     X
DirectionalLight0.SpecularColor Vector3 X     X
DirectionalLight0.Enabled bool X     X
DirectionalLight1 as per DirectionalLight0 X     X
DirectionalLight2 as per DirectionalLight0 X     X
TextureEnabled bool X      
VertexColorEnabled bool X X X  
Texture (base) Texture2D X X X X
Texture2 (overlay modulate 2x) Texture2D   X    
DiffuseColor Vector3 (when texture disabled?) X X X X
Alpha float (1 opaque 0 transparent) X X X X
ReferenceAlpha float     X  
AlphaFunction CompareFunction (never, greater, less, …)     X  
EnvironmentMap TextureCube       X
EnvironmentMapAmount float       X
EnvironmentMapSpecular float       X
FogEnabled bool X X X X
FogColor Vector3 X X X X
FogStart float X X X X
FogEnd float X X X X
View Matrix.CreateLookAt() X X X X
Projection Matrix.CreatePerspectiveFieldOfView() X X X X
World Matrix X X X X


VertexElementUsage Accepted DataType Basic Dual AlphaTest EnvMap
Position Vector3 X X X X
Normal Vector3, NormalizedShort4 X     X
Color Vector3, NormalizedShort4 X X X  
TextureCoordinate (0) Vector3, NormalizedShort4, UsageIndex 0 X X X X
TextureCoordinate (1) Vector3, NormalizedShort4, UsageIndex 1 X     X


More indepth documentation of WP7 shaders can be found at codeproject