PDA

View Full Version : Speed of glProgramEnvParameter4fvARB



rviney
02-10-2003, 08:54 PM
Hi,

I've recently been replacing all my per-vertex setup code with vertex programs using ARB_vp. For each polygon I have a matrix to transform from world space to texture space for bump mapping, and so before rendering each polygon with glDrawElements, I do the following:


// Put poly's onb into vertex program constant memory
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 4, &poly->onb().tangent().x());
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 5, &poly->onb().binormal().x());
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 6, &poly->onb().normal().x());
But I'm not sure about the speed of updating the vertex program constant memory, especially for every polygon. Is it fast? Is there a better way to update it? Can I set all three at once?

And on a slightly different topic ... is it worth replacing the cpu per-vertex setup with a vertex program on cards like the GeForce 1? Because it would have to emulate the vp in software anyway ... and then couldn't use the hardware accelerated texture matrix and transform unit.

Thanks in advance,
Richard

jra101
02-10-2003, 09:51 PM
The fastest way would be to have an array of tangents, an array of binormals, an array of normals, and an array of vertices. Then use standard OpenGL vertex arrays.

something like this:

glVertexAttribPointerARB(0, ..., vertices);
glVertexAttribPointerARB(1, ..., tangent);
glVertexAttribPointerARB(2, ..., binormal);
glVertexAttribPointerARB(3, ..., normal);

glEnableVertexAttribArrayARB(0);
glEnableVertexAttribArrayARB(1);
glEnableVertexAttribArrayARB(2);
glEnableVertexAttribArrayARB(3);

glDrawElements(...);

glDisableVertexAttribArrayARB(0);
glDisableVertexAttribArrayARB(1);
glDisableVertexAttribArrayARB(2);
glDisableVertexAttribArrayARB(3);


[This message has been edited by jra101 (edited 02-10-2003).]