I have a stupid question. At least I hope that I choosed a right forum to ask it. 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.
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.
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. Thanx
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.
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:
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.
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? If so I don’t have anything more I’d like to ask for now.
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, 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