CG is NVIDIA's (relatively) high level graphics programming language. It stands for "C for Graphics", not the most clever acronym, but appropriate. Patterned after C, it provides a simple and (most importantly) standard interface to the Graphic Processing Units (GPU) on 3D cards.

Graphics cards have seen an incredible burst in development in the last five years. Initially, the goal was to be able to push as many polygons to the screen as possible. It wasn't long before graphics cards started drawing faster than the CPU could provide the information. So, the answer was to start off-loading some of the calculations previously performed by the CPU to the card. Simple operations such as calculating light intensities for surfaces were among the first things to be used in this way, but the potential was immediately recognized as being much greater than was being utilized.

Modern 3D cards allow you to send small batches of instructions for them to execute on the data they are working with. There are two types of processors in most modern 3D cards, vertex processors and fragment processors. Each modifies a different type of data. Vertex programs, run on the vertex processors, deal with the positions and characteristics of vertices defining the polygon (strip, mesh, etc). Fragment programs (or pixel programs or pixel shaders), run on the fragment processors, deal directly with pixels or texels. Vertex shaders could be used to quickly simulate a field of grass, with dynamically generated grass being processed by the card and rustling under a virtual wind. Pixel shaders could make it seem as though the light on the grass was being blocked by clouds overhead, which moved in chaotic patterns.

Each new generation of 3D card increases the maximum complexity of programs that the card can execute upon the data. However, writing these programs involves coding assembly level instructions. It's very slow and painstaking, hard to debug, and hard to modify. Prototyping new effects is ridiculously hard under such constraints. John Carmack, of id software, himself has stressed the importance of a higher level abstraction for dealing with the GPUs. There is currently a race between OpenGL, DirectX, and NVIDIA to get their own standards for this out and supported.

For NVIDIA, the benefits of winning this race are huge. Not all 3D cards support the same feature sets. Some cards will support some operations that are poorly, inefficiently, or simply not supported by others. CG handles this problem with what are called "Profiles". Currently, there are profiles for DirectX 8.0, OpenGL ARB, and three different unique profiles for NVIDIA cards. Get the picture? If you're developing with CG, you can use the common functionality provided by DirectX or OpenGL, and if your customer is using an NVIDIA card, they can get even flashier whiz-bang effects. The other card manufacturers will continually be playing catchup, writing their own support for CG, the language designed and updated by NVIDIA. They'll be more or less at the mercy of NVIDIA, who updates the language whenever they add a new feature to one of their own cards.

CG is structurally and syntactically very similar to C. It is clearly oriented for graphics programming, as the base types it supports include vectors of variable dimensions (up to four), and matrices of up to four rows by four columns as well. The common functions available within CG include matrix operations, texture lookups (currently only for NVIDIA cards, of course!), lerping, lighting calculation, and vector refraction as a few examples. It also supports the "if/then" structure, but as the current cards on the market can't loop over data, that's it for control structures.

The capabilities of the graphics cards on the market right now are hardly being tapped, largely because of the tremendous complexity and resources required to take full advantage of them. CG and other such abstracted graphics interface languages will change this dramatically. 3D worlds will become much less static, and realistic shadows and lighting are only the beginning.