大佬教程收集整理的这篇文章主要介绍了c – 为什么光线跟踪器将球体渲染为椭圆形?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我真的不知道是什么原因引起的.它可能是光线球体交叉代码,如下所示:
bool Sphere::intersect(Ray ray,glm::vec3& hitPoint) { //Compute A,B and C coefficients float a = glm::dot(ray.dir,ray.dir); float b = 2.0 * glm::dot(ray.dir,ray.org-pos); float c = glm::dot(ray.org-pos,ray.org-pos) - (rad * rad); // Find discriminant float disc = b * b - 4 * a * c; // if Discriminant is negative there are no real roots,so return // false as ray misses sphere if (disc < 0) return false; // compute q float distSqrt = sqrt(disc); float q; if (b < 0) q = (-b - distSqrt)/2.0; else q = (-b + distSqrt)/2.0; // compute t0 and t1 float t0 = q / a; float t1 = c / q; // make sure t0 is smaller than t1 if (t0 > t1) { // if t0 is bigger than t1 swap them around float temp = t0; t0 = t1; t1 = temp; } // if t1 is less than zero,the object is in the ray's negative direction // and consequently the ray misses the sphere if (t1 < 0) return false; // if t0 is less than zero,thE intersection point is at t1 if (t0 < 0) { hitPoint = ray.org + t1 * ray.dir; return true; } else { // else thE intersection point is at t0 hitPoint = ray.org + t0 * ray.dir; return true; } }
或者它可能是另一回事.有没有人有想法?非常感谢!
折射实际上看起来很不错;它是倒置的,因为折射率很高.漂亮的照片在this question.
以上是大佬教程为你收集整理的c – 为什么光线跟踪器将球体渲染为椭圆形?全部内容,希望文章能够帮你解决c – 为什么光线跟踪器将球体渲染为椭圆形?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。