I've been in the IT profession since 1980 and began my career as an applications programmer responsible for maintaining a hodgepodge of poorly developed legacy computer systems. It didn't take long before I recommended to management that these systems, which were written in COBOL and FORTRAN, were in dire need of a complete overhaul. The midnight phone calls due to batch processing failures were getting old in a hurry. Another patch here, another patch there, and prayers to the computer gods were the standard order of business back then. Fast-forward ten years. Although we continued to use the COBOL programming language, the majority of our company's production data was migrated to a variety of high-end database systems such as IDMS and DB2.
At this point you may be wondering what any of this has to do with NVIDIA. Hold on to your horses for a while longer as I'm constructing an analogy that will be used to demonstrate the benefits of their latest technology.
Reporting is an important part of a computer system and has a tendency to consume a large portion of development costs. While COBOL was still widely used at our shop, we purchased a forth generation reporting system called FOCUS in 1995. FOCUS was a revolutionary product and caused a tremendous impact by changing the way I worked. With FOCUS, I could use a straightforward reporting language no matter what type of database structure I was reporting from. I could even join data from multiple data sources on different computing platforms to create a comprehensive report.
Benefit of High Level Languages
The most valuable feature of FOCUS was its simplicity. For example, a typical report to retrieve, sort, sum, subtotal, and print data in a COBOL program could easily exceed 600 lines of source code. The same report can be written using FOCUS in 10 lines of source code. That's the beauty of a forth generation procedural language - you tell it what you want to do, and it figures out how to do it. For example:
JOIN PART_NUMBER IN PURCHASE_ORDER TO PART_NUMBER IN PART_MASTER
TABLE FILE PURCHASE_ORDER
PRINT PURCHASE_ORDER_NUMBER, PART_NUMBER, PART_DESCRIPTION
This FOCUS program is almost self-documenting. After a few training sessions, I eventually had end-users writing their own reports.
Now what if we were to take the above example and extend the same concepts to programming 3D graphics? As a game developer, I would probably be very excited...
Introducing NVIDIA Cg
Today NVIDIA is introducing beta version 1.0 of their Cg Toolkit which consists of a high-level shading language ("C" for graphics) based on the shading capabilities included in the DirectX and OpenGL application programming interfaces. The toolkit includes the following components:
NVIDIA Cg Toolkit 1.0
Cg Compiler Public Beta 1.0
- Vertex: DirectX 8 and OpenGL 1.4
- Pixel: DirectX 8
Cg v1 language specification
Cg Standard Library
Cg Users Manual
Cg Shaders (Various pre-written programs)
Along with NVIDIA's NV30 graphics chipset, which will debut this fall, version 2.0 of the Cg toolkit will also be released. In fact, Silicon Graphics co-founder Kurt Akeley has gone on record by stating that "The biggest revolution in graphics in 10 years, and the foundation for the next 10" will be attributed to NV30 and the Cg toolkit. That is certainly an extremely powerful statement!
NVIDIA Cg Toolkit 2.0
Cg Compiler 1.0 Gold
- Vertex: DirectX 9 and OpenGL-NV30
- Pixel: DirectX 9 and OpenGL-NV30
- CgFX Parsing
Cg Browser 5.0 (CgFX enabled)
- More Shaders
Max CgFX plugin
Maya CgFX plugin
XSI CgFX plugin
With the advent of vertex and pixel shaders, which allows the graphics accelerator itself to be programmed, more accurate modeling of the interaction between light and materials was made possible. However, in order to expose the advanced features of the latest graphics hardware, developers had to write shader programs in a low level assembly language. Similar to the analogy I made between the FOCUS and COBOL programming languages, a single Cg shader instruction may result in a hundred or more lines of assembler code to be generated during the compile phase. Depending on the skill level of a developer, shader programs can continue to be written in assembly language, but many will opt to use the Cg language. Not only will Cg decrease the amount of development time, but since it's also capable of generating optimal code, there will be fewer program bugs to contend with.
Cg Compiler Schematic
The compilers that I've been accustomed to using, such as a COBOL compiler, take a source program and generate a machine language load module, which can then be executed. With the Cg compiler, the compile, or the translation from a high level shading command to low level assembly code, can be accomplished at run-time. There's a distinct advantage to Cg being compiled at run time in that the capabilities of future graphics hardware can be added to the compiler without having to modify source code.
Perhaps the most powerful feature of the Cg language is that it will allow developers to enable even higher quality graphics which are capable of being hardware accelerated by today's graphics processors and those of tomorrow. NVIDIA has made it clear on several occasions that a major goal is to achieve real-time cinematic graphics quality in 1/60th of a second. As anticipated, developer feedback on what the Cg language brings to the table has been overwhelming. While I had access to a document of quotes from over 20 developers, I included a subset here.
"Cg is the missing connector between the world of fast, hardware-driven rendering and the detail-oriented world of software rendering. Cg provides the artist the same rich toolbox of image possibilities previously only available through slow software rendering or laborious assembly coding. Cg is the necessary link that brings hardware-accelerated rendering to within a hair's breadth of the software-driven world -- and once that linkage occurs, it will not only revolutionize the experience for gamers and other end users of graphics, but it will revolutionize the practice of animation in every corner of the industry -- by simplifying, unifying, and accelerating the image-development process, right there at the artist's desktop. I expect that the combination of Cg-driven power and quick, interactive rendering will quickly come to surpass almost all other forms of rendering for artistic purposes in every venue -- games, TV, and movies."
Kevin Bjorke Imaging Supervisor Final Fantasy: The Spirits Within
"Most games out have been lagging behind what the NVIDIA GPUs can actually do in terms of graphics processing. Writing visually exciting and optimized shaders takes serious time—until now. Cg takes shader implementation to the next level. It will be the standard for writing effects from now on."
Todd Howard Lead Programmer - Morrowind Bethesda Softworks
"We have been eagerly awaiting this next generation of shader technology. Cg, with its compiler and associated toolkit, will be an indispensable tool for the creation and implementation of pixel shaders and vertex shaders. By abstracting the lower level assembly language, we are now free to spend more time and programming resources on writing more powerful custom shaders for the delivery of much more visually stunning effects on both OpenGL and DirectX."
Dean Sekulic Programmer Croteam
"Cg is a bright light for a black art. Finally, cryptic shader tricks can be explored and applied by mere mortals."
Mike Biddlecombe Programmer - Dungeon Siege Gas Powered Games
"NVIDIA's understanding of graphics development goes beyond the advancement of 3D hardware. They understand that it takes software support to intelligently drive these systems. Cg is another brilliant offering that empowers us to build the worlds we imagine. The encompassing vision of Cg (art tool integration, debugging, and platform compatibility) is something that developers like us have been yearning for. Finally being able to replace complicated shader systems with a simple unified language will greatly simplify our work. Relic prides itself on its artistic and technical presentation, and anything that can bring us closer to our vision is something we are ready to embrace."
Ian Thomson Lead Programmer - Impossible Creatures Relic Entertainment
NVIDIA is also receiving favorible comments from the Digital Content Creation (DCC) software community. DCC software is an important tool for game developers as it allows creation of character animation, photo-realistic materials and surfaces, and scenes using textures and lighting. Popular DCC software packages include Maya, 3ds max, LightWave 3D, and Softimage/XSI.
"Discreet is excited how a language like Cg makes it possible for 3ds max game artists and programmers to single-source their shader assets between tool and game - something that should enable and encourage the exchange of cutting-edge shading techniques across the industry. Discreet is pleased to be working with NVIDIA to ensure these custom shaders are easily used within 3ds max, giving 3D artists the power to bring the realism of their creation environment ever closer to that of their final output."
Phillip Miller Vice President of Animation Products Discreet, a division of Autodesk, Inc.
Cg was developed with participation from Microsoft and the initial release will work with all programmable graphics processors that support DirectX 8 or OpenGL 1.4. Since Cg was developed under the guidance of industry standards, it should be widely adopted only if remains an industry standard. The last thing developers need is a language that takes on proprietary characteristics by catering to "non-standard" features. Another area that will require close monitoring is the ability for the Cg compiler to generate optimal code - not so much for NVIDIA's graphics processors, but for GPU's from competing graphics chipsets.
NVIDIA's also mentions that key Cg compiler components are open-sourced. Although I failed to ask NVIDIA for details on that specific feature, it may provide new and better methods of incorporating shader techniques into the compiler. If that's the case, contributions by the industry to enhance the quality of the Cg compiler could lead to even greater support. On the other hand, it might be necessary for vendors to implement their own shading compilers to overcome perceived shortcomings of NVIDIA's Cg. This approach would fragment high level shading languages and cause an undesirable side-effect for developers.
With the advancement of graphics hardware during the past few years, consumers that have bought into the technology continue to ask when will leading-edge graphics technology become widely adopted by game developers. I believe that NVIDIA may have be asking the same question and answered it by developing Cg. If Cg ends up making the same impact as FOCUS did when I was a developer, than Kurt Akeley's earlier comment should be taken with much more than a grain of salt.