Graphics 缺少余弦的光线跟踪

Graphics 缺少余弦的光线跟踪,graphics,rendering,raytracing,phong,Graphics,Rendering,Raytracing,Phong,我正在看经典光线跟踪器(所以还没有Monte Carlo或任何东西)的代码和源代码,为了清晰起见,在下面的简短伪代码中包含了这些代码 我很难理解为什么光线跟踪器实现中没有包含渲染方程中的余弦。我已经包括了我认为它缺失的地方的评论 我可以看到,对于完美镜面反射的BRDF(f_r=(δ(cosθI− cosθr)δ(φi− φr±π))/cosθi)余弦被抵消。但是,如果将它与下面所示的phong反射模型结合起来,又会怎样呢 for (loop through pixels) {

我正在看经典光线跟踪器(所以还没有Monte Carlo或任何东西)的代码和源代码,为了清晰起见,在下面的简短伪代码中包含了这些代码

我很难理解为什么光线跟踪器实现中没有包含渲染方程中的余弦。我已经包括了我认为它缺失的地方的评论

我可以看到,对于完美镜面反射的BRDF(f_r=(δ(cosθI− cosθr)δ(φi− φr±π))/cosθi)余弦被抵消。但是,如果将它与下面所示的phong反射模型结合起来,又会怎样呢

for (loop through pixels) 
{        
  Ray ray(eye, getDirection(col+0.5,row+0.5));
  vec3 color = trace(ray, 0);      
}

trace(ray, recursion_depth)
{
  if (too deep, or ray hits nothing)
    return vec3(0,0,0);  // return black

  Hit hit(ray);
  return vec3(hit.Ed)           // light source color
    + classic_trace_lights(hit)         // direct light
    + classic_trace_reflection(hit, depth)     // specular reflection
    + classic_trace_refraction(hit, depth);    // specular refraction
}

classic_trace_reflection(hit, depth)
{
    ....
    vec3 R = ideal_reflected_direction(hit.vdir, hit.normal);
    Ray ray(hit.pos, R);
    return hit.Rs * classic_trace_recursive(ray, depth+1); // Rs = specular color
}

classic_trace_lights(...) { ... }

classic_trace_light(...)
{
    ....
    return phong(...) * light.Ed /* * COSINE MISSING HERE? */;
}
....