View Full Version : Why does this vertex-program not work?

06-27-2003, 03:26 AM
const unsigned char ARBVP[] =
# This is a sample ARB Vertex Program\n\
ATTRIB iPos = vertex.position;\
ATTRIB iColor = vertex.color;\
ATTRIB iTex0 = vertex.texcoord[0];\
ATTRIB iTex1 = vertex.texcoord[1];\
ATTRIB iTex2 = vertex.texcoord[2];\
ATTRIB iTex3 = vertex.texcoord[3];\
PARAM mvp[4] = { state.matrix.mvp };\
OUTPUT oPos = result.position;\
OUTPUT oColor = result.color;\
OUTPUT oTex0 = result.texcoord[0];\
OUTPUT oTex1 = result.texcoord[1];\
OUTPUT oTex2 = result.texcoord[2];\
OUTPUT oTex3 = result.texcoord[3];\
# This just does out vertex transform by the modelview projection matrix\n\
DP4 oPos.x, mvp[0], iPos;\
DP4 oPos.y, mvp[1], iPos;\
DP4 oPos.z, mvp[2], iPos;\
DP4 oPos.w, mvp[3], iPos;\
# Write our color out directly\n\
MOV oColor, iColor;\
MOV oTex0, iTex0;\
MOV oTex1, iTex1;\
MOV oTex2, iTex2;\
MOV oTex3, iTex3;\

It does transform the vertices correctly into clip-space, but it seems not to pass the texture-coordinates through.

glProgramStringARB does not return an error, therefore i think it should work. Does anyone see an error here?


06-27-2003, 04:53 AM
I don't know what hardware you have but you have to have 4 texture coordinates.

I have used 5 (and even more) tex coords while having only 4 available and I didn't get error messages.

I don't really see bugs in the code, but make sure the string is well formed as well.

Julien Cayzac
06-27-2003, 07:30 AM
Originally posted by Jan2000:
const unsigned char ARBVP[] =

Nothing to do with vertex program, but multiline string litterals are evil (as "won't be supported forever since they're deprecated).
Correct code style:

const unsigned char ARBVP[] =


06-27-2003, 11:29 AM
Well, the \n didnīt make it work. But i didnīt expect that.

I have a Gf 4200, so i do have 4 TUs. And i do use all of them. I want this program to calculate some texcoords, i would have to upload every frame else. So i first tried to make a program, which does effectively do nothing, except passing all parameters through, so that the old method works and i can slowly proceed forward.


06-27-2003, 11:58 AM
Have you tried calling glGetString(GL_PROGRAM_ERROR_STRING_ARB)?

06-27-2003, 12:37 PM
I tracked the bug, but i donīt understand it. Here is, what i do:

TU 0: normalization cubemap
TU 1: bump-map
TU 2: 3D lightmap
TU 3: texture

If i set the tex-env-combine parameters up to not use the 3D lightmap, everything works fine! Even with the VP. That means i can see the base-texture, the bumpmapping works and also the normalization is as expected.
If i disable the VP it works even with the 3D lightmap.
For TU 2 i do use the texture-matrix to create texture-coords. At the moment i donīt know, if the VP bypasses this (but i am quite sure it does). Therefore i commented the texture-matrix stuff out and set my 3D texture to all white. That means, no matter how the texcoords could be, the texel color will always be white, therefore the 3D lightmap cannot influence the image anymore. But still everything gets black! However everything else works. I do have some stuff, which is not rendered with the VP and if i stand in front of it, i can see the black siluettes (?) of the other polys.
Is there a restriction, that 3D textures (or there texcoords) cannot be used in VPs??? I will search the spec for something like that, but i donīt think, this should be the case.
Really strange.


06-30-2003, 01:19 AM
>>That means, no matter how the texcoords could be, the texel color will always be white, therefore the 3D lightmap cannot influence the image anymore.<<

Depends on the filtering. Don't forget to set the border color to white, too.