I’m having trouble with my reflection stuff.
Basically, I’m trying to implement per-pixel reflections into a cube map (from a normal map). I’m using the texture shader for the reflection. I’m trying to use a vertex program to set up the texel matrix - but I’m getting odd results.
Here’s the part of my vp that constructs the texture coordinate for the texture shader matrix:-
(c[8]->c[11] = inverse transpose modelview matrix)
(R0=normal, R1=tangent, R2=binormal, R3=NON-UNIT LENGTH eye-to-vertex vector)
// transform tangent by inverse transpose modelview matrix & move into first column of texel matrix:-
DP4 o[TEX1].x, c[8], R1;
DP4 o[TEX2].x, c[9], R1;
DP4 o[TEX3].x, c[10], R1;
// transform binormal by inverse transpose modelview matrix & move into second column of texel matrix:-
DP4 o[TEX1].y, c[8], R2;
DP4 o[TEX2].y, c[9], R2;
DP4 o[TEX3].y, c[10], R2;
// transform normal by inverse transpose modelview matrix & move into third column of texel matrix:-
DP4 o[TEX1].z, c[8], R0;
DP4 o[TEX2].z, c[9], R0;
DP4 o[TEX3].z, c[10], R0;
// move the eye-to-vertex vector into the fourth column of texel matrix:-
MOV o[TEX1].w, R3.x;
MOV o[TEX2].w, R3.y;
MOV o[TEX3].w, R3.z;
The results I’m getting are that if I tilt the camera down around the x-axis it looks correct, but if I rotate the camera around the y-axis, then tilt down the z-axis, the cube map tilts down the x-axis still. What am I doing wrong?
If I transform the eye-to-vertex vector by the modelview inverse transform and put the result in the w column I get the cube map in eye-space (ie. looks like its glued to the camera on the y-axis, but tilts correctly).
Please help me - it looks so good, but not correct. I feel I’m nearly there.