Which Shader Language to Use?

Started by
3 comments, last by RealMarkP 15 years, 7 months ago
I am incorporating a shader system into my game engine but I don't know which way to go. The Engine uses both OpenGL and DirectX so I am limited to: Cg - supports both DX & OGL. Shader Assembly - supports Both?? I don't mind learning the Assembly, are there any advantages/drawbacks to using assembly over CG or vice versa? I looked through the archives and most Cg/ASM arguments are from 2001-2002 and they all bash Cg. So Could I get a second opinion?
------------Anything prior to 9am should be illegal.
Advertisement
Last I heard, Cg had some issues, but assembly is pretty much the wrong choice for anything modern nowadays, so Cg is your only other option there.

Why do you support both GL and D3D?

Another option is to build your own intermediate shader description methodology that can translate to GLSL or HLSL, this is what renderers like Ogre appear to do (in addition to directly supporting either).
On AMD/ATI hardware GLSL is the only way to get to the modern features of the GPU when using OpenGL. The assembler interface is stuck back before the SM2.0 days.
I don't think "shader assembly" means quite what you think it means. It's not something that's cross-platform between DX and OpenGL, or even between HLSL and Cg. Shader assembly is only for DirectX and HLSL. It's not really assembly code directly executed by the GPU either, it's more of a bytecode that gets translated by the driver into something the GPU can execute.

As phantom mentioned, these days shader development is almost always done in a high-level shader language. It's much more convenient and productive, and in DX it let's you target multiple shader profiles with the same code. In fact if you're working with DX10/SM40, you can't even use assembly anymore.

My suggestion is to use HLSL and the Effects framework for DirectX, and CgFX if you work with OpenGL. The Effects framework is a gift from above, it's incredibly flexible and useful. CgFX isn't nearly as great, but it's a heck of a lot better than nothing.
I was thinking of dropping OpenGL support for now anyway, so I guess going with FX files is the way to go. Thanks for the info so far.
------------Anything prior to 9am should be illegal.

This topic is closed to new replies.

Advertisement