PDA

View Full Version : cg c for graphics


t-man152
07-29-2003, 11:12 PM
does anyone know this language? what do you program with this? a gpu? is it worth learning? and does anyone know of good free tutorials on the web?

Dave Black
07-29-2003, 11:24 PM
It's Nvidia's, and it's cool. That's all I know. And I think it's mostly for programming hardware. Did'nt understand a word of it when Nvidia pitched it. Learn more here:

http://www.nvidia.com/object/cg.html

-3DZ

:D

Array
07-29-2003, 11:49 PM
it's a lot like renderman's shading language. in fact, Larry Gritz, former Pixar Employee and co-founder of Exluna (entropy and bmrt renderers) works for Nvidia now, presumably helping in the development of Cg. It is primarily for realtime applications (games, simulations).

Boone
07-30-2003, 08:16 PM
When I get my new PC - I'll be going through this language in great depth.

Its used in conjunction with OpenGL & DirectX 9. Looks very interesting!:applause:

mattregnier
07-30-2003, 09:29 PM
It's very very cool. We were researching it in a Renderman class I took my senior year of college. The programming side, it's very much like C, with classes and objects, etc... On the graphics side, it is amazing, because once you download it and install the plugins to max/maya, you can have real time shaders in your viewport. And it's fast. During the class we ran them on a Geforce Quadro FX 500. I got my new machine at work now and can run all the demos and the card is a Geforce FX Quadro 1000.

You can find all documentation, literature, and other stuff on nvidia's site, but i'll also suggest going to http://www.cgshaders.org/

Those guys have a forum and have been doing alot with it. I welcome any other questions to those just getting started with cG. and I'll try to help you out.

either respond to this post, or pm me. It's just since the language is relatively new, there's not many people working with it, so if anyone is interested/working with it/just playing around, drop me a line I'd be interested to see what you've come up with.

I'm actually excited enough about it I would go so far as to recommend having a cG section here at the talk, and starting some small projects/shaders just to see what all you guys come up with, and work together collaboratively on writing a few things.

As soon as all the mods get back from being on vacation, I'll run it by them...
cheers!

Boone
07-30-2003, 10:45 PM
Re: Mattregnier.

Hmm. I'm assuming I can use this "CG" language for use in DirectX games...:shrug:

I'm a little confused as to it's requirements - will I need a certain graphics card?

Cheers.

mattregnier
07-30-2003, 10:53 PM
You'll need an Nvidia based card, geforce 3 or higher. It really works best with the geforce 4's. basically right now all cG can do for you is realtime shaders, but eventually what some industry professionals want to do with it, is when it comes to realtime gaming. a lot of the things such as baked textures/lighting, will become a thing of the past with cG, since the modern graphics cards can interpret the code in realtime.

if you don't have an nvidia based graphics board though, there are emulators for the ati radeons.

sorry didn't make the language/programming for it very clear. it has a small gui environment for programming similiar to vb/visual studio/etc... there is a preview viewport for simple viewing of objects, triangles, spheres, boxes. for more complex viewing of compiled shaders you'll need either max/maya and the plugins associated with them. I've emailed lil'd about starting a cg forum, and I'll try to get together a startup users guide for installing all the files/runtimes/devlopment kits for cg and hopefully we can get rocking on this :D I'm excited that finally some others are showing interest in it.

Boone
07-30-2003, 11:04 PM
Re: Mattregnier.

Thanks for the info:thumbsup:

Vril3D
07-31-2003, 04:06 AM
Hi all,
I'm very interested in Nvidia Cg shaders also.
I think it would be a great idea mattregnier to set up a Cg section here at CGtalk.
I noticed the Maya 5 plug-in is available now so will get it today and start exploring this stuff.

mattregnier
08-01-2003, 05:06 PM
Well I've emailed and Pm'd lil'd(tito) about it, so now all I'm waiting for is a reply. Hopefully He'd be up for it :D They are all probably still at siggraph or in san diego though, so I'm not expecting a reply just yet... I'll post in here as soon as I know details. Thanks for everyone supporting this. Hopefully we will soon have a forum dedicated to the cG shading language.

CGmonkey
08-01-2003, 05:16 PM
There are CG forums on the net.

Vril3D
08-01-2003, 06:05 PM
I got it set up today,having some issues with the current Shelf Buttons they don't seem to work with Maya,I made an order for a copy of the book called Cg the Cg Tutorial.So when I get that I will have some questions no doubt.What I have seen of it so far is pretty impressive.

Hey CgMonkey.
What's wrong with having one more?

mattregnier
08-02-2003, 12:05 AM
Monkey just sounds a little lost is all, if he messed around with cg a bit, he'd realize why we need a forum for it here.

Vril3D-

The shelf button problem may just be caused by the version of maya that you have. I need some more info, version of maya, type of graphics card, and did you do a full install of the cgtoolkit?

You can PM me, or reply to this post, hopefully we can keep generating traffic here, to garner some more interest in this...

Array
08-02-2003, 12:51 AM
just ask in the rendering forums. CG is a LOT like renderman's SL.

Vril3D
08-02-2003, 03:35 AM
Hey mattregnier,
I am running Maya 5 on an Xp system, I have installed all the Cg toolkit 1.1 stuff.
The shelf tools available for download are still marked as 4.5 shelf tools so that's where the problem lies i am sure.
The 5.0 plug-in was only released a few days ago so im sure they will put a new tool shelf up soon for people like me to nooob to make their own.I got a shipping notice on my tutorial book so will have that soon.

My setup is a p4,2.8,800mhz/abit ic7-g/1024 meg corsair 3200twix/FX5900 128meg.
damn I love this new system it flies

CGmonkey
08-02-2003, 03:39 AM
Originally posted by mattregnier
Monkey just sounds a little lost is all, if he messed around with cg a bit, he'd realize why we need a forum for it here.


Can't you guys just realize that you can't create a forum every single time something new comes up :]

CgTalk is already overcrowded with sub-forums! :)

Just search the net or as Array suggested, ask in the rendering forums.

mattregnier
08-02-2003, 04:46 AM
Well lil'd told me he'd look into it, so I'll have a response for you guys sometime next week.

Array-

That's where I'm shooting to host this nvidia cg forum, is under rendering actually.

CgMonkey-

It's not a new idea, Nvidia came out with this language over a year ago now, and I think it's important (to me and others) to find out more about it. With cgtalk being the industry forefront in several other areas, why shouldn't we be up on one of the biggest and most exciting areas of realtime rendering right now? There are quite a few big name industry guys behind this, and they really think it has the potential to do some great things for games and entertainment industry. I'm not asking for you 2 to police it, I've already talked to tito, and he said he'd look into it. But since you guys already shot it down, I wouldn't be surprised if he does too.

Boone & Vril3D-

I guess you can just pm me or email me then, and we can talk about this over that instead. Maybe I'll try getting a listserv setup or something as an alternative, since this isn't being very well received thus far...

CGmonkey
08-02-2003, 12:36 PM
mattregnier,

I'm very interested in nVidias new language, and I know it's been out awhile.. I'm actually trying to find every possible article to read about, even ordered the book awhile ago. It's RELATIVELY new.

Hmm, and I would love to see a forum here on CgTalk. But I've seen this question so many times and they have already closed down a Renderman forum. Even if they create one, it's not going to be populated since it's a purely programmable language and CgTalk tends to be more to the artistic side.

:)

bjorke
08-06-2003, 12:00 AM
Hi, I'm the author of the Mel scripts mentioned, so I guess I should chime-in :)

The scripts are identical between Maya 4.5 and Maya 5.0 -- the only difference is the contents of the CgFX_shelf.mel file -- it uses some icons from the Maya install directory, so if you don't have Maya4.5 installed, the buttons appear as gray blocks -- not pictures. Editing the text of the CgFX_shelf.mel to replace "4.5" with "5.0" will fix everything.

The Cg plugins for 4.5 and 5.0 are different, but only because of changes in Alias's Maya API. The source code (distributed) for the 5.0 version will also create the 4.5 version -- there are only a couple of lines that change.

The plugin is pretty plain-vanilla OpenGL inside -- I've seen people run it quite happily on cards other than NVIDIA, though of course NVIDIA cards are the most-capable for running long, interesting ARB fragment programs. So (imo)
everyone using Maya ought to have this plugin! It can provide a lot of useful speedup to your workflow.

(And likewise the plugins for Max, and the new latest-latest one for XSI 3.5, which may prove to be the most-capable hw shading tool yet!)

schroder
08-06-2003, 12:39 AM
I'm also very interested in cG. I'm going to hit up some other sites to learn more but would love to see a spot here to for sharing shaders etc... possibly a contest in the future if there is enough interest. :)

I've read nvidia's site on it and heard a little about it before. Is cG used just for real time shaders or is it also used for coding other game components? I mean, can it replace C++ for game programming?

bjorke
08-06-2003, 01:11 AM
Cg doesn't replace C++; it controls what occurs within the GPU for shading and object transformations. So your C++ program would call and bind Cg shaders to objects, much as your program currently might bind textures to those same objects and textures before the advent of Cg.

dmeyer
08-06-2003, 01:29 AM
I'm up for a Cg forum, or at least some sort of extended Beginners Guide. I've been looking at getting into it but havent really had the time.

How is the learning curve? I have pretty extensive scripting experience in C++ like languages (actionscript, javascript, mel, lingo, etc) but never had a need to hit up C++ itself. I'm a designer that programs as much as a have to. ;)

bjorke
08-06-2003, 02:02 AM
...like most 3D tools, the curve is as steep as your comfort level. If you want to program Cg, there are books etc. If you just want to use Cg, there are predefined shaders and a few tools for automatically-generating shaders -- so you can aim either high or low in terms of complexity. In this respect, it's a "deep" technology, and getting deeper each day.

Vril3D
08-06-2003, 02:34 AM
Thanks bjorke,
That was way easy to fix.I only started playing with Mel a few days ago but that was very easy to sort out thanks heaps.
I'm still waiting for my tutorial book on Cg to arrive,so I can get a better understanding of how this works.
As I'm only a new member here I realise my opinion counts for little but I think it would surely be of help to a few people in here if there was a dedicated thread on this subject here somewhere.
The fact that the person "bjorke" that wrote the Mel for the tools is here making comments can only be a massive plus, their first post has solved my first set of problems.
Again I realise there are other forums to go to for this info but to be frank who wants to,if I can go one place to get the info I want I would much prefer that.Being new to a forum means you have to go through the hassle of getting to know the place and the people in it to develop a bit of street cred so you can get answers to your questions,I don't have the time to join a new forum for every new technology or peace of software out.I would much prefer to go to one or 2 places to get the info I'm after.

mattregnier
08-06-2003, 05:00 AM
Sweetness! ask and ye shall receive, thanks Leo & lil'd...

this was exactly what i was wanting

Neil
08-06-2003, 06:51 AM
couldn't they have thought of a better term that 'CG'?

I mean when people ask you, "what are you doing" and you say "oh, i'm just doing cg".... they say "no shit, smart ass". :)

markdc
08-06-2003, 07:48 AM
I took the cg course at siggraph and I'm reading the book now. Looks very promising. I hope to do something useful with it soon.

CGmonkey
08-06-2003, 01:12 PM
mattregnier - i kinda got that in my face, eh? :P

Vril3D
08-06-2003, 01:48 PM
Yes, thank you to the higher powers."Dua Netjer en ek"

