Path Tracer

// generate eye path
const FVector2 vScr(((REAL)pnt.x + FMTrand()) * m_finvWidth, ((REAL)pnt.y + FMTrand()) * m_finvHeight);
const FRay ray = m_pScene->getpCamera()->genRay(vScr);
EyePath eyepath(ray.vPos, ray.vDir, m_pScene->getpGeomMgr()); 

if(! eyepath.bValid)
	continue;

// extend eyepath as possible
while(eyepath.extend(m_pScene->getpGeomMgr()))
	;

// get contribution from light at each path vertex
LightE weight(1, 1);
for(unsigned int i = 0; i < eyepath.nPathLength; ++i)
{
	ret += sampleDI(&eyepath.DG[i], eyepath.vTheta[i]) * weight;
	weight *= eyepath.BSDF[i] / eyepath.fBSDFpdf[i];
}

例のPathクラスを実装してみました。

うーん。もうちょっと簡潔にできないかなぁ。