what language for shaders?

Started by
6 comments, last by TheOther 18 years, 4 months ago
what is the best for working on next-gen effects like parallax mapping and the sort? i've heard of HLSL, CG, opengl shading language, and i can't find difference s in them. or rather, what is the best shading language for opengl? directx? thanks in advance
Advertisement
If your using OpenGL then GLSL (Or opengl shader language) is the most common. For DirectX then its HLSL. CG isn't really good because it's not as supported as HLSL and GLSL.
______________________________________________________________________________________With the flesh of a cow.
All of the languages you mentioned can be used to implement a parallax mapping shader, and the difficulty level among them is almost exactly equivalent.

HLSL is DirectX specific, GLSL (OpenGL Shading Language) is OpenGL specific and CG can be used in both. Which of these is suitable/best for you depends on the rest of the project specifications.

Niko Suni

But Cg could only be used on nVidia Hardware. Or is it possible to use Cg programs on ATI chips too?

mod42
AFAIK Cg kan be used on both nVidia and Ati hardware. Although I haven't tested it yet, I have a strong feeling that Cg will run faster on nVidia hardware than the equivalent Ati hardware, since nVidia has developed Cg.
Killers don't end up in jailThey end up on a high-score!
Having working in GLSL, CG and attended a *few* sessions by M$ on HLSL I have to say there is very little in them in terms of learning time. If you can work in one, the time to convert between them is very low.

As said, GLSL for OpenGl, HLSL for DirectX is how I would go.

GOCP
Quote:Original post by nife
AFAIK Cg kan be used on both nVidia and Ati hardware. Although I haven't tested it yet, I have a strong feeling that Cg will run faster on nVidia hardware than the equivalent Ati hardware, since nVidia has developed Cg.


You can use it on ATI as long you target ARB_vp and ARB_fp, but these are outdated. I heard that Cg runs ok on ATI now but never used it much.

I'm using GLSL and I think it's the better choice for GL programming.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Quote:Original post by V-man
Quote:Original post by nife
AFAIK Cg kan be used on both nVidia and Ati hardware. Although I haven't tested it yet, I have a strong feeling that Cg will run faster on nVidia hardware than the equivalent Ati hardware, since nVidia has developed Cg.


You can use it on ATI as long you target ARB_vp and ARB_fp, but these are outdated. I heard that Cg runs ok on ATI now but never used it much.

I'm using GLSL and I think it's the better choice for GL programming.


Yup. There's some good discussions on this topic here in this very thread, but I was able to use Cg on both my NVidia and ATI hardware. Though there's some (understandable) clunkyness with this interface on the ATI side, as it only communicates with the hardware using the "older" ARB_vp and ARB_fp extensions.

This topic is closed to new replies.

Advertisement