光线追踪 - 反射
Ray Tracing - Reflection
我现在正在研究光线追踪器,反射部分。我让一切正常工作,包括创建一个带有阴影的球体。现在,我正在实现反射部分。但是,我无法理解。我的算法如下:
traceRay(Ray ray, int counter){
// look through the intersection between ray and list of objects
// find the final index aka the winning index, (if final index == -1, return background color)
// then calculate the intersection point
// perform reflection calculation here
if(counter > 1 && winning object's reflectivity > 1 ){
//get the intersection normal, vector N
//Calculate the reflection ray, R
// let I is the inverse of direction of incoming ray
//Calculate R = 2aN - I (a = N dotProduct I)
// the reflection ray is origin at the point of intersection between incoming ray and sphere with the R direction
Ray reflecRay (intersection_poisition, R);
Color reflection = traceRay(reflecRay, counter + 1);
// multiply by fraction ks
reflection = reflection * ks;
}
// the color of the sphere calculated using phong formula in shadeRay function
Color prefinal = shadeRay();
// return the total color of prefinal + reflection
}
我试图获得反射但无法得到它,任何人都可以让我知道我的 traceRay 函数算法是否正确吗?
反射光线时,需要沿反射器的法线移动它,以避免与反射器本身相交。例如:
const double ERR = 1e-12;
Ray reflecRay (intersection_poisition + normal*ERR, R);
相关文章:
- 光线追踪:椭球命中功能
- 平面和球体光线追踪之间的交点
- 不完整的多线程光线追踪器花费的时间是预期的两倍
- 光线追踪对象文件漫反射着色问题
- 光线追踪 - 反射
- 光线追踪锥.判别式给出 -ve 值,因此没有交集
- C++:光线追踪器导致内存不足错误 - 由于反复调用"new"?
- 实时光线追踪器
- 光线追踪 - 几何球体相交 - 相交函数对所有光线返回 true,尽管没有相交
- 优化光线追踪器
- C++:光线追踪器输出中的非确定性行为
- 光线追踪框交集 (c++)
- 光线追踪网格上的伪影黑线(使用Embree)
- 光线追踪框交叉点
- 光线追踪-照明方程
- 基于前向的光线追踪器
- 光线追踪器不会渲染对象的多个实例
- 计算机图形行业的人们用什么来进行光线追踪?
- 在光线追踪器中实现软阴影
- 分布式光线追踪器的基本思想