dchavez
08-06-2003, 02:40 PM
I'm almost certain that Cg is not just for NVidia cards. It compiles into Vertex Shader (VS) and Pixel Shader (PS) programs that either vendor's (NVidia or ATI) GPUs can run. Cg is basically an alternative implementation of DirectX 9.0's Higher Level Shader Language (HLSL). Of course Nvidia could make Cg GPU-specific at any time, and DX is the standard, so HLSL is possibly a better choice for a game engine. In any case, their syntax is so similar that if you learn one, you should be able to pick up the other in pretty quick time.

DChavez out.

mattregnier
08-06-2003, 04:45 PM
Originally posted by CgMonkey
mattregnier - i kinda got that in my face, eh? :P

Monkey-

:)

pseudoE
08-06-2003, 05:47 PM
Cg does appear very attractive~ However it seems to be limited to hardware rendering- Is this what others have found? I can make all the shaders I want for viewport viewing in max, but when I want to software render(scanline), there isn't a pathway...

e.

Knut
08-06-2003, 06:20 PM
As far as i know, Cg is for realtime calculations only. For use in Games, Viewports etc. I belive renderman (or other compatible software) has covered the rendered version of this concept.

Correct me if i'm wrong.

shrimp_chip
08-06-2003, 09:21 PM
cg is a shading language for hardware 3D graphics.

There are currently four competing shading languages:

Pixar Renderman SL
+ Been around for 10 years.
+ Very good for non-realtime graphics
- Not designed for realtime hardware accelleration.

NVIDIA cg
+ Good documentation
+ Works with both OpenGL and Direct3D
+ Good for realtime graphics
- Doesn't work very well on non-NVIDIA cards

Microsoft HLSL
+ Nearly identical to cg
+ Good for realtime graphics
+ Works on all high-end 3D cards (e.g. both NVIDIA and ATI)
- DirectX only

OpenGL Slang
+ Should eventually work on all 3D cards
+ Good for both real-time and non-realtime applications
+ Uses software emulation and/or multiple passes to make graphics program work even if your card isn't high-end. This is useless for games, but great for rendering.
- may not show up on all cards for several more years.
- syntax is unnescessarily different than cg/HLSL

If you learn cg you should be able to apply what you learned to HLSL and OpenGL slang.

Microsoft already supports HLSL for Xbox. I wonder if Sony will ever support a shading language for the PS2/PS3? It would be nice if you could write shaders once and have them work on PCs and consoles.

Array
08-06-2003, 09:47 PM
Originally posted by Knut
As far as i know, Cg is for realtime calculations only. For use in Games, Viewports etc. I belive renderman (or other compatible software) has covered the rendered version of this concept.

Correct me if i'm wrong.

it can be used in non-realtime applications. people have been experimenting with rendering using OpenGL for years. Theres several multi-pass openGL renderers out there that get decent results.

markdc
08-06-2003, 10:42 PM
Motion Builder renders using OpenGL only. It's being used for an animated series (SD Gundam Force --I think) demonstrated at siggraph.

chrisdejoya
08-08-2003, 06:34 AM
Is anybody aware of any projects underway that use Cg?

I like the idea of Cg, I'd learn programming to be able to make my own shaders. I've read a lot of naysayers saying it will die. This thread is different, there's a lot of enthusiasm for it here.

But is it really going to happen?

bjorke
08-08-2003, 06:44 AM
If you look at the docs you'll see that Cg is both specific and general. You can define the profiles at compile-time -- so if you want nv3x-specific stuff, specify that (say via the "FP30" profile), but the API standards -- ARBFP for OpenGL, and the various ps_#.# flavors for DirectX -- are always supported. In fact they have to be supported for DirectX users, since there's no such thing as "GPU-specific" DirectX. That's one of DirectX's features.

The only problem people with non-NV cards should have is that no other cards let you run truly long, robust shaders, unless you break them up into multiple passes.

