BasicEffect.PreferPerPixelLighting Property

Gets or sets a value indicating that per-pixel lighting should be used if it is available for the current adapter. Per-pixel lighting is available if a graphics adapter supports Pixel Shader Model 2.0.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework.Graphics (in

public bool PreferPerPixelLighting { get; set; }

Property Value

true to use per-pixel lighting if it is available; false to disable per-pixel lighting. The default value is true. When PreferPerPixelLighting is true, if the graphics adapter does not support a minimum of Pixel Shader Model 2.0, BasicEffect will automatically fall-back to per-vertex lighting. When PreferPerPixelLighting is false, per-vertex lighting is used regardless of whether per-pixel lighting is supported by the graphics adapter.

There are two common types of real-time lighting used in games. Per-vertex lighting is where lighting contributions are determined at each vertex and then the results are interpolated across the triangle. Depending on how tessellated the mesh is, this can result in severe artifacts. Per-pixel lighting interpolates the per-vertex normal across the triangle, but calculates the contribution at each pixel, which results in much smoother lighting, particularly when a specular highlight falls between vertices.

Xbox 360, Windows 7, Windows Vista, Windows XP

Community Additions