Game Design Music and Art

vertex programs – naan

Junior Member

Posts: 2
From: india
Registered: 05-26-2004
can anybody tell me how do i use the large number of program parameter registers avilable on a GPU. the actual problem is that i am using Cg library and i have got a large number of per vertex parameters.firts i was using the attribute registers (with semantic NORMAL,TEXCOORD etc.) to piggyback the data but as my parameters grew,this method had to abandoned and i dont know the semantics for the parameter registers of the GPU. plz help me..


Posts: 1335
From: Melbourne, FL USA
Registered: 11-09-2002


Posts: 1335
From: Melbourne, FL USA
Registered: 11-09-2002
1. I'm assuming you are talking about passing in
variables to a vertex program. If so, here is an
example line from my exe:

glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB, 0,
lightPos.x, lightPos.y, lightPos.z, 0);

This passes in an environment variable named lightpos.
GL_VERTEX_PROGRAM_ARB says what type of program it's
going to. The 2nd "0" is the position in the environment
array that it's going to.

Getting to it inside the vertex program:

PARAM lightPos = program.env[0];

Another example:

glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB, 1,
position.x, position.y, position.z, 0);

PARAM camPos = program.env[1];

2. Long term I expect GLSLang to outpace Cg but at
this moment Cg is much more stable and can also
compile to Direct3D. It really depends on how well
Nvidia supports its language (or drops it in the

Full example code:


PARAM mvp[4] = { state.matrix.mvp };

ATTRIB iVertex = vertex.position;
ATTRIB iNormal = vertex.normal;
ATTRIB iTexCoord = vertex.texcoord[0];

PARAM lightPos = program.env[0];
PARAM camPos = program.env[1];

OUTPUT oPos = result.position;
OUTPUT texCoord = result.texcoord[0];
OUTPUT lightVec = result.texcoord[1];
OUTPUT viewVec = result.texcoord[2];

TEMP lv;

DP4 oPos.x, mvp[0], iVertex;
DP4 oPos.y, mvp[1], iVertex;
DP4 oPos.z, mvp[2], iVertex;
DP4 oPos.w, mvp[3], iVertex;

MOV texCoord, iTexCoord;

SUB lv, lightPos, iVertex;
MUL lightVec, lv, 0.001;

SUB viewVec, camPos, iVertex;




Posts: 1335
From: Melbourne, FL USA
Registered: 11-09-2002
So Naan, was that what you were asking for?