]> git.tdb.fi Git - libs/gl.git/blobdiff - source/colorcurve.h
Add a color curve post-processor
[libs/gl.git] / source / colorcurve.h
diff --git a/source/colorcurve.h b/source/colorcurve.h
new file mode 100644 (file)
index 0000000..82a8526
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef COLORCURVE_H_
+#define COLORCURVE_H_
+
+#include "postprocessor.h"
+#include "program.h"
+#include "programdata.h"
+
+namespace Msp {
+namespace GL {
+
+/**
+Processes oversaturated colors to preserve hues.  When one color component 
+exceeds 1.0, the others are scaled towards white.  A transition curve is also
+applied near 1.0 to prevent the abrupt change in the gradient.
+
+Only makes sense when used in an HDR framebuffer.
+*/
+class ColorCurve: public PostProcessor
+{
+private:
+       Program shprog;
+       ProgramData shdata;
+       const Mesh &quad;
+
+public:
+       ColorCurve();
+
+       /// Sets the size of the peak zone.  Must be between 0 and 1, inclusive.
+       void set_peak(float);
+
+       /** Sets brightness for oversaturated colors.  Must be >= 1.  Suggested
+       values are between 1.5 and 2.0; a value of 1.0 will clamp colors to the
+       saturated value. */
+       void set_brightness(float);
+
+       virtual void render(const Texture2D &, const Texture2D &);
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif