Judgement day has come! (Choosing a shader lang)

Started by
10 comments, last by zedzeek 18 years, 10 months ago
So I feel like my little pet project engine has gotten to the point where I want to seriously start integrating shaders into it. I've been toying around with simple effects for a while, and have become reasonably familiar with both CG and GLSL, but I haven't really used them for anything serious as of yet. So... I'd like to know everyone's opinons of the current state of the High Level Shading Languages avalible. What you've used, why you like one or the other, and what problems you've had with either. I know that a while back support for either was iffy at best, but I hope that's improved considerably. Not trying to start any flame wars here, I just want educated opinions. [Edited by - Toji on June 1, 2005 10:05:54 PM]
// The user formerly known as Tojiro67445, formerly known as Toji [smile]
Advertisement
I for one believe that high level shading languages are still pretty far from being robust and reliable enough to be introduced to application targeting the big crowd.

I had my share of headaches and bitterness about some shaders that I wrote and which would run on a set of hardware while excluding some other, heck even the same hardware but with different drivers could give you a nightmare.

For the problems aforementioned, I for one decided to stick with ARB programs instead as I'm almost guaranteed to have them work pretty much everywhere given the right extensions.

Just my $0.02
I think this is what you'll hear from other people. GLSL's implementations are so... inconsistent, that untill it gets some help it probably wont be the best option. GLSL though, in my opinion, is the prettiest language, I like how it interfaces with the main program. CG on the other hand, has an interface that I dont like quite as much. Additionally, its completely incapable of using branching on any non-nvidia card (in OpenGL)(as far as i know, if im wrong, PLEASE correct me :-))

hope that helps/hope i didnt give out any horribly wrong information regarding cg as im new to it (driven away from GLSL)
-Dan
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
The OpenGL Shading Language is the future.
The ARB interface will slowly lag more and more behind as there are no plans to update it (it already lacks the ability to branch and loop the SM3.0 cards can perform).

Cg can perform branching and looping, however it must use NV extension or GLSL as the backend to achieve this.

The GLSL compilers are indeed a tad immature, this is true, however they have only been in existance for less than two years and arent the only thing being worked on. However I would say for the most part they are now alot more stable on Win32 platforms, not perfect and maybe not as fast has hand produced code in some instances (however how much of that is down to the compiler and how much is down to the programmer being 'clever' and making life harder for the compiler is another matter) but its certainly getting there. Linux and OSX drivers might be a different matter, I dont know [smile]

I use GLSL myself, I've had no problems with it but I've not really pushed it all that much. It does have some issues so I wont pretend its perfect, but frankly if you are just starting to learn shaders its probably the best way to learn as its alot simpler than Cg in some respects and intergrated more tightly with OpenGL and as I opened with, it is the future.
I was just wondering how is it possible to do Per-pixel lighting/other effects on GF3 cards if you do not have branching/looping on it? Most of the GLSL tutorials seem to use if's, loops(uniforms) alot. How do people achieve all those lighting effects on todays games which run on GF3 hardware?
I'd imagine through the ARB interfaces. That said, I think conditionals in shaders are kinda abused. You can certainly to per-pixel lighting without a single if or for, as it's really nothing more than calculating the brightnesss of the pixel based on the angle from it to the light. (Oversimplification, but hey.)

In any case, I think I'm leaning towards GLSL simply because, as phantom said, it's the future of shading with openGL. nVidia sounds like they're not very interested in supporting cg in the future, so why support a dying language? In the meantime, though, I think I'll implement every thing through ARB shaders, then make an interface for GLSL avalibe for such a time when it becomes stable enough for regular use.

I'd still love any other opinions, though!
// The user formerly known as Tojiro67445, formerly known as Toji [smile]
Quote:I was just wondering how is it possible to do Per-pixel lighting/other effects on GF3 cards if you do not have branching/looping on it? Most of the GLSL tutorials seem to use if's, loops(uniforms) alot. How do people achieve all those lighting effects on todays games which run on GF3 hardware

in my game i use ~200 glsl shaders,
in none of the 200 do i use an if statement or any loops
perpixel lighting doesnt need conditionals to work?
then again glsl doesnt work on gf3 u will need register combiners on that hardware
God!!! I can only imagine the compile and load times of those 200 shaders
/shudder
I myself use cg, but I would recomend GLSL, it will be future of gl shading. I've not used it recently but from what I hear things have really gotten better from the year + ago when I last tried it.

The only real bonus to using cg over GLSL is it supports geforce 3 and 4 cards IMO.
Quote:Original post by JavaCoolDude
God!!! I can only imagine the compile and load times of those 200 shaders
/shudder


I can't imagine he'd be using them all at once... (And if so I'm so, so sorry)

// The user formerly known as Tojiro67445, formerly known as Toji [smile]

This topic is closed to new replies.

Advertisement