Hey people.
I really need your help.
I’m doing a very basic ray casting.The eye is at (0,0,-f)
and the view window is square with center is in (0,0,0),sphere intersect,
without shading or light. I have this effect that bothers me:
The spheres look fine (cycle) when their center located at (0,0,something)
but when the center moves some distance in x or y direction
the sphere starts to look (not at once) more like an allipse (is that effect correct??).
when I add shading (eye = light source) those spheres look ugly so have to correct in
the previous stage.
the simple code:
void RayCast(Scene myscene,Image *result)
{
int x,y;
int w,h;
Point E,P0,L0;
Vector d;
Vector dVx = {1.0,0.0,0.0};
Vector dVy = {0.0,1.0,0.0};
Line ray;
Color col;
w = myscene.width; /* (2w)(2*h) image and view window size (one to one pixel) */
h = myscene.height;
E = myscene.eye;
P0.x = -w;
P0.y = -h;
P0.z = 0.0;
L0 = P0;
for(y=-h; y<h; y++) {
P0=L0;
for(x=-w; x<w; x++) {
ray.point = P0;
vminus(P0,E,d); /* d = P0-E */
vnormalize(d);
ray.direction = d;
col = Ray_Trace(ray,myscene);
SetPixel(result,col,x+w,y+h); /* start with (0,0) */
vinc(P0,dVx); /* P0 += dVx */
}
vinc(L0,dVy);
}
}
Thank you.
Best Wishes.