What is a “pixel shader”?

I have noticed that some games quote the requirement for “pixel shader 3.0 or better”.

What is a pixel shader and is it some software requirements or hardware requirements?

Answer

Simple answer

Pixel shaders are tiny programs that can do operations on a single pixel on the screen, as opposed to geometry shaders and vertex shaders which work on the geometrical primitives (triangles) that make up everything you see on the screen. The most common use for pixel shaders is ‘shading’, approximation to real world lighting. Commonly used shading model is Phong.

Pixel shaders are executed on your video card, so your video card needs to support them. Each new version provides more capabilities, so an older video card will not run newer shaders. A new version of the pixel shader specification (e.g. Pixel Shader 3.0) is usually released for each new version of DirectX (more accurately, Direct3D).

Software Requirements

You need to have the correct version of Direct3D (or OpenGL) installed in order to use the shaders. For example, Pixel Shader 4.0 requires at least Direct3D 10. Normally you don’t have to worry about this, every game that uses Direct3D will install the correct version for you when you install the game. The only exceptions are Direct3D 10 and later, which will not run on Windows XP or earlier. You will need at least Windows Vista in order to play a game that uses Direct3D 10 or 11.

Wikipedia provides a nice list of Pixel Shader versions, the version of Direct3D you need, and the types of graphics cards that work with them.


Technical answer

The ‘standard’ stages of a 3D rendering pipeline are as follows (somewhat simplified):

  • Transformation (Moving, rotating and scaling all the objects in the scene)
  • Lighting
  • Projection (‘Squashing’ the 3D world into a 2D plane)
  • Clipping (Removing anything outside the field of view)
  • Rasterising (Converting the vector graphics (triangles, etc) into raster graphics (pixels))
  • Texturing
  • Display

Pixel Shaders are used as an alternative to the standard texturing phase. During rasterisation, each triangle is converted into pixels. These pixels do not have their final colour yet, but the do have a bunch of parameters associated with them. These include base colour, texture coordinates, lighting information, etc. The Pixel Shader is a small program that takes these parameters and uses them to calculate the final colour as it is displayed on the screen. The Pixel Shader has access to all texture data, and can use them to do interesting things such as blending two textures (to create a ‘dirty’ look), using a texture as a bump map (to simulate a relief), or to simulate reflections.

Hardware

On the hardware side, Pixel Shaders are executed on ‘Shader Units‘, small processors on your GPU. Each Shader Unit is basically a very simple CPU, but a modern video card may contain thousands of these things (an AMD Radeon HD6990 contains over 3000). Older GPUs had different Shader Units for different tasks: Pixel Shaders were executed on different parts of the system than Vertex Shaders. Modern GPUs have so called ‘unified shader units‘ which can perform all of these operations.

Attribution
Source : Link , Question Author : Sisir , Answer Author : Community

Leave a Comment