0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OSL の envmap の importance sampling と MIS の計算についてのメモ

Posted at

OSL testrender のコードを参考にします.

語彙

  • 4 PI : 単位球の表面積
  • CDF : Cumulative Density Function. envmap の importance sampling に利用
  • MIS : Multiple importance sampling

OSL background.

background.h では

4 PI は, MIS で BSDF とサンプリングを行うために確率の計算空間を合わせるために必要です. CDF を正規化したのち, sample/eval で pdf/f を返すときに 4pi 補正を入れるのでも OK です.

Implicit

diffuse などで反射したレイが envmap に当たるケース.

Explicit

レイが surface にあたり, 交点で光源を明示的にサンプルして寄与を計算するケース.

ちなみに OSL testrender では envmap(background) と, 他の光源(point, directional, area など)は別であつかっています.

つまり integrator では, explicit の直接光計算で, envmap と, それ以外の光源とで二回レイを飛ばします.
manylight + envmap のシーンでは, こちらのほうが効率(収束)がよいです.
(ただし shadow catcher material があるシーンでは, 扱いが面倒だったような)

note

OSL testrender では sinTheta を考慮しない jacobian を使っています(理由は不明). pbrt は sinTheta で補正をいれた jacobian を使っています.

したがって, レイの方向から UV 座標を計算する map 関数(vector -> uv) だけを別の環境マップツールで使う場合などに注意が必要です(これで筆者はハマりました).

MIS weight

OSL test render では power heuristic を使っています.

しかし OSL testrender では f(eval) が f/pdf と pdf で割った値が含まれているものに対して MIS を計算しているので, そのままで他のレンダラに使う場合には注意がいります.

power_heuristic_weight(sampled_pdf, other_pdf):

  if (sampeld_pdf > other_pdf) {
    r = other_pdf / sampled_pdf;
    mis = 1 / (1 + r * r)
  } else if (sampled_pdf < other_pdf) {
    r = sampled_pdf / other_pdf;
    mis = 1 - 1 / (1 + r * r)
  } else { // inf/inf
    mis = 0.5
  }

  return mis

implicit hit to envmap

input: bsdf_pdf

(Le, bg_pdf) = envmap.Le(dir)

mis_weight = eyeray ? 1.0 : power_heuristic_weight(bsdf_pdf, bg_pdf);

L = Le * mis_weight 

explicit hit(sample envmap)

u0, u1 = random number
(Li, L_dir, L_pdf) = envmap.Sample_Li(u0, u1);

mis_weight = power_heuristic_weight(L_pdf, bsdf_pdf)

contrib = throughput * bsdf_f * L * mis_weight / L_pdf

TODO

  • さらなる検算
  • PBRT-v3 integrator との比較(PBRT では, implicit/explicit の扱いが異なる)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?