]> git.tdb.fi Git - libs/gl.git/blob - source/colorcurve.h
Use Renderer for rendering PostProcessors
[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 others are scaled towards white.  A transition curve is also
16 applied near 1.0 to prevent the abrupt change in the gradient.
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 private:
25         Program shprog;
26         ProgramData shdata;
27         Texture1D curve;
28         Texturing texturing;
29         const Mesh &quad;
30
31 public:
32         ColorCurve();
33
34         /// Sets the size of the peak zone.  Must be between 0 and 1, inclusive.
35         void set_peak(float);
36
37         /** Sets brightness for oversaturated colors.  Must be >= 1.  Suggested
38         values are between 1.5 and 2.0; a value of 1.0 will clamp colors to the
39         saturated value. */
40         void set_brightness(float);
41
42         /** Sets the gamma value used for mapping output colors.  Allowed range is
43         from 0.1 to 10. */
44         void set_gamma(float);
45
46         /** Sets output mapping to sRGB.  This is almost, but not exactly equivalent
47         to set_gamma(2.2). */
48         void set_srgb();
49
50         /// Sets output mapping to linear.  This is equivalent to set_gamma(1).
51         void set_linear();
52
53         virtual void render(Renderer &, const Texture2D &, const Texture2D &);
54 };
55
56 } // namespace GL
57 } // namespace Msp
58
59 #endif