You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
auto w = img->GetWidth();
auto h = img->GetHeight();
vector<double> distribution(w*h);
double sum = 0.f;
for (int y = 0; y < h; y++) {
double sinTheta = sin(PI<float> * (y + 0.5) / static_cast<double>(h));
for (int x = 0; x < w; x++) {
int idx = img->xy2idx(x, y);
distribution[idx] = sinTheta * img->GetPixel(x, y).to_rgb().illumination();
sum += distribution[idx];
}
}
for (auto & p : distribution)
p /= sum;
aliasMethod.Init(distribution);
......
void AliasMethod::Init(const vector<double> & distribution) {
......
for (int i = 0; i < num; i++) {
// 默认设置为 i
table[i].k = static_cast<int>(i);
table[i].p = distribution[i];
table[i].u = num * distribution[i];
if (table[i].u < 1)
underfulls.push_back(i);
if (table[i].u > 1)
overfulls.push_back(i);
}
......
}
The text was updated successfully, but these errors were encountered:
u聚,在这里InfiniteAreaLight初始化这里,sum不是要再除以(w*h)才等于贴图这个二维函数在定义域上的积分吗?如果这里不除的话,distribution中的值应该并不是pdf(i,j)吧,应该只是个分布,若是这样的话。好像u聚在AliasMethod却是直接把他当作pdf了。
The text was updated successfully, but these errors were encountered: