This repository was archived by the owner on Nov 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrenderer.h
55 lines (50 loc) · 1.39 KB
/
renderer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2016 Kai Luo. All rights reserved.
#ifndef ZLI_RENDERER_H_
#define ZLI_RENDERER_H_
#include <atomic>
#include <memory>
#include <string>
#include "film.h"
#include "filter.h"
#include "kl/chan.h"
#include "kl/error.h"
#include "kl/option.h"
#include "scene.h"
#include "spectrum.h"
namespace zLi {
class Renderer {
public:
struct RenderResult {
int x, y;
xyYColor xyY;
};
Renderer(const std::string &scene_file, int film_width, int film_height,
int spp = 128);
kl::Result<void> Render();
void Stop();
bool Stopped();
// std::shared_ptr<Chan<RenderResult>> RGBChan() { return rgb_chan_; }
std::shared_ptr<kl::Chan<RenderResult>> xyYChan() { return xyY_chan_; }
Film MoveRenderResult();
~Renderer();
private:
static const Float SampleRadius;
// void AddToRGBChan(int, int, const Spectrum &);
void AddToxyYChan(int, int, const Spectrum &);
kl::Result<void> SlowRender();
kl::Result<void> ParallelRender();
void Work(int, int);
std::unique_ptr<Film> film_;
std::unique_ptr<Scene> scene_;
std::string scene_file_;
int film_width_, film_height_;
std::atomic<int> render_job_;
std::atomic<bool> stopped_;
Spectrum SampleSpectrumAt(Float, Float);
int spp_; // samples per pixel
// std::shared_ptr<Chan<RenderResult>> rgb_chan_;
std::shared_ptr<kl::Chan<RenderResult>> xyY_chan_;
filter::Gauss1D filter_;
};
} // namespace zLi
#endif