レイ トレーシングのエリア ライティングについて簡単な質問があります。私はゼロからのレイ トレーシングからこの主題を学んでおり、アンチエイリアスが適用されていない場合、私のエリア ライトの結果は次のようになります。
ご覧のとおり、画像には多くのノイズが含まれています。アンチエイリアスを適用すると問題なく表示され、256x AA を適用すると次のようになります。
[影の色の変更は些細なことです。影のいくつかのプロパティを変更しました]
私の質問は、これがエリア ライトの動作なのか、それとも何か間違っているのでしょうか? 最初のレンダリングには 4秒しかかかりませんが、後者のレンダリングには約 20分かかります。何かが間違っているように感じます。
ポイント ライト クラスとエリア ライト クラスの唯一の違いはget_direction
関数です。
ポイントライトのget_direction
機能:
virtual Vec get_direction(ShadeRec& sr)
{
return Vec(position.x-sr.hit_point.x, position.y-sr.hit_point.y, position.z-sr.hit_point.z).norm();
}
エリアライトのget_direction
機能:
virtual Vec get_direction(ShadeRec& sr)
{
Vec newLocation;
newLocation.x = position.x + radius * (2.0 * rand_float() - 1.0);
newLocation.y = position.y + radius * (2.0 * rand_float() - 1.0);
newLocation.z = position.z + radius * (2.0 * rand_float() - 1.0);
return ((newLocation - sr.hit_point).norm());
}