Radiance3 RayTracer::L_indirectImpulses(const shared_ptr<Surfel>& surfel, const Vector3& wo, ThreadData& threadData, int bouncesLeft) const { Surfel::ImpulseArray impulseArray; surfel->getImpulses(PathDirection::EYE_TO_SOURCE, wo, impulseArray); Radiance3 L; for (int i = 0; i < impulseArray.size(); ++i) { const Surfel::Impulse& impulse = impulseArray[i]; L += L_in(bump(surfel, impulse.direction), impulse.direction, threadData, bouncesLeft) * impulse.magnitude; } return L; }
//================================================================================= void RenderPixel (float u, float v, TPixelRGBF32& pixel) { // make (u,v) go from [-1,1] instead of [0,1] u = u * 2.0f - 1.0f; v = v * 2.0f - 1.0f; // find where the ray hits the near plane, and normalize that vector to get the ray direction. TVector3 rayStart = c_cameraPos + c_cameraFwd * c_nearPlaneDistance; rayStart += c_cameraRight * c_windowRight * u; rayStart += c_cameraUp * c_windowTop * v; TVector3 rayDir = Normalize(rayStart - c_cameraPos); // our pixel is the amount of light coming in to the position on our near plane from the ray direction pixel = L_in(rayStart, rayDir); }
Radiance3 RayTracer::traceOnePrimaryRay(float x, float y, ThreadData& threadData) { // Ray P, -wi const Ray& primaryRay = m_camera->worldRay(x, y, Rect2D::xywh(0, 0, (float)m_image->width(), (float)m_image->height())); return L_in(primaryRay.origin(), primaryRay.direction(), threadData, m_settings.numBackwardBounces); }