本文整理汇总了C++中ParamSet::AddRGBSpectrum方法的典型用法代码示例。如果您正苦于以下问题:C++ ParamSet::AddRGBSpectrum方法的具体用法?C++ ParamSet::AddRGBSpectrum怎么用?C++ ParamSet::AddRGBSpectrum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParamSet
的用法示例。
在下文中一共展示了ParamSet::AddRGBSpectrum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wi
MedianCutEnvironmentLight::MedianCutEnvironmentLight(const Transform &light2world,
const Spectrum &L, int ns_, const string &texmap)
: Light(light2world, ns_), impl(new MedCutEnvImpl {nullptr, nullptr, ns_}) {
int width = 0, height = 0;
RGBSpectrum *texels = NULL;
// Read texel data from _texmap_ into _texels_
if (texmap != "") {
texels = ReadImage(texmap, &width, &height);
if (texels)
for (int i = 0; i < width * height; ++i)
texels[i] *= L.ToRGBSpectrum();
}
if (!texels) {
width = height = 1;
texels = new RGBSpectrum[1];
texels[0] = L.ToRGBSpectrum();
}
impl->radianceMap = new MIPMap<RGBSpectrum>(width, height, texels);
impl->width = width;
impl->inv_w = 1.0f/(width-1);
impl->height = height;
impl->inv_h = 1.0f/(height-1);
impl->createDistantLight = [this](const RGBSpectrum& s, float cy, float cx) {
ParamSet p;
float rgb[3];
s.ToRGB(rgb);
p.AddRGBSpectrum("L", rgb, 3);
const float theta = impl->inv_h*cy * M_PI
, phi = impl->inv_w*cx * 2.f * M_PI;
const float costheta = cosf(theta), sintheta = sinf(theta);
const float sinphi = sinf(phi), cosphi = cosf(phi);
const Point wi(-sintheta*cosphi, -sintheta*sinphi, -costheta);
p.AddPoint(string("to"), &wi, 1);
#if DEBUG >= 1
fprintf(stderr, "rgb (%f,%f,%f)\n", rgb[0], rgb[1], rgb[2]);
#endif
return CreateDistantLight(this->LightToWorld, p);
};
impl->solid_angle = ((2.f * M_PI) / (width - 1)) * (M_PI / (1.f * (height - 1)));
#if DEBUG >= 1
fprintf(stderr, "solid_angle = %f\n", impl->solid_angle);
#endif
for (int y = 0; y < height; ++y) {
float sinTheta = sinf(M_PI * float(y + 0.5f)/height);
for (int x = 0; x < width; ++x)
texels[y*width + x] *= impl->solid_angle * sinTheta;
}
// Initialize energy sum array; the array is shifted for (1,1)
// i.e. (0,*) and (*,0) are inserted 0-boundaries
fprintf(stderr, "[+] [%10.2f] Initializing sum array\n", clock()*1.0/CLOCKS_PER_SEC);
#if DEBUG >= 3
for (int y = 0; y < 5; ++y) {
for (int x = 0; x < 5; ++x) {
fprintf(stderr, "%.2f ", texels[y*width+x].y());
}
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
#endif
vector<vector<float>> acc(height+1, vector<float>(width+1));
for (int y = 0; y < height; ++y)
for (int x = 0; x < width; ++x)
acc[y+1][x+1] = acc[y+1][x] + texels[y*width + x].y();
#if DEBUG >= 3
for (int y = 0; y < 5; ++y) {
for (int x = 0; x < 5; ++x) {
fprintf(stderr, "%.2f ", acc[y][x]);
}
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
#endif
for (int x = 1; x <= width; ++x)
for (int y = 1; y <= height; ++y)
acc[y][x] += acc[y-1][x];
#if DEBUG >= 3
for (int y = 0; y < 5; ++y) {
for (int x = 0; x < 5; ++x) {
fprintf(stderr, "%.2f ", acc[y][x]);
}
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
#endif
// initialize median cut
//.........这里部分代码省略.........