### Post by jzarra on Jul 17, 2020 11:55:38 GMT

Hello!

As always thanks for your attention and support.

Currently I am going through Chapter 11. Everything seems cool so far, but checking out my reflected spheres on a mirror surface (material.reflective = 1) they seem to get stretched.

I attach a sample image, where it can be appreciated in the left mirror the enlargement of the middle green sphere, which I am sure it is abnormal since a flat mirror does not distortion images in this way.

A little bit of background so far is that the mirrors at the back were not reflecting nothing at all. This was because my implementation was not transforming the normal vector {0,1,0} of the XZ plane.

After realizing of this, I override the normal_at function to apply the transformation matrix to the normal, similar to how a sphere overrides the normal_at function. The implementation for a plane is different from the sphere because I assume that for my XZ plane the object_normal is always pointing towards the +Y axis {0,1,0}. In other words, I do not consider the specific point where the ray hits the plane, since wherever happens the normal vector will have the same value. So basically my normal_at function applies the transpose of the inverse transformation matrix of the Plane instance like this:

Has anyone come out with a similar situation? What are your thoughts? Please let me know your comments, I highly appreciate it since I might be assuming something incorrectly, made a mistake in my implementation, etc.

If you are curious about the rest of my code please let me know. You could also take a glance at my repository for this project github.com/JSebastianZ/Ray-Tracer .

Thanks!

As always thanks for your attention and support.

Currently I am going through Chapter 11. Everything seems cool so far, but checking out my reflected spheres on a mirror surface (material.reflective = 1) they seem to get stretched.

I attach a sample image, where it can be appreciated in the left mirror the enlargement of the middle green sphere, which I am sure it is abnormal since a flat mirror does not distortion images in this way.

A little bit of background so far is that the mirrors at the back were not reflecting nothing at all. This was because my implementation was not transforming the normal vector {0,1,0} of the XZ plane.

After realizing of this, I override the normal_at function to apply the transformation matrix to the normal, similar to how a sphere overrides the normal_at function. The implementation for a plane is different from the sphere because I assume that for my XZ plane the object_normal is always pointing towards the +Y axis {0,1,0}. In other words, I do not consider the specific point where the ray hits the plane, since wherever happens the normal vector will have the same value. So basically my normal_at function applies the transpose of the inverse transformation matrix of the Plane instance like this:

`void Plane::normal_at(Matrix& inv_tx, Vector& normal) {`

Vector object_normal = this->m_plane_normal; // all plane instances have normal pointing towards +Y {0,1,0}

Vector world_normal = Matrix::multiply_vector(Matrix::transpose(inv_tx), object_normal);

// returns normal from object space to world space.

normal = Vector::normalize(world_normal); // normalize the normal

}

Has anyone come out with a similar situation? What are your thoughts? Please let me know your comments, I highly appreciate it since I might be assuming something incorrectly, made a mistake in my implementation, etc.

If you are curious about the rest of my code please let me know. You could also take a glance at my repository for this project github.com/JSebastianZ/Ray-Tracer .

Thanks!