i must have missed something in your explanation cass. :-/
I have tried different ways:
- local parameters : inv(modelview * projection).
- matrix bindings as state.matrix.projection.inverse.
both gives different results as far i can see but not the right vector i need for the scan inside the 3Dtexture.
In the code below, fragment.position is normalised then transformed by (1) or (2) normalised and finally scaled to texture w,h,d (here a 646464).
-> code:
TEMP texCoords;
TEMP res;
TEMP empty;
TEMP hit;
TEMP realPos;
TEMP foundPos;
TEMP vdir;
TEMP vdirx;
TEMP vdiry;
TEMP vdirz;
TEMP vdirw;
TEMP vdirTex;
TEMP dot;
PARAM startCoords = { 1.0, 1.0, 1.0, 1.0};
PARAM hitDone = { -1.0, -1.0, -1.0, -1.0 };
PARAM vide = { 0.0, 0.0, 0.0, 0.0 };
PARAM viewport={0.0015625,0.00209,1.0,1.0};
PARAM two={2.0,2.0,2.0,1.0};
PARAM texSize = {0.015,0.015,0.015,0.015};
PARAM zRange = {-0.01, -0.01, 0.01, -0.01};
PARAM invProjM0= program.local[0];
PARAM invProjM1= program.local[1];
PARAM invProjM2= program.local[2];
PARAM invProjM3= program.local[3];
#PARAM invProjM0= state.matrix.projection.inverse.row[0];
#PARAM invProjM1= state.matrix.projection.inverse.row[1];
#PARAM invProjM2= state.matrix.projection.inverse.row[2];
#PARAM invProjM3= state.matrix.projection.inverse.row[3];
ATTRIB tex0 = fragment.texcoord[0];
OUTPUT out = result.color;
OUTPUT zout = result.depth;
MOV vdir,fragment.position;
#normalised window coordsâŚ
MUL vdir,vdir,two;
MUL vdir,vdir,viewport;
ADD vdir,vdir,hitDone;
#vector tranform by matrixâŚ
SWZ vdirx,vdir,x,x,x,x;
SWZ vdiry,vdir,y,y,y,y;
SWZ vdirz,vdir,z,z,z,z;
MOV vdirw,startCoords;
MUL vdirx,vdirx,invProjM0;
MUL vdiry,vdiry,invProjM1;
MUL vdirz,vdirz,invProjM2;
MUL vdirw,vdirw,invProjM3;
ADD vdir,vdirx,vdiry;
ADD vdir,vdir,vdirz;
ADD vdir,vdir,vdirw;
#normalisationâŚ
DP3 dot,vdir,vdir;
RSQ dot,dot.x;
MUL vdir,vdir,dot;
MUL vdirTex,vdir,texSize;
MUL vdir,vdir,zRange;
#init scan3d.
MOV hit,hitDone;
MOV empty,vide;
MOV texCoords,tex0;
#start scan iteration0
TEX temp, texCoords, texture[0], 3D;
CMP res, hit, temp, res;
SLT hit,empty,res;
ADD hit,hitDone,hit;
ADD texCoords,vdirTex,texCoords;
etcâŚ
/* oops modified wrong texture coords below*/
Note that the bounding box corners (s,t,r) correspond to texture3D bounds [0,1].
Sorry for not providing any shot, our website is down due to the probs on internet right now
[This message has been edited by Ozzy (edited 12-02-2003).]