Tweak3D - Your Freakin' Tweakin' Source!
NVIDIA Cg And CG Compiler

Posted: June 13, 2002
Written by: Davey McWatters

NVIDIA Cg And CG Compiler

C For Graphics

Final Fantasy, Shrek, and Toy Story are all notoriously well-developed computer generated, or CG, movies. When will we be seeing these kind of graphics rendered in real-time you ask? It may just be closer than you think. Cg is rapidly approaching the answer all developers have been looking for. It will allow them to not only to be able to render those kinds of graphics in real-time but also be able to code them much easier.

Some complicated frames in a CG movie can take an entire day to render the single frame. With real-time rendering, they have a 60th of a second. Taking today’s mixture of software and current GPUs, there is no way it could be rendered that fast. With that, they're either going to have to drastically ramp up the speed of the GPUs or they are going to have to come up with a way to compile the code to render that type of image extremely fast in software.

NVIDIA’s answer to the problem is their Cg compiler. They have been working closely with Microsoft to develop the compiler to make sure it will be 100% compatible with DirectX 9 and Microsoft’s High Level Shading Language, which will be introduced in DirectX 9. However, unlike Microsoft, NVIDIA’s compiler will support DirectX 8 as well as DirectX9. It will also support any GPU that is compatible with Microsoft’s DirectX 8 or 9. The catch is, since NVIDIA knows exactly how their GPUs work they will be able to fine tune it toward NVIDIA GPUs. That gives NVIDIA’s compiler another advantage over Microsoft’s if you’re using an NVIDIA GPU based graphics card.

NVIDIA’s compiler will also be able to work with either of the two largest API’s available, DirectX or OpenGL, yet another advantage for developers to use NVIDIA’s compiler when coding their games. With the ability to work with multiple API’s and the ability to work with any GPU supporting those API’s, there is no reason for the developers not to take advantage of such a tool. Oh and did we mention, the compiler will support multiple platforms including Windows, Mac OS X, Linux, and Xbox.

The Coding Process

Before Cg, if you wanted to develop a beautifully rendered cinematic for your video game you would have had to code it in the language we know as Assembly. Very few people in the world have the skills it takes to be an Assembly programmer. Due to the fact that gorgeous cinematics had to be coded in Assembly, most companies wouldn’t even bother trying.As you can see from the image above, Cg is far more like the English languange than Assembly, but it's still not up to RenderMan's ease of use.

Now, with NVIDIA’s Cg Compiler, developers can develop some of the greatest looking cinematics we have ever seen much easier than they could before. The compiler will ship with its own bundle of built in libraries that developers can use to create their games, or they can code their own libraries if they desire.

Cg is expected to be the C/C++ of the graphics world. With NVIDIA and Microsoft working closely together, we are guaranteed the compiler will be fully compatible with DirectX, which will in turn guarantee us compatibility with any GPU as long as it is Direct X compatible as well.

Where The Compiler Comes Into Play

The Cg Compiler actually resides before your API, whether it be DirectX or OpenGL. The Compiler will send the API the compiled data and then the API will pass the data on to your GPU, which will output the beautifully rendered image to your screen. This will make things significantly easier for developers since they can write the code directly toward the compiler instead of writing Assembly code to the specific GPU.

With Cg making developers jobs easier, it wouldn’t make sense for them not to adopt it and use it in every new game produced. Paired with NVIDIA’s NV30 the Cg compiler will offer the ultimate reward. NVIDIA’s compiler can write the code that is optimized for NVIDIA GPUs and their vertex and pixel shaders, which will result in glorious real-time renderings.

Having open sourced parts to their compiler, NVIDIA should allow other GPU developers to check out what the compiler is doing and make sure their GPUs work optimally with the compiler to keep consumers happy. NVIDIA will begin to play an even bigger role in the gaming industry over the next few years, even more so than they have in the past few years. All we can do is sit back and wait to see what comes along.

Developer Support

Hundreds of developers have already pledged their support for Cg. Among the list of supports are big names like Electronic Arts, Sega, and Valve. With developer support from nearly every developer in the industry, it looks like NVIDIA is headed in the right path with Cg and their Cg compiler. Could we finally be starting to see the convergence between movies and the real-time rendering NVIDIA has been talking about for a few years now?

NVIDIA is definatly onto something big here, the next few years should be very exciting in the gaming community. The stuff we’ve seen at E3 this year such as Doom III already looks amazing, but when developers start getting more acquainted with Cg there is no telling what we might see. Who wouldn’t like to see Final Fantasy: The Spirits Within able to be rendered in real-time?

Many individuals who have influenced the gaming community are pledging their support as well. Here is a quote form Kurt Akeley, Co-Founder of SGI and OpenGL, said this on NVIDIA’s NV30 and Cg. “It’s the biggest revolution in graphics in 10 years, and the foundation for the next 10 years.” With someone as knowledgeable as Kurt Akeley saying that, it shows that Cg and NVIDIA’s Compiler have huge potential in the industry.

We are excited to see where the gaming industry is headed over the next few years. Graphics are one of the fastest moving industries in history. We hope to see it continue to rise as fast as it has the last few years. We also hope to see most if not all developers taking use of what new technology is offered by companies like NVIDIA and Microsoft. What are you waiting for? Hop in and enjoy the ride.

  • News
  • Forums
  • Tweaks
  • Articles
  • Reviews