alecjacobson / computer-graphics-ray-casting

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

Triangle Soup Normal Direction #7

Closed AbdallaGomaa closed 6 years ago

AbdallaGomaa commented 6 years ago

Every triangle will have two surface normals, one in the "+ve" direction and one in the "-ve" direction. For the normal we return, are we supposed to pick a specific one? The reason I am asking is I get this image as my normal.ppm. While for the most of it it looks correct, the colors aren't the same as the one in the assignment description. I'm guessing that's because some normals are pointing in a certain direction and some are pointing in another. Is there a specific direction we're supposed to be picking? If so, what is it?

normal

johnkanji commented 6 years ago

Generally in graphics triangles have a front and a back which is determined by the order of the vertices. You should not encounter any problems as long as you are consistent with your vertices when computing the normal. If you are 100% sure you're being consistent the problem may lie elsewhere.

AbdallaGomaa commented 6 years ago

I'm kinda confused to what being consistent with the vertices means. Each triangle has different vertices, are they supposed to be ordered in a certain way? If I should just use vertices at the same index then I already do that.

On Mon, Sep 24, 2018, 4:51 PM johnkanji notifications@github.com wrote:

Generally in graphics triangles have a front and a back which is determined by the order of the vertices. You should not encounter any problems as long as you are consistent with your vertices when computing the normal. If you are 100% sure you're being consistent the problem may lie elsewhere.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alecjacobson/computer-graphics-ray-casting/issues/7#issuecomment-424120486, or mute the thread https://github.com/notifications/unsubscribe-auth/AYY2o30YBe_VF65mxDxbpizTtY6tvSK1ks5ueUXRgaJpZM4W3Tkf .

johnkanji commented 6 years ago

If you are always using the same indices for each triangle to compute the normal then they would all be correct or all be flipped, which doesn't seem to be the case here. Therefore, the error may be earlier in your intersection computation, or perhaps in first_hit.

AbdallaGomaa commented 6 years ago

I get this is my id.ppm, doesn't this mean I should be computing the intersection and first_hit correctly? id

AbdallaGomaa commented 6 years ago

Nevermind, found my mistake

lcapacitor commented 6 years ago

How long did your implementation take to render this triangle soup out? Mine is going to take a like century...

AbdallaGomaa commented 6 years ago

Takes about 3-5 mins

lcapacitor commented 6 years ago

Thanks for replying. May I know how long it takes to render one triangle?

AbdallaGomaa commented 6 years ago

If you mean just running the program for one triangle then it happens straight away. Takes almost as much time as it does for the sphere

lcapacitor commented 6 years ago

Thanks. I think there must have something to improve in my code since mine takes more than 20sec to get the "triangle.json" rendered. Anyways, thanks for the information.