Gregory Igehy

Dancing at hemisphere coordinate

Shadow of area light

  • smallpt を修正して, Cornell Box の円板のエリアライトのシャドウだけを描画した
  • ただライト方向からではなく, カメラ方向だけからレイを飛ばしているので, サンプル数の割には結果が汚い
  • 下図は 1 ピクセルあたり 200 サンプル, 1000 サンプルの場合

f:id:gregory-igehy:20150217142455j:plain
f:id:gregory-igehy:20150217145826j:plain

  • ついでに下は cos_theta ^ e の半球の重点サンプリングのコード例
//
// From "Ray Tracing from the Groud Up" Kevin Suffern.
//

// シャドウであるため
double e         = 0.0;

double r1        = erand48( Xi );
double r2        = erand48( Xi );

double phi       = 2 * M_PI * r1;
double cos_phi   = cos( phi );
double sin_phi   = sin( phi );

double cos_theta = pow( 1.0 - r2, 1.0 / ( e + 1.0 ) );
double sin_theta = sqrt( 1.0 - cos_theta * cos_theta );

Vec w            = nl;
Vec u            = ( ( fabs( w.x ) > 0.1 ? Vec( 0, 1 ) : Vec( 1 ) ) % w ).norm( );
Vec v            = w % u;
Vec d            = ( u * sin_theta * cos_phi + v * sin_theta * sin_phi + w * cos_theta ).norm();
  • (追記) 下は間違っていた結果で,シェードが入っている
  • 1 ピクセルあたり 1000 サンプルの場合

f:id:gregory-igehy:20150216153409j:plain