chracatoa

06-03-2003, 01:34 PM

I am trying to do something very simple using vertex programs but some weird things are happening.

I have the following calls:

-----

glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB,1 ,U.x,U.y,U.z,1);

glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB,2 ,V.x,V.y,V.z,1);

(...) /* glBegin, etc. */

glVertexAttrib4fARB(20,ecenter.x,ecenter.y,0,1);

glVertex4f(...);

(...)

-----

and I just want to do a very simple calculation: the new vertex position will be equal to ecenter.x*U+ecenter.y*V. This is my code:

-----

!!ARBvp1.0

PARAM U = program.env[1];

PARAM V = program.env[2];

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

ATTRIB pos = vertex.position;

ATTRIB color = vertex.color;

ATTRIB intexcoord = vertex.texcoord;

ATTRIB ecenter = vertex.attrib[20];

OUTPUT opos = result.position;

OUTPUT outcolor = result.color;

OUTPUT outtexcoord = result.texcoord;

TEMP tmp1,tmp2,npos;

# npos = ecenter.x * U + ecenter.y * V

MUL tmp1,ecenter.x,U;

MUL tmp2,ecenter.y,V;

ADD npos,tmp1,tmp2;

DP4 opos.x, mvp[0], npos;

DP4 opos.y, mvp[1], npos;

DP4 opos.z, mvp[2], npos;

DP4 opos.w, mvp[3], npos;

MOV outcolor, color;

MOV outtexcoord,intexcoord;

END

-----

I am still not using vertex.position, vertex.color.secondary and other parameters because I will use them as soon as I fix this simple problem. The final computation will be much more complex.

Any ideas?

[This message has been edited by chracatoa (edited 06-03-2003).]

I have the following calls:

-----

glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB,1 ,U.x,U.y,U.z,1);

glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB,2 ,V.x,V.y,V.z,1);

(...) /* glBegin, etc. */

glVertexAttrib4fARB(20,ecenter.x,ecenter.y,0,1);

glVertex4f(...);

(...)

-----

and I just want to do a very simple calculation: the new vertex position will be equal to ecenter.x*U+ecenter.y*V. This is my code:

-----

!!ARBvp1.0

PARAM U = program.env[1];

PARAM V = program.env[2];

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

ATTRIB pos = vertex.position;

ATTRIB color = vertex.color;

ATTRIB intexcoord = vertex.texcoord;

ATTRIB ecenter = vertex.attrib[20];

OUTPUT opos = result.position;

OUTPUT outcolor = result.color;

OUTPUT outtexcoord = result.texcoord;

TEMP tmp1,tmp2,npos;

# npos = ecenter.x * U + ecenter.y * V

MUL tmp1,ecenter.x,U;

MUL tmp2,ecenter.y,V;

ADD npos,tmp1,tmp2;

DP4 opos.x, mvp[0], npos;

DP4 opos.y, mvp[1], npos;

DP4 opos.z, mvp[2], npos;

DP4 opos.w, mvp[3], npos;

MOV outcolor, color;

MOV outtexcoord,intexcoord;

END

-----

I am still not using vertex.position, vertex.color.secondary and other parameters because I will use them as soon as I fix this simple problem. The final computation will be much more complex.

Any ideas?

[This message has been edited by chracatoa (edited 06-03-2003).]