a small problem about lesson 22

Started by
1 comment, last by krobin 17 years, 4 months ago
There is a small problem in lesson 22(bump and multi-texture), VMatMult function I think. In the text, the description of this function is set v=M*v, but what it originally did in the code is v=v*M. It's wrong since opengl uses v=M*v. Also, for Homogenous Coordinate, we can't simply set v[3]=M[15], we should calculate v[3] as v[0],v[1],v[2]. So, instead of coding VMatMult like this: void VMatMult(GLfloat *M, GLfloat *v) { GLfloat res[4]; res[0]=M[ 0]*v[0]+M[ 1]*v[1]+M[ 2]*v[2]+M[ 3]*v[3]; res[1]=M[ 4]*v[0]+M[ 5]*v[1]+M[ 6]*v[2]+M[ 7]*v[3]; res[2]=M[ 8]*v[0]+M[ 9]*v[1]+M[10]*v[2]+M[11]*v[3];; v[0]=res[0]; v[1]=res[1]; v[2]=res[2]; v[3]=M[15]; } VMatMult should be: void VMatMult(GLfloat *M, GLfloat *v) { GLfloat res[4]; res[0]=M[ 0]*v[0]+M[ 4]*v[1]+M[ 8]*v[2]+M[12]*v[3]; res[1]=M[ 1]*v[0]+M[ 5]*v[1]+M[ 9]*v[2]+M[13]*v[3]; res[2]=M[ 2]*v[0]+M[ 6]*v[1]+M[10]*v[2]+M[14]*v[3]; res[3]=M[ 3]*v[0]+M[ 7]*v[1]+M[11]*v[2]+M[15]*v[3]; v[0]=res[0]; v[1]=res[1]; v[2]=res[2]; v[3]=res[3]; // Homogenous Coordinate }
Advertisement
Yes we are aware of this, but i can safely say that we won't be revisiting emboss bump mapping again, because of this we won't fix it right away (but we will take note of it).

v[3]=M[15]; actually works (i think) because m 12,13,14 is always 0 and v[3] 1s always 1 thus making res[3]=0*x+0*y+0*z+m[15]*1=m[15] (as far as i understand it).
Though it's a bit of a hack.
That's fine.
btw, is there any good tut on dot3 bump mapping?

This topic is closed to new replies.

Advertisement