1.3.64
 
Loading...
Searching...
No Matches
LensFlare.h
Go to the documentation of this file.
1
16#ifndef LENS_FLARE_H
17#define LENS_FLARE_H
18
19#include "Context.h"
20#include <complex>
21#include <map>
22#include <string>
23#include <vector>
24
25// Forward declaration - full definition is in RadiationModel.h
26// LensFlareProperties must be defined before this header is included
28
30
35class LensFlare {
36public:
38
42 LensFlare(const LensFlareProperties &lens_flare_props, helios::int2 resolution);
43
45
50 void apply(std::map<std::string, std::vector<float>> &pixel_data, helios::int2 resolution);
51
53
59 std::vector<std::tuple<int, int, float>> findBrightPixels(const std::map<std::string, std::vector<float>> &pixel_data, helios::int2 resolution, float threshold) const;
60
61private:
63
67 void generateStarburstKernel();
68
70
74 void generateApertureMask(std::vector<float> &mask) const;
75
77
82 void applyStarburst(std::map<std::string, std::vector<float>> &pixel_data, helios::int2 resolution, const std::vector<std::tuple<int, int, float>> &bright_pixels);
83
85
91 void applyGhosts(std::map<std::string, std::vector<float>> &pixel_data, helios::int2 resolution, const std::vector<std::tuple<int, int, float>> &bright_pixels);
92
94
101 static float fresnelReflectance(float cos_theta, float n1 = 1.0f, float n2 = 1.5f);
102
104
110 static void fft2D(const std::vector<float> &input, std::vector<std::complex<float>> &output, int size);
111
113
118 static void fft1D(std::vector<std::complex<float>> &data, int size, bool inverse = false);
119
121
129 void renderSoftDisc(std::vector<float> &channel, helios::int2 resolution, float center_x, float center_y, float radius, float intensity) const;
130
132 LensFlareProperties props_;
133
135 helios::int2 resolution_;
136
138 std::vector<float> starburst_kernel_;
139
141 int kernel_size_ = 128;
142
144 static constexpr float ghost_scales_[] = {0.3f, 0.5f, 0.8f, 1.2f, 1.6f};
145
147 static constexpr float ghost_sizes_[] = {0.02f, 0.03f, 0.015f, 0.025f, 0.04f};
148};
149
150#endif // LENS_FLARE_H