float[] = create_pdf(float values[])
入力の配列値からPDFを作成し、それをfloat配列として返します。
values
PDFを作成するための配列値。
CDFは、分布からサンプリングする時に役立ちます。 例えば、光源パワーのCDFを作成することができます。 このCDFは、パワーに基づいた確率でライトをサンプリングすることができます。 この例は離散CDFであり、サンプリングは、固定された確率の集合の中から選択します。 そのようなCDFは、以下のコードで作成することができます:
Examples
// すべてのライトを反復して、パワーをサンプリングします。 int[] li = getlights(); float values[]; resize(values, len(li)); int nsamples = 256; int sid = israytrace ? SID : newsampler(); vector s, pos, clr; float scale; for (int i = 0; i < len(li); i++) { for (int j = 0; j < nsamples; j++) { nextsample(sid, s.x, s.y, "mode", "nextpixel"); sample_light(li[i], P, s, Time, pos, clr, scale); values[i] += luminance(clr); } values[i] /= nsamples; } // そのパワー分布のCDFを作成します。 float cdf[] = create_cdf(values); // パワー分布に基づいて、ランダムにライトを選択します。 nextsample(sid, s.x, s.y, "mode", "nextpixel"); int index = 0; sample_cdf(cdf, s.x, index); // 選択したライトを使って何かをします。 // li[index] ...
See also | |
bsdf | |
pbr |
|
sampling |