Previous Object Programming: Advanced Rendering Using Shader Objects Next

About Shaders

The shader functionality implemented in IDL object graphics provides access to the advantages of the hardware-based OpenGL Shading Language (GLSL) features that are available on modern graphics cards. Using a shader, computationally intensive image processing operations can be off-loaded to the graphics card, making the time and processing resources of the host computer available to other application elements. Additionally, the OpenGL Shading Language greatly expands on the capabilities of the fixed OpenGL rendering pipeline to produce advanced visual effects. Whereas native IDL object graphics expose OpenGL capabilities through fixed object properties, GLSL offers the ability to modify virtually any object characteristic. Using shaders lets you implement realistic material and lighting effects, create animations by modifying object vertices, and achieve image processing performance rates that far exceed what is possible using the system CPU.

It is important to realize that this functionality only exposes the ability to use OpenGL Shading Language within an IDL application. It does not implement the shading language nor does this document explain how to write shader language code. However, numerous GLSL publications and internet resources are available.

Why Use Shaders

Shaders are often used to produce elaborate scenes including realistic materials and lighting, especially in 3-D gaming environments. However, shaders also offer incredible performance and enhanced interactivity when used in image processing applications. Consider an application the applies the following operations to an image:

Using the system CPU as the primary processor in a software-based solution, it is only possible to achieve a display rate of a few frames per second. However, if a shader program is implemented, the processing is shifted to the graphics card GPU and display rates of over 100 frames per second are possible. The shader program applies these operations on every draw so there is no performance penalty for altering parameters during rapid drawing sequence. This means that a user can change a parameter of the operation and see the results nearly instantaneously, which makes the image processing application highly responsive to interactive changes. See How Shaders Enhance Performance for details.

Shaders also provide a means of solving a wider range of image processing problems than what is possible using only the fixed functionality of the OpenGL pipeline exposed by IDL procedures and functions. There are no limits to the image processing problems that you can solve using shaders other than those imposed by the shader itself and the boundaries of your imagination.

Hardware Requirements for Shaders

In general, shader programs will work on graphics cards and drivers that support the OpenGL 2.0 interface. However, it is important to note that performance varies greatly between low-end and high-end graphics cards, and also varies depending on the implementation and content of the shader program. Also, always use the most up-to-date drivers available for your graphics card when developing IDL applications that use shader programs.

Use the SHADING_LANGUAGE_VERSION keyword to IDLgrWindow::GetDeviceInfo to determine whether or not a card supports shader functionality.

A shader-equipped graphics card will not utilize the shader hardware if IDL is using software rendering. To make sure you are using the shading hardware, be sure to specify the hardware renderer (for example, set the IDLgrWindow RENDERER property to 0).

Image processing applications can provide a software-based alternative in case the system graphics card does not support OpenGL 2.0. See Providing a Software Alternative to Shaders for details.

If there is insufficient support for the shader program, IDL draws the scene as if there was no shader object present unless a software fallback exists.

Setting the IDLgrWindow property RETAIN to 2 disables hardware shaders. Software shaders are used if available.

  IDL Online Help (March 06, 2007)