PDA

View Full Version : ___ CG ___



Orzech
12-10-2003, 02:40 AM
Hello

I have a stupid question. At least I hope that I choosed a right forum to ask it. http://www.opengl.org/discussion_boards/ubb/wink.gif So... what is the difference between CG and OpenGL shaders? Are they something similiar and do they have the same purpose? I don't really know anything about it so I'll appreciate any help.

Thanx

Corrail
12-12-2003, 01:08 AM
The main difference between CG and GLslang is that the high shading language compiler of GLslang is included in the OpenGL driver of the implementation. So there are A LOT of optimization possibilities.

azazello
12-12-2003, 02:06 AM
cg - developed by NVidia, GLSlang - by 3Dlabs (and became to be official HL language for OpenGL, when cg was restricted).

Orzech
12-12-2003, 09:23 AM
Ow, I see. http://www.opengl.org/discussion_boards/ubb/smile.gif Now it seems to be clear for me. Thanks guys!

Orzech
12-12-2003, 09:28 AM
Hmmm... I thought of another question (if you don't mind). Is it possible to use CG with OpenGL? Does a graphics API has to provide some additional feedback for managing CG code? I'm just curious. http://www.opengl.org/discussion_boards/ubb/smile.gif Thanx

azazello
12-12-2003, 11:14 AM
>>Is it possible to use CG with OpenGL?
ARB_profile & NV20/nv30 profile(Win32/Linux, but not a FreeBSD/MacOS X).

Riff
12-12-2003, 12:17 PM
The CG compiler emits fragment program code so OpenGL is not required to provide additional shader management functionality and neither are you forced to use the CG runtime library. There has to be some way to bind variables to certain API constructs, but thats really about it for CG.

>>Does a graphics API has to provide some additional feedback for managing CG code? I'm just curious.

mchristen
12-12-2003, 12:54 PM
The most important advantage of OpenGL Shading language is the integration into OpenGL, you can access OpenGL states with built-in uniforms. For example you set lighting with:

glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_amb);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_dif);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_spec);

and then access your values inside the shader with gl_LightSource[0].ambient etc.

The benefit is better portability and compatibility between shaders of different authors. In CG everyone used his own uniform variables and it resulted in a complete lack of portability between different C++ programs.

Imagine someone writes a OGLSL phong lighting fragment shader using built-in uniforms only, it is a matter of a few minutes to integrate this shader into someones existing OpenGL program... And if the end-user doesn't have a video card with shader support he will still see standard OpenGL (per vertex) lighting.

--Martin

Orzech
12-13-2003, 06:19 AM
Thank you for your help. http://www.opengl.org/discussion_boards/ubb/smile.gif

To sum up, I think you've answered a question I wanted to ask now... I mean what is better? I see that for OpenGL GLslang is the best option, right? http://www.opengl.org/discussion_boards/ubb/smile.gif If so I don't have anything more I'd like to ask for now.

Thanks once again!

Corrail
12-13-2003, 06:29 AM
Yes, GLslang is the best option but it is supported by 3DLabs and ATI (inofficial) only. And I noticed that ATI's implementation has some major bugs... :-)

azazello
12-13-2003, 07:24 AM
As I know, NVidia GLSlang implementaion will be very soon(looks like in the same time with official ATI implementation). Cg also will be updated.

Corrail
12-14-2003, 01:13 AM
nVidia and GLslang? Very soon?
This is the first time I heard something like this. But I hope it is true!

Orzech
12-14-2003, 05:30 AM
Hmmm... I thought it would be nice if you knew some tutorials about GLslang. Do you know any? It is rather hard to learn from technical specifications. http://www.opengl.org/discussion_boards/ubb/wink.gif

Thanx in advance! http://www.opengl.org/discussion_boards/ubb/smile.gif

Ffelagund
12-14-2003, 06:38 AM
Hi, i have a proponsal to all of yours: The only source of glslang examples are the ASHLI, form ATI, and ogl2sdk, form 3DLabs. I Propose to create a web related to GLSLang. I can provide the site (a subdomain of my site www.typhoonlabs.com, (http://www.typhoonlabs.com,) in construction, and with no accupation for now) with all the glslang community contributions, source code, demos, tutorials, etc.
One site for all people that want to learn GLSLang, but i need all your colaborations http://www.opengl.org/discussion_boards/ubb/smile.gif


P.D: forgive my bad english please http://www.opengl.org/discussion_boards/ubb/smile.gif

Zengar
12-14-2003, 07:09 AM
Originally posted by ayaromenok:
Cg also will be updated.

I thought thay dropped it in favour of glSlang. It wouldn't make much sence to continue it, anyway.

mchristen
12-14-2003, 09:12 AM
I recently created a webpage with some OGLSL examples, located at: http://www.clockworkcoders.com/oglsl/

Right now, it only contains very simple tutorials, current OGLSL implementations are just not as advanced (or even have bugs).

If you created some shaders I can add some links to your site, or you can send them to me.

--Martin

Corrail
12-14-2003, 09:41 AM
Ey, cool site!!
Especially the VS.NET GLslang coloring!! Thank you, guy!

PS: Which GLslang implementation do u use?

mchristen
12-14-2003, 10:14 AM
PS: Which GLslang implementation do u use?

Shader Spec 1.051 http://www.opengl.org/discussion_boards/ubb/wink.gif

I tested everything with ATI 'cod hotfix' driver and 3Dlabs current driver.

--Martin

Ffelagund
12-15-2003, 01:40 AM
Well http://www.opengl.org/discussion_boards/ubb/smile.gif , i promise send my "experiments" with glslang to your web http://www.opengl.org/discussion_boards/ubb/smile.gif

Orzech
12-15-2003, 06:29 AM
Originally posted by mchristen:
I recently created a webpage with some OGLSL examples, located at: http://www.clockworkcoders.com/oglsl/

That's just what I've been looking for. Thanks. http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by Orzech (edited 12-15-2003).]