hello,
i’m trying to generate the texcoords for a 3d object (let’s say a sphere) in order to make it reflective (using a cubemap texture), so given the cubemap texture and the vertex normals, can anyone help me with a vertex program (ARB) that can do that?
i made one on my own, but soething strange is happening…when i rotate the object (well, using glRotate), it also rotates the reflection too, but when i rotate my “camera” (using gluLookAt) it is ok, so, in fact, that’s what i don’t understand.
here’s my vp code:
!!ARBvp1.0
ATTRIB ipos =vertex.position;
ATTRIB icol =vertex.color;
ATTRIB inrml =vertex.normal;
ATTRIB itex1 =vertex.texcoord[1];
ATTRIB itex2 =vertex.texcoord[2];
ATTRIB itex3 =vertex.texcoord[3];
OUTPUT opos =result.position;
OUTPUT ocol =result.color;
OUTPUT otex0 =result.texcoord[0];
OUTPUT otex1 =result.texcoord[1];
OUTPUT otex2 =result.texcoord[2];
OUTPUT otex3 =result.texcoord[3];
PARAM modelv[4] ={ state.matrix.modelview };
PARAM modelvi[4] ={ state.matrix.modelview.inverse };
PARAM modelvit[4] ={ state.matrix.modelview.invtrans };
PARAM modelvp[4] ={ state.matrix.mvp };
PARAM ceyepos =program.env[0];
PARAM doi ={ 0, 0, 2, 0 };
TEMP vecrefl;
TEMP vecnorm;
TEMP pos;
TEMP vec;
TEMP nrml;
TEMP nrmlnorm;
TEMP eyepos;
################
DP3 nrml.x, modelvit[0], inrml;
DP3 nrml.y, modelvit[1], inrml;
DP3 nrml.z, modelvit[2], inrml;
DP3 nrmlnorm.w, nrml, nrml;
RSQ nrmlnorm.w, nrmlnorm.w;
MUL nrmlnorm, nrml, nrmlnorm.w;
ADD vec, -ceyepos, pos;
DP3 vecnorm.w, vec, vec;
RSQ vecnorm.w, vecnorm.w;
MUL vecnorm, vec, vecnorm.w;
MUL vec, nrmlnorm, doi.z;
DP3 vecrefl.w, nrmlnorm, vecnorm;
MAD vecrefl, vecrefl.w, vec, -vecnorm;
DP3 otex0.x, modelvi[0], vecrefl;
DP3 otex0.y, modelvi[1], vecrefl;
DP3 otex0.z, modelvi[2], vecrefl;
################
DP4 opos.x, modelvp[0], ipos;
DP4 opos.y, modelvp[1], ipos;
DP4 opos.z, modelvp[2], ipos;
DP4 opos.w, modelvp[3], ipos;
MOV ocol, icol;
MOV otex1, itex1;
MOV otex2, itex2;
MOV otex3, itex3;
END
kinda mess here, i’m learning
thank you