graphics, rendering
Home

Path Tracing Notes

Simple path tracing:

trace() {
    { // miss
        stop = true;
        return;
    }
    { // emitter hit test
        if (hitIsEmitter) {
            misWeight = powerHeuristic(brdfPdf, lightPdf);
            radiance += misWeight * throughput * emittance / lightPdf;
            stop = true;
            return;
        }
    }
    { // direct light
        // importance sample the light
        sampleLight();
        emittance *= numLights;
        isShadowed = checkVisibility(hitPos, lightSample.dir);
        if (!isShadowed) {
            evalBrdf();
            misWeight = powerHeuristic(lightPdf, brdfPdf);
            radiance += misWeight * emittance * brdfVal * cosTheta * throughput / lightPdf;
        }
    }
    { // sample next ray
        sampleBrdf();
        throughput *= brdfVal * cosTheta / brdfPdf;
        trace();
    }
}
local to global:
  wi ==> lightDir
  wo ==> viewDir
  (1,0,0) ==> tangent
  (0,1,0) ==> bitangent
  (0,0,1) ==> ffnormal
global to local:
  wi <== lightDir
  wo <== viewDir
  (1,0,0) <== tangent
  (0,1,0) <== bitangent
  (0,0,1) <== ffnormal
calc:
 [tangent[0:3]       [tangent.x    [1
  bitangent[0:3]   *  tangent.y  =  0
  normal[0:3]    ]    tangent.z]    0]