Vertex Programs Programming

Well, hello all. I’ve recently come across the specs for the vertex program extension and I think it’s awesome! So, I’m reading the specs and I think to myself, I want to make my own vertex programs. More precisely, I wanted to port all my bump-mapping code. This bump-mapping code basically just finds texture coordinates of a light normal map given a light position and a triangle’s vertex. The code stretches and moves the light map on the triangle surface to account for light distance. Then I would dot3 the light map, and the triangle’s bump/normal map.
So, anyway, I read through most of the article, and I cannot find how to actually code these programs . All I’ve found are some opcodes and what they do, but not how to actually write programs and then load them into my app using the extension. Can anyone help me please? If I knew how to do this, I would get much more interactive rates with my bump-mapping! It would be much appreciated!

I think that you should read this paper :

Specs are not intended to be tutorials on how to use a special extension, it’s an indeep description to use as a reference. For tutorials and white papers you had better go on Nvidia or ATI developper site.
Hope it helps

[This message has been edited by Zeross (edited 04-28-2003).]

You should check out the Cg progamming language… it’s basically ‘C’ for graphics. It makes vertex and fragment shaders SOOOOO much easier to write.


It is usually good practise to write shader assembly before switching to a higher-level language.

Here’s a link to a small prog with vertex program:

Some very simple NV and 1 ARB Vertex Program examples on my site.

Thanks for the help! I downloaded the pdf Zeross gave me a link to, and it helped me understand vertex programs much better . Now, I’m curious. When a vertex program is loaded, it is executed every time a call to glVertex is given-either directly or indirectly such as through glDrawArrays-right? If not, have I totaly misunderstood how vertex programs work? I’m wondering because I want to know if vertex programs will let me do what I want to.
Basically, given three vertices of a triangle, I calculate a matrix based on it’s normals: out, up, and right. Then, using those normals, I calculate the distance between the triangle and a light source. I offset the lightmap texture from the center of the triangle according to a formula I use, then using the distance between the light and triangle, I model light attenuation. The algorithm works fine in software, but is horribly slow. I’m wondering how to pass in the three vertices to be used by the vertex program. I hope this all makes sense. I see potential, but just need a little guidance.

Yes, vertex programs are executed for every vertex drawn while the vertex program is bound.

Vertex programs definately can do that.
However, depending on the targeted hardware, you should keep your “software path” for OpenGL implementations that do not support vertex programming.