| 522 | } |
| 523 | |
| 524 | void ReflectionSimulator::bounce(const IScene& scene, |
| 525 | int bounce, |
| 526 | const Hit& hit, |
| 527 | const Vector3f& hitPoint, |
| 528 | int threadId, |
| 529 | Ray& ray, |
| 530 | float* accumEnergy, |
| 531 | float& accumDistance) |
| 532 | { |
| 533 | for (auto j = 0; j < Bands::kNumBands; ++j) |
| 534 | { |
| 535 | accumEnergy[j] *= (1.0f - hit.material->absorption[j]); |
| 536 | } |
| 537 | |
| 538 | accumDistance += hit.distance; |
| 539 | |
| 540 | ray.origin = hitPoint; |
| 541 | |
| 542 | if (mThreadState[threadId].rng.uniformRandomNormalized() < hit.material->scattering) |
| 543 | { |
| 544 | auto diffuseSampleIndex = mThreadState[threadId].rng.uniformRandom() % mNumDiffuseSamples; |
| 545 | ray.direction = Sampling::transformHemisphereSample(mDiffuseSamples[diffuseSampleIndex], hit.normal); |
| 546 | } |
| 547 | else |
| 548 | { |
| 549 | ray.direction = Vector3f::reflect(ray.direction, hit.normal); |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | |
| 554 | // -------------------------------------------------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected