PDA

View Full Version : arb vertex program not working



bumby
01-17-2005, 08:01 AM
Hello,

I have just begun experimenting with the arb vertex program in order to see how they work.

I am simply trying to pass a float in to the program and use it to shrink/grow a quad...the float varies from 0.5 to 2.0. over time in 0.05 increments.

const char EXPANDTEST[]= "!!ARBvp1.0\
ATTRIB iPos = vertex.position;\
ATTRIB iNormal = vertex.normal;\
ATTRIB iColor = vertex.color;\
ATTRIB iTex = vertex.texcoord;\
ATTRIB iTex1 = vertex.texcoord[1];\
PARAM mfactor = program.env[0];\
PARAM mvp[4] = { state.matrix.mvp };\
PARAM mvpinv[4]={ state.matrix.modelview.invtrans};\
PARAM lightdir = state.light[0].position;\
PARAM halfdir = state.light[0].half;\
PARAM specexp = state.material.shininess;\
PARAM ambientcol = state.lightprod[0].ambient;\
PARAM diffusecol = state.lightprod[0].diffuse;\
PARAM speccol = state.lightprod[0].specular;\
OUTPUT oPos = result.position;\
OUTPUT oColor = result.color;\
OUTPUT oTex = result.texcoord;\
OUTPUT oTex1 = result.texcoord[1];\
TEMP xfnorm;\
TEMP temp;\
TEMP dots;\
TEMP res;\
TEMP tpos;\
\
MUL tpos,mfactor,iPos;\ BLING BLING!
DP4 oPos.x, mvp[0], tpos;\
DP4 oPos.y, mvp[1], tpos;\
DP4 oPos.z, mvp[2], tpos;\
DP4 oPos.w, mvp[3], tpos;\
\
DP3 xfnorm.x, mvpinv[0],iNormal;\
DP3 xfnorm.y, mvpinv[1],iNormal;\
DP3 xfnorm.z, mvpinv[2],iNormal;\
DP3 res.w, xfnorm,xfnorm;\
RSQ res.w,res.w;\
MUL res.xyz,res.w,xfnorm;\
MOV xfnorm,res;\
DP3 dots.x, xfnorm, lightdir;\
DP3 dots.y, xfnorm, halfdir;\
MOV dots.w, specexp.x;\
LIT dots,dots;\
MAD temp,dots.y,diffusecol,ambientcol;\
MAD oColor.xyz,dots.z,speccol,temp;\
\
MOV oColor.w,diffusecol.w;\
MOV oTex, iTex;\
MOV oTex1, iTex1;\
END";

I see no effect on the quad. I also tried simply multiplying the position by a constant directly:
ie changed:
MUL tpos,mfactor,iPos;\
to
MUL tpos,2.0,iPos;\
and it didnt work
although if i changed the 2.0 to 0.0 i see nothing..which makes sense.

There are no errors reported either by glGetString(GL_PROGRAM_ERROR_STRING_ARB)
or
glGetError()

Any idea why it wouldnt work?

Thanks,

Jeremy

endash
01-17-2005, 09:10 AM
You might want to end your lines with \n\ not just \. I'm not sure why you aren't getting an error, but as I read what you wrote, OpenGL is seeing a big one-line string with no newlines in it.

bumby
01-17-2005, 10:21 AM
nope, no workie!

Just to clarify, i see the textured quad, but dont see it changing like i want.

zeckensack
01-17-2005, 01:35 PM
Originally posted by bumby:
I see no effect on the quad. I also tried simply multiplying the position by a constant directly:
ie changed:
MUL tpos,mfactor,iPos;\
to
MUL tpos,2.0,iPos;\
and it didnt workShouldn't work ;)
You multiply all four components of the source vector by two. Later, perspective divides divides x, y and z by w. c*x/(c*w)=x/w for all c!=0, if you catch my drift.

although if i changed the 2.0 to 0.0 i see nothing..which makes sense.Absolutely :)

Try your first shader and this:
float bling[4]={2.0f,2.0f,2.0f,1.0f};
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 0,bling);

bumby
01-17-2005, 01:44 PM
Criminy!

That was it!

Thanks a billion!