MCPcopy Create free account
hub / github.com/ValveSoftware/steam-audio / bounce

Method bounce

core/src/core/reflection_simulator.cpp:524–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

522}
523
524void 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// --------------------------------------------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 2

uniformRandomMethod · 0.80

Tested by

no test coverage detected