]> git.tdb.fi Git - libs/gl.git/blob - source/colorcurve.h
Add gamma correction and sRGB conversion support to ColorCurve
[libs/gl.git] / source / colorcurve.h
1 #ifndef COLORCURVE_H_
2 #define COLORCURVE_H_
3
4 #include "postprocessor.h"
5 #include "program.h"
6 #include "programdata.h"
7 #include "texture1d.h"
8
9 namespace Msp {
10 namespace GL {
11
12 /**
13 Processes oversaturated colors to preserve hues.  When one color component
14 exceeds 1.0, the others are scaled towards white.  A transition curve is also
15 applied near 1.0 to prevent the abrupt change in the gradient.
16
17 Only makes sense when used in an HDR framebuffer.
18 */
19 class ColorCurve: public PostProcessor
20 {
21 private:
22         Program shprog;
23         ProgramData shdata;
24         Texture1D curve;
25         const Mesh &quad;
26
27 public:
28         ColorCurve();
29
30         /// Sets the size of the peak zone.  Must be between 0 and 1, inclusive.
31         void set_peak(float);
32
33         /** Sets brightness for oversaturated colors.  Must be >= 1.  Suggested
34         values are between 1.5 and 2.0; a value of 1.0 will clamp colors to the
35         saturated value. */
36         void set_brightness(float);
37
38         void set_gamma(float);
39         void set_srgb();
40         void set_linear();
41
42         virtual void render(const Texture2D &, const Texture2D &);
43 };
44
45 } // namespace GL
46 } // namespace Msp
47
48 #endif