Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.6 - Reflections #63

Open
radhikamattoo opened this issue Oct 13, 2017 · 4 comments
Open

1.6 - Reflections #63

radhikamattoo opened this issue Oct 13, 2017 · 4 comments

Comments

@radhikamattoo
Copy link

I'm currently working on implementing section 1.6 of the homework for reflections. I conceptually understand how it works, but implementing it with my code is proving to be difficult.

I currently have a for loop iterating through all objects in the scene to test for intersections with the meshes. I thought that, along with testing for mesh intersections, this is where I would check for mirror intersections. I have set my mirror as y = -1, and in every iteration of the for loop I solve for t in the equation e_y + t * d_y = -1 to see if t > 0, meaning the ray cast from the camera intersected with the mirror. I then construct vectors r and d per the instructions in the textbook, and perform ray intersection on r to get the pixel value assign in my color matrix.

Unfortunately, my output image is exactly the same, with no reflections rendered at all. Is my algorithm flawed or is my thinking correct? My code is updated in my repo in a function called part4.

@jiangzhongshi
Copy link
Collaborator

Hi,

I suggest you test if the reflected ray does occur by adding a condition before you compute r and d. It is possible that you don't have rays shooting the floor (if you do orthographics), or some scene arrangement issue.

Best,
Zhongshi

@radhikamattoo
Copy link
Author

I thought that I already checked that the reflected ray occurs by checking that t > 0. I only construct r and d and perform ray tracing on r if the above condition passes.

@mafshar
Copy link

mafshar commented Oct 13, 2017

Hi,

I tried running in perspective and I do not get any reflections. I followed the same logic outlined above (and mentioned in office hours). I have:
ray_intersection_reflection = ray_origin + ( t_mirror * ray_direction); ray_normal_reflection = (0, 1, 0); // in the direction of the floor d = (ray_intersection_ref - origin).normalized().transpose(); r = d - 2(d.dot(n)) * n;

When I use perspective, my code takes an incredibly long time to terminate (still running after 30 minutes in release mode!)

@jiangzhongshi
Copy link
Collaborator

Hi,

As a debugging advice, if you do not see the reflection, you should go into your code, find the line that computes it. Then add multiple printing codes there to see what is going on, i.e. what everything's value is. And then you may be able to identify if it's the problem with the intersection, or shading model, etc.

And if the program is running long, it's always good to add a lot of intermediate printings so that you can be sure that your program is actually running and what is the current state, instead of going into some infinite loop caused by some bug.

Best,
Zhongshi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants