Sign in to follow this  
RealMarkP

Which Shader Language to Use?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

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