Pixel Shading in OpenGL

Hey all,

I’m just starting to get into pixel-shaders, and would very much appreciate it if someone would point me in the right direction. Links would be appreciated too. My queries are:

  1. How are pixel-shaders supported in OpenGL? Is it only OpenGL 1.4? Do Nvidia’s texture shaders have anything to do with this?

  2. Cg supposedly works with all programmable GPUs supporting DX8 or OGL1.4, regardless of vendor. Is this true in practice? If I use an ATI card, will Cg still work on it?

I have read the Learning Cg FAQ, but I only have a hazy picture as I’m not sure whether references to ‘shader’ in there always apply to both vertex and pixel shaders or to vertex shaders only in some circumstances.

For Nvidia: http://developer.nvidia.com
For Ati: http://www.ati.com/developer/

Those links are pretty much all you need, and of course knowing about opengl.org helps a lot too.

-SirKnight

  1. How are pixel-shaders supported in OpenGL? Is it only OpenGL 1.4? Do Nvidia’s texture shaders have anything to do with this?

There’s the ARB_fragment_program extension which, however, only is available in a hardware-accelerated way on Radeon 9700 or NV30. ARB_f_p is not part of OpenGL 1.4 however, so OGL 1.4 does not have any fragment program support. NVIDIA’s texture shaders + register combiners are kind of the OpenGL equivalent of DirectX pixel shaders (up to version 1.3 with a couple of extensions). ATI has the ATI_fragment_shader extension which is pretty much the same as DX pixel shaders version 1.4.

  1. Cg supposedly works with all programmable GPUs supporting DX8 or OGL1.4, regardless of vendor. Is this true in practice? If I use an ATI card, will Cg still work on it?

When you use the ARB_vertex_program Cg profile called arbvp1, you can use it on any card that supports ARB_vertex_program. Also the new 3dlabs cards support NV_vertex_program, so you can even use the vp20 Cg profile on those.
As for fragment shaders, currently Cg only supports DirectX pixel shaders and no OpenGL fragment programs other than NV30 fragment programs (which relies on an NVIDIA-specific fragment program extension).

Cheers.

Thanks Asgard for a great explanation. SirKnight, thanks for the links, and yes I’ve visited them before. It’s just that I can’t seem to find out exactly what I want to know (maybe I don’t know exactly where in there to look).

For example, Cg states that it is ‘compatible with both OpenGL and DirectX’, but I needed to know exactly what that meant, like in Asgard’s post the compatibility may be limited to certain extensions or certain chipsets only.