pixel shader language?

Started by
10 comments, last by cypherx 18 years, 8 months ago
OK theres like 20 different pixel shading langauges right now: Direct3D: ps_1_1 to ps_3_0 (asm-like) HLSL (high level) OpenGL: arb_fragment_program (asm-like) GLSL (high level) And Cg, which can compile to arb_fragment_program. (I saw somewhere that it supported some of Direct3D's languages. Is this true?) My questions is which of the above languages will be/is currently the most widely supported in hardware?
Advertisement
HLSL, GLSL and Cg are very common and highly supported.

5-6 languages, not quite the mellow dramatic 20...

Use which ever you like best for the graphics API you like...
Actually there's only 4 "used" languages:

HLSL - DirectX.
ARB_x_program - OpenGL.
OGLSL - OpenGL.

And then there's the bastard kid, Cg, which can compile to something useable by DirectX or to something useable by OpenGL.

And also ps 1.1 to 3.0 are just feature sets, not languages.
Yup, 1.1, 1.4, 2.0, and 3.0 are just the version of the pixel shader. LKater version can support more and different commands. Generally, you want to use the lowest version that will do what you need, so more cards can handle it. You may also want to include multiple versions of the shaders and run the highest one possible.

HLSL, GLSL, and the asm shaders are just the language used. HLSL and GLSL both compile to the asm language (IIRC). They will all have the same features exposed. HLSL/GLSL are both easier to learn (they have a very c like syntax), while the assembly typw can be tricky for a beginner. I think there is probably a small performance loss from the higher level languages, but I really don't know...
weird, don't know how I got logged out... that was me ^^^
Sean Henley [C++ Tutor]Rensselaer Polytechnic Institute
So HLSL compiles to DirectX-usable-assembly and GLSL compilles to OpenGL-usable assembly, and Cg compiles to both?
Quote:Original post by dyerseve
So HLSL compiles to DirectX-usable-assembly and GLSL compilles to OpenGL-usable assembly, and Cg compiles to both?


Something like that...
Sean Henley [C++ Tutor]Rensselaer Polytechnic Institute
In the end they all get compiled into the same thing that your "regular" code gets compiled into. Nothing but a bunch of on and off patterns that the processor's hardware has been designed to do something useful with.

In this case, the GPU as opposed to the CPU.

Unless you need to do some crazy optimization, go with the high level languages because they provide convenient commands and semantics that will make your life SO much easier.
Actualy IF you need crazy optimization, usually you will be better off using a high-level language. If you use it correctly the compiler will do the rest of the dirty work well enough.
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
Very true. There's always exceptional cases though. Let me rephrase. Unless you really know what you're doing and profile your code and REALLY think asm coding your shader is going to make a difference (or let you do something you wouldn't otherwise be able to do) then use the compilers =D

This topic is closed to new replies.

Advertisement