orgeeizm
08-10-2003, 06:48 PM
Im still a little bit clouded by how this CG thing works.
Im downloaded the ALL-in-One kit right now, though I have an ATI card, i know it probably wont work all good but its ok, ill be getting an Nvidia card later.

So I just have a simple request to whoever here already knows CG. Can you post a small code ala 'printf("hello world\n")' using CG but instead of hello world, draw a box with a texture map.

would be something like this:

main()
{
cgMakeBox hellobox 10 10 10;
cgTextureBox hellobox "texture.bmp";
cgDisplayBoxOnScreen hellobox;
delete hellobox;

return 0;
}

?? i dont know, enlighten me. How does this all work? Being integrated into Maya and all or being used in C++ for games?

Is it going to replace DX or Opengl graphics functions?

Im lost but all I know is that im really interested.

Boone
08-10-2003, 07:06 PM
Re: Orgeezim.

I plan to run through Cg when my new PC arrives in less than 7 days...I'll be considering writing a tutorial on it when I've cracked it.

If any of you guys want to help me with this - feel free! If we help each other - we all learn it faster...:beer:

orgeeizm
08-10-2003, 07:17 PM
Im down to learn. Im still downloading the All-in-One package, almost done. Hopefully my ATI card doesnt bang up on me alot..

shrimp_chip
08-10-2003, 10:39 PM
Originally posted by orgeeizm
Im still a little bit clouded by how this CG thing works.?? i dont know, enlighten me. How does this all work? Being integrated into Maya and all or being used in C++ for games?

Is it going to replace DX or Opengl graphics functions?

Im lost but all I know is that im really interested.

As I'm sure you've figured out by now, cg is a shading language, not a graphics language. You still have to use OpenGL or DirectX to draw the geometry -- cg just helps with shading the geometry.

So I guess they should call it "cs" not "cg".

orgeeizm
08-10-2003, 11:36 PM
So like, Im assuming it would be something like this then:

drawBox(BoxObject Box)
{
for i = 0 to Box.NumberOfFaces
{
cgDrawAnistropicWithReflection( Box.Face[i] );
}
}


But of course the cgDrawAnistropicWithReflection type function
is going to be different depending on how the quad is supposed to be shaded.

Maybe some quads dont have reflection so it would call a function similar but with no reflection. So it basically works on the shading/texturing level when drawing the models on the screen using the video card through the cG language.

Am I on the righ track?

bjorke
08-11-2003, 01:44 PM
Cg defines shading, not the actual model. You use Cg to describe the surface properties -- in the same way that you might use a texture to describe a surface's base color, you can use Cg to describe other preperties of that surface (how shiny, its reflective characteristics, animating procedural patterns, etc etc etc). So you just apply Cg to any existing geometric model -- you can think of it as a more-poerful mechanism for texturing.

Jamaludin
08-11-2003, 09:37 PM
Hello all, im very new to this but Ive been interested in game making for some years now think about 10 years now and have been busy with it as well. This programming language seems very capable and I cant wait to try to learn this, very interesting indeed ! :scream:

rendermaniac
08-12-2003, 12:01 PM
Hi Kevin

Hope you're still following this thread - and having fun at nVidia of course! Just wondering would it be possible to make your Siggraph course notes available about cg? I would particularly like to know how it can be used in visual effects. The only place I can think of is Maya particles or as an interactive preview (Although there isn't usually the time to do pretty stuff like that).

Simon

bjorke
08-12-2003, 06:38 PM
The notes etc will be available through developer.nvidia.com (http://developer.nvidia.com), probably within the next day.

(Although there isn't usually the time to do pretty stuff like that).

That lack of time is exactly why having tools like Cg is important. If the interactive displays look like the final result (or in fact can actually be the final result, in some cases), then there's less time spent waiting on renders or re-doing things. The goal is to reduce the time spent trying to second-guess the renderer (and the director).

CGTalk Moderation
01-15-2006, 07:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.