karansher / computer-graphics-ray-casting

Computer Graphics Assignment about Ray Casting
1 stars 0 forks source link

upside down background in my result Images #20

Open FarzanehCS opened 2 years ago

FarzanehCS commented 2 years ago

Hi, I am getting the following image, instead of the ones shown on the A2's repo!

I get this:

image

VS this correct one in the repo:

image

Not sure why! I am guessing the problem could be how I create the ray vector. I use this vector as the d in this formula and then multiply it by the transformation matrix. Similar to:

image

So I am using the vector [u_i, v_j, -d] is used as it says (i.e. I use u, v, -camera.d). Also, I am aware that in our case we should use u_j, and u_i instead.

What could be the problem here?

Ming-Yeung-Alfred-Meng commented 2 years ago

The top half of the pixels detect the blue plane which is actually below the sphere...that means there is something wrong with the t value of your ray at detection. There are two possibilities/cases, 1) your rays point toward the correct direction, -w, then in plane's intersect(), you are only allowing negative values of t, 2) your rays point toward the opposite direction, then fix in it viewing_ray.

FarzanehCS commented 2 years ago

So I see if I use u, -v, -camera.d, i.e. if I use -v, the issue is solved. But I am not sure why? Is that because we consider the top left as the origin of the image plane? I still do not understand why?

panuelosj commented 2 years ago

Yes, it's because we take the (0,0) pixel to be the top left with positive values pointing down, while in the camera space basis, positive v points up.