提交 134eb78d 编写于 作者: M Matt Pharr

Add Film::ResetPixel() method

上级 a4f48c69
......@@ -50,6 +50,7 @@ class Film : public TaggedPointer<RGBFilm, GBufferFilm, SpectralFilm> {
const SampledWavelengths &lambda) const;
Image GetImage(ImageMetadata *metadata, Float splatScale = 1);
PBRT_CPU_GPU
RGB GetPixelRGB(Point2i p, Float splatScale = 1) const;
......@@ -64,6 +65,8 @@ class Film : public TaggedPointer<RGBFilm, GBufferFilm, SpectralFilm> {
Filter filter, const FileLoc *loc, Allocator alloc);
std::string ToString() const;
PBRT_CPU_GPU inline void ResetPixel(Point2i p);
};
} // namespace pbrt
......
......@@ -295,6 +295,10 @@ class RGBFilm : public FilmBase {
return outputRGBFromSensorRGB * sensorRGB;
}
PBRT_CPU_GPU void ResetPixel(Point2i p) {
std::memset(&pixels[p], 0, sizeof(Pixel));
}
private:
// RGBFilm::Pixel Definition
struct Pixel {
......@@ -367,6 +371,10 @@ class GBufferFilm : public FilmBase {
std::string ToString() const;
PBRT_CPU_GPU void ResetPixel(Point2i p) {
std::memset(&pixels[p], 0, sizeof(Pixel));
}
private:
// GBufferFilm::Pixel Definition
struct Pixel {
......@@ -482,6 +490,16 @@ class SpectralFilm : public FilmBase {
return {};
}
PBRT_CPU_GPU void ResetPixel(Point2i p) {
Pixel &pix = pixels[p];
pix.rgbSum[0] = pix.rgbSum[1] = pix.rgbSum[2] = 0.;
pix.rgbWeightSum = 0.;
pix.rgbSplat[0] = pix.rgbSplat[1] = pix.rgbSplat[2] = 0.;
std::memset(pix.bucketSums, 0, nBuckets *sizeof(double));
std::memset(pix.weightSums, 0, nBuckets *sizeof(double));
std::memset(pix.bucketSplats, 0, nBuckets * sizeof(AtomicDouble));
}
private:
PBRT_CPU_GPU
int LambdaToBucket(Float lambda) const {
......@@ -584,6 +602,12 @@ inline const PixelSensor *Film::GetPixelSensor() const {
return Dispatch(filter);
}
PBRT_CPU_GPU
inline void Film::ResetPixel(Point2i p) {
auto rp = [&](auto ptr) { ptr->ResetPixel(p); };
return Dispatch(rp);
}
} // namespace pbrt
#endif // PBRT_FILM_H
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册