alecjacobson / computer-graphics-ray-casting

Computer Graphics Assignment about Ray Casting
30 stars 27 forks source link

bunny is greenish #24

Open FannieZhao0317 opened 5 years ago

FannieZhao0317 commented 5 years ago

image sphere and triangle look just fine..

abhimadan commented 5 years ago

This is likely related to how you're calculating your triangle normals. The triangles are given in a specific order to ensure that their normals are consistently ordered; computing cross products in a different way than what the given order suggests can make them point the opposite way (and thus have a different colour).

In a somewhat roundabout way, you can also notice this by looking at the plane colours. You can immediately tell which direction their normals are pointing, and comparing their colours with the colours on the triangles can give you a sense of which direction the triangle normals are pointing. Given that, what can you tell about the triangle normals in your image versus the triangle normals in the expected image?

FannieZhao0317 commented 5 years ago

This is likely related to how you're calculating your triangle normals. The triangles are given in a specific order to ensure that their normals are consistently ordered; computing cross products in a different way than what the given order suggests can make them point the opposite way (and thus have a different colour).

In a somewhat roundabout way, you can also notice this by looking at the plane colours. You can immediately tell which direction their normals are pointing, and comparing their colours with the colours on the triangles can give you a sense of which direction the triangle normals are pointing. Given that, what can you tell about the triangle normals in your image versus the triangle normals in the expected image?

Right! I noticed that the normal image for triangle.cpp is also yellowish. Thank you so much for reminding me about the direction of normal vectors!