Unexpected result when computing shadows in a ray tracer

泄露秘密 提交于 2019-12-06 04:23:31

Cornstalks is right but one thing important if you are using hitPoint+0.03*normalAtHit, you need to be sure that the normal is the one that matches the incident ray, from what we see in your code you just take the normal of your primitive but each face has 2 normals (one reversed from the other).

Depending on that you may have a ray that start from the wrong side and thus may cause invalid shadow.

To do this you can check the dot product of your incidentRay with the normal, depending on the result (greater than 0 or less than 0), you will know if you need to reverse your normal.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!