]> git.tdb.fi Git - libs/gl.git/blob - source/effects/colorcurve.h
Use default member initializers for simple types
[libs/gl.git] / source / effects / colorcurve.h
1 #ifndef MSP_GL_COLORCURVE_H_
2 #define MSP_GL_COLORCURVE_H_
3
4 #include "postprocessor.h"
5 #include "programdata.h"
6 #include "texture1d.h"
7
8 namespace Msp {
9 namespace GL {
10
11 class Program;
12
13 /**
14 Processes oversaturated colors to preserve hues.  When one color component
15 exceeds 1.0, the overflow is distributed to the other components, scaling the
16 color towards white.
17
18 Gamma or sRGB correction can also be applied to the output.  It can be used to
19 improve color reproduction by performing lighting calculations in linear color
20 space and converting to sRGB for display.
21 */
22 class ColorCurve: public PostProcessor
23 {
24 public:
25         struct Template: public PostProcessor::Template
26         {
27                 class Loader: public DataFile::DerivedObjectLoader<Template, PostProcessor::Template::Loader>
28                 {
29                 public:
30                         Loader(Template &);
31
32                 private:
33                         void gamma(float);
34                         void srgb();
35                 };
36
37                 float exposure_adjust = 0.0f;
38                 float brightness_response = 0.4f;
39                 float gamma = 1.0f;
40                 bool srgb = false;
41
42                 virtual ColorCurve *create(unsigned, unsigned) const;
43         };
44
45 private:
46         const Program &shprog;
47         ProgramData shdata;
48         Texture1D curve;
49         const Mesh &quad;
50         const Sampler &linear_sampler;
51         const Sampler &nearest_sampler;
52
53 public:
54         ColorCurve();
55
56         /** Set exposure adjustment in EV units.  Positive values brighten the
57         image, negative values darken it.  Zero is neutral. */
58         void set_exposure_adjust(float);
59
60         /** Sets the exponent of the brightness response curve.  It must be greater
61         than zero and at most one.  A value of one gives a linear response; closer
62         to zero results in a more gentle curve. */
63         void set_brightness_response(float);
64
65         /** Sets the gamma value used for mapping output colors.  Allowed range is
66         from 0.1 to 10. */
67         void set_gamma(float);
68
69         /** Sets output mapping to sRGB.  This is almost, but not exactly equivalent
70         to set_gamma(2.2). */
71         void set_srgb();
72
73         /// Sets output mapping to linear.  This is equivalent to set_gamma(1).
74         void set_linear();
75
76         virtual void render(Renderer &, const Texture2D &, const Texture2D &);
77
78         virtual void set_debug_name(const std::string &);
79 };
80
81 } // namespace GL
82 } // namespace Msp
83
84 #endif