1 #ifndef MSP_GL_COLORCURVE_H_
2 #define MSP_GL_COLORCURVE_H_
4 #include "postprocessor.h"
5 #include "programdata.h"
14 Maps high dynamic range colors to 8-bit and applies gamma correction.
16 An exponential curve (with exponent less than or equal to 1) is applied to
17 simulate the response of the human eye. If the maximum color component of the
18 result exceeds 1, the overflow is distributed to the other components to
19 increase the apparent brightness without changing the hue.
21 Gamma or sRGB correction can also be applied to the output. It can be used to
22 improve color reproduction by performing lighting calculations in linear color
23 space and converting to sRGB for display.
25 class ColorCurve: public PostProcessor
28 struct Template: public PostProcessor::Template
30 class Loader: public DataFile::DerivedObjectLoader<Template, PostProcessor::Template::Loader>
40 float exposure_adjust = 0.0f;
41 float brightness_response = 0.4f;
45 virtual ColorCurve *create(unsigned, unsigned) const;
49 const Program &shprog;
53 const Sampler &linear_sampler;
54 const Sampler &nearest_sampler;
59 /** Set exposure adjustment in EV units. Positive values brighten the
60 image, negative values darken it. Zero is neutral. */
61 void set_exposure_adjust(float);
63 /** Sets the exponent of the brightness response curve. It must be greater
64 than zero and at most one. A value of one gives a linear response; closer
65 to zero results in a more gentle curve. */
66 void set_brightness_response(float);
68 /** Sets the gamma value used for mapping output colors. Allowed range is
70 void set_gamma(float);
72 /** Sets output mapping to sRGB. This is almost, but not exactly equivalent
76 /// Sets output mapping to linear. This is equivalent to set_gamma(1).
79 virtual void render(Renderer &, const Texture2D &, const Texture2D &);
81 virtual void set_debug_name(const std::string &);