]> git.tdb.fi Git - libs/gl.git/blob - source/colorcurve.h
Store a Transform in keyframes instead of a Matrix
[libs/gl.git] / source / colorcurve.h
1 #ifndef MSP_GL_COLORCURVE_H_
2 #define MSP_GL_COLORCURVE_H_
3
4 #include "postprocessor.h"
5 #include "program.h"
6 #include "programdata.h"
7 #include "texture1d.h"
8 #include "texturing.h"
9
10 namespace Msp {
11 namespace GL {
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;
38                 float brightness_response;
39                 float gamma;
40                 bool srgb;
41
42                 Template();
43
44                 virtual ColorCurve *create(unsigned, unsigned) const;
45         };
46
47 private:
48         Program shprog;
49         ProgramData shdata;
50         Texture1D curve;
51         Texturing texturing;
52         const Mesh &quad;
53
54 public:
55         ColorCurve();
56
57         /** Set exposure adjustment in EV units.  Positive values brighten the
58         image, negative values darken it.  Zero is neutral. */
59         void set_exposure_adjust(float);
60
61         /** Sets the exponent of the */
62         void set_brightness_response(float);
63
64         // Deprecated functions
65         void set_peak(float);
66         void set_brightness(float);
67
68         /** Sets the gamma value used for mapping output colors.  Allowed range is
69         from 0.1 to 10. */
70         void set_gamma(float);
71
72         /** Sets output mapping to sRGB.  This is almost, but not exactly equivalent
73         to set_gamma(2.2). */
74         void set_srgb();
75
76         /// Sets output mapping to linear.  This is equivalent to set_gamma(1).
77         void set_linear();
78
79         virtual void render(Renderer &, const Texture2D &, const Texture2D &);
80 };
81
82 } // namespace GL
83 } // namespace Msp
84
85 #endif