Summary: Today NVIDIA has unveiled a new programming language solely for graphics: Cg. Find out more about Cg and its possible ramifications for the graphics world in our preview of this technology.
Accelerating the convergence of film and real-time rendering
Up until now, game developers have had to use complex assembly language to create the lifelike graphics gamers experience in today’s latest games. The programming skills required to truly bring these games to life are only possessed by a select group of programmers and requires an extensive amount of time and patience to be done properly. In today’s fast-paced world, game developers are often placed under intense time constraints, while others lack the resources to bring in top-notch talent. With economic pressure continuing to hamper game developers while the complexity of modern graphics also continues to increase, life in the game development field has never been tougher. In an attempt to alleviate some of the pressure on 3D content developers, NVIDIA has been working behind closed doors on its Cg graphics programming language.
In today’s programming environment, programmers are forced to code directly to the hardware itself. As we discussed earlier, this is done in low-level assembly code. Cg replaces the abstract assembly code with more familiar syntax that resembles a programming language all programmers are familiar with: C. As a result, a graphics effect that once took dozens (or even hundreds) of lines of code has been simplified to only a handful of lines.
The illustrations above highlight the difference between assembly and Cg for content creation developers. As you can see Cg has simplified the process of bringing objects to life substantially. If you were a programmer, which language would you prefer to code in?
SIDEBAR: “Cg will do for GPUs what C and C++ did for CPUs”
-Jen Hsun Huang, CEO NVIDIA Corporation
If the language itself is the nuts and bolts of the Cg programming environment, the Cg compiler is the heart and soul that makes it all happen. Once the program is written, the compiler can output code for DirectX or OpenGL. Since Cg is designed specifically for vertex and pixel shader programs, DirectX versions 8 and 9 are supported as well as OpenGL 1.4. The compiler itself is cross platform; in particular programs written for Windows, Linux, Macintosh, and Xbox are supported. And if all that isn’t enough, the compiler can create code for all GPUs that support DirectX 8 (or above) and/or OpenGL 1.4, making it very universal. In keeping with Linux tradition, NVIDIA has open-sourced certain components of the compiler, allowing content developers to add their own customizations as well.
Like NVIDIA’s unified driver architecture, the Cg compiler employs a unified compiler architecture that is forward and backward compatible with today’s current and tomorrow’s next generation of graphics cores. As a result, once the program is written, the compiler will automatically optimize the program for multiple generations of graphics chips with no intervention from the programmer – the days of optimizing for one particular graphics core (future or present) are gone.
The final components of the Cg toolkit are the Cg browser (a graphics interface for creating and modifying objects), the Cg standard library (a set of built-in functions dedicated to help the programmer with common computations), and a collection of pre-written Cg shaders that can be used for development as well as training.
SIDEBAR: The Cg toolkit is currently in beta; the gold release is scheduled for later this year.
On the surface, NVIDIA’s Cg programming environment appears to be a good thing for all content developers who are looking to push the limits of today’s hardware without requiring a corresponding increase in development time. Many journalists and consumers have noticed the increasing disparity between today’s latest hardware and games (or other software applications) that are designed to take advantage of that hardware with growing frustration. Cg could be the key ingredient that gets the software industry the shot of adrenaline it currently needs.
|© Copyright 2003 FS Media, Inc.|