ARB_fragment_program details.

Started by
8 comments, last by Gorax 18 years, 7 months ago
Hi, I am trying to learn ARB_fragment_program to write vertex and fragment shaders for general-purpose applications. I know Cg but there is a bug in current Cg version and hopefully it will be resolved by the next release and I can't wait long enough for that release to come through. I have some questions regarding ARB_fragment_program. Q1- Does ARB_fragment_program support conditional statements like "if" and "else" statements similar to what we have in "Cg" language? Q2- Does ARB_fragment_program support looping statements like "while" and "for" loops similar to what we have in "Cg" language? Q3- How does ARB_fragment_program compare to ARB_fragment_shader and which is more worthy to learn? Q4- Is there some other high-language worthy of learning other than ARB_fragment_program and Cg and why? Please comment and all help is appreciated. Thanks. - FMS
Advertisement
Hi,
I don't know much about 1-3 as I am not familiar with Cg or shaders. On my travels trying to find out about them I saw the OpenGL Shader Language
http://www.opengl.org/documentation/oglsl.html

which may or may not answer Q4. As to why, I'd imagine it will be more widely supported by future graphics cards than Cg, as that's Nvidia-only. Although I may be wrong there.
"I must not fear. Fear is the mindkiller. Fear is the little death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. And when it has gone past me I will turn to see fear's path. Where the fear has gone there will be nothing. Only I will remain." ~Frank Herbert, DuneMy slice of the web
A1: No
A2: No
A3: I think ARG_fragment_shader just means you can use fragment programs written in the opengl shading language but I am not 100% on that.
A4: OpenGL Shading Language (aka GLSL GLSLang). Why? It is the official high level language of opengl.
super genius
Does OpenGL Shading language supports NPOT (non-power of two) texture lookups similar to the one we have in Cg?

Thanks.
The answers to your first two questions are "yes" if you are running on Nvidia hardware that supports the NV_fragment_program2 extension.
Quote:Original post by fms
I am trying to learn ARB_fragment_program to write vertex and fragment shaders for general-purpose applications.


Frankly, dont waste your time.

The assembler interface for cross vendor code is as good as dead and will never be updated again and will get left behind (and already is as the answer to your first two questions is no), NV are still extending the assembler interface via their own extensions however you'll be limited NV only hardware if you take this path.

If you are new to shaders the OpenGL Shading Language is really what you should be learning, or at a push Cg if you want to support D3D as well as OGL with the same shaders (however, unless Cg can be compiled to GLSL its also going to have problems on non-NV hardware when it comes to new features).

ARB_texture_non_power_of_two just allows you to perform a normal texture lookup on a non-power-of-two texture, so it doesnt require any specific instructions.

Now, if you ment EXT_texture_rectangle I cant find any details on how it interacts with GLSL, which is a tad annoying.
I don't think you can just ignore the assembly shaders just yet. There is still some "decent" video cards out there that don't support the GLSL. Or I am wrong in this?
super genius
afaik every ATI, NV and 3DLabs card which supports the assembler interface supports GLSL.

There might well be some cases where assembler is prefered, however if you are new to it there is little point in learning what is basically a dead extensions.
Actually the ATI Radeon 9200 does NOT support GLSL yet it has a programmable core (HLSL shaders work), and I'm guessing arb_vertex_program works too.
Assuming it's similar to the ARB_vertex_program extension, you can use an if/else block in an ARB_fragment_program, but it executes both paths, and then selects the appropriate value at the end, so it's somewhat slower than the higher level languages (like Cg (assuming you use the right profile), and GLSL), and the number of instructions increases very quickly, so you can't do too much if you continue to use them. However, you can't use for/while loops unless they can be unrolled into repeated blocks of code, and even then, you'd want to use Cg to produce the appropriate shader code for you, or you'll spend a lot of time producing fairly simple code, when you could be doing better things (imagine how long it would have taken for Doom 3 and Half-Life 2 to be made, if they were written in assembly).

[EDIT]
As the AP said, older videocards don't support GLSL, but they can use the older shaders. You can use Cg to pick the appropriate shading language profile to deal with various compatibility issues, but some cards wont support fragment shaders at all (like my GeForce 2).

This topic is closed to new replies.

Advertisement