Original Post
hihi!
i was trying to compute the eye ray direction. I was having some difficulty computing the right intersection coordinates with the scene bounding box, so i decided to fall back on the eye ray direction...
i was using the forumla given somewhere in this forum:
//x = xleft + (0.5 + i)dx
//y = ytop + (0.5 + j)dy
i suppose u all used the near view plane as a start, compute its world coords for its corners, and use the above forumla to determine the ray directions
znear is 1.0f
origin is "camera eye position" at (0,0,20)
IN.position(WPOS) gives the window screen coords
near viewplane world coord corners:
//topleft(-1.33,1.56,19.99)
//topright(2.08,1.56,19.99)
//bottomleft(-1.33,-1.56,19.99)
//bottomright(2.08,-1.56,19.99)
float3 ComputeRayDirection(Fragment IN, Viewplane viewplane, float2 viewport)
{
float3 dir = float3(0,0,0);
float dx = (viewplane.topright.x - viewplane.topleft.x) / viewport.x;
float dy = (viewplane.topright.y - viewplane.bottomright.y) / viewport.y;
dir.x = viewplane.bottomleft.x + (0.5 + IN.position.x) * dx;
dir.y = viewplane.bottomleft.y + (0.5 + IN.position.y) * dy;
dir.z = 0;
dir = normalize(dir - origin);
return dir;
}
the resulting direction happened to be quite small numbers
eg (0.014,0.008,-0.99)
does that make sense??
thx!
Edwinz