View Full Version : Vertex Programs Programming

04-28-2003, 02:53 PM
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 http://www.opengl.org/discussion_boards/ubb/frown.gif. 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! http://www.opengl.org/discussion_boards/ubb/smile.gif

04-28-2003, 03:23 PM
I think that you should read this paper : http://developer.nvidia.com/docs/IO/4449/SUPP/GDC2003_OGL_ARBVertexProgram.pdf

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 http://www.opengl.org/discussion_boards/ubb/smile.gif

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

04-28-2003, 06:45 PM
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.


04-28-2003, 09:41 PM
It is usually good practise to write shader assembly before switching to a higher-level language.

04-28-2003, 11:51 PM
Here's a link to a small prog with vertex program:

04-29-2003, 03:36 AM
Some very simple NV and 1 ARB Vertex Program examples on my site.

04-29-2003, 01:28 PM
Thanks for the help! I downloaded the pdf Zeross gave me a link to, and it helped me understand vertex programs much better http://www.opengl.org/discussion_boards/ubb/smile.gif. 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. http://www.opengl.org/discussion_boards/ubb/wink.gif

04-29-2003, 02:25 PM
Yes, vertex programs are executed for every vertex drawn while the vertex program is bound.

04-29-2003, 09:33 PM
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.