Sign in to follow this  
Bulma

OpenGL Cg or GLSL

Recommended Posts

I need to write some shader code in openGL, for windows platform. It is targeted for Geforce7800, and I`ll be using SM3. Which shader language do you recommend? Which one is easier to use, more stable(I saw some posts about problems with some functions in GLSL), has more features? Also, Cg has CgFX, is there something like GlslFX? Thank you.

Share this post


Link to post
Share on other sites
Hi,

Personally I am trying to learn NVidia Cg and CgFX. I am trying to use this for my scenegraph's material system so that I can support fallback for lower spec hardware and the CgFX techniques stuff appear to support this.

I previous created a few fragment shaders in plain Cg which was really straight forward - and I think it would have been just as easy in GLSL. But GLSL as far as I know does not support techniques etc. from a single source file.

Have a look at my material thread and hopefully there will be some feedback from others soon :)

Cheers,
Dave

Share this post


Link to post
Share on other sites
I'd like to weigh in here also; my preference so far has been GLSL only because it is not vendor-specific; which Cg may or may not be (is it?) I was concerned that some functions in Cg may not work exactly the same on non-nvidia cards but I may be wrong.

It is true that GLSL uses seperate files / structures for Vertex and Fragment shaders, but that's not a big deal for me.

Share this post


Link to post
Share on other sites
Hi,

I believe with the 1.5 public betas NVidia have released their profiles are now better supported by non-NVidia hardware. There is also a GLSL profile available. But I have never tried it on non-NVidia cards so I could not make a comparison.

Quote:

It is true that GLSL uses seperate files / structures for Vertex and Fragment shaders, but that's not a big deal for me.


Yep I can agree with that, generally its not a big deal. However, I want to supply easily packaged materials that have a fall back, and the CgFX runtime helps a lot with the automatic determination which techniques are valid. If I went down plain Cg or GLSL route I would not have this helper API to determine things like this for me.

I agree the work for each kind is probably the same because a CgFX file still contains separate shaders (potentially) for different hardware revision (just like I would have to do for GLSL).

I think there are pros and cons for each and I think I would be right in saying once you know one quite well its easy to apply your existing knowledge. Good luck with which ever one you decide.

Cheers,
dhm

Share this post


Link to post
Share on other sites
I have been working with CG only so I cant say anything about GLSL.

CG works fine on NVidia hardware and can work on ATI but I found lots of little issues when working with ATI. I spent about 2 weeks trying to get some shadowmapping code running on an ATI card that worked perfectly on NVidia.

On the other hand there is lots of resources from NVidia with good examples and code.

Just my 2 cents.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this