"//! Is debug mode enabled for importance screen sampling.\n"
"uniform int uDebugAdaptive;\n"
"\n"
+ "//! Exposure value for tone mapping.\n"
+ "uniform float uExposure;\n"
+ "\n"
+ "#ifdef TONE_MAPPING_FILMIC\n"
+ "\n"
+ "//! White point value for filmic tone mapping.\n"
+ "uniform float uWhitePoint;\n"
+ "\n"
+ "#endif // TONE_MAPPING\n"
+ "\n"
"//! Output pixel color.\n"
"out vec4 OutColor;\n"
"\n"
"#define SCALE_FACTOR 1.0e6f\n"
"\n"
"// =======================================================================\n"
+ "// function : ToneMappingFilmic\n"
+ "// purpose :\n"
+ "// =======================================================================\n"
+ "vec4 ToneMappingFilmic(vec4 theColor, float theWhitePoint)\n"
+ "{\n"
+ " vec4 aPackColor = vec4 (theColor.rgb, theWhitePoint);\n"
+ " vec4 aFilmicCurve = 1.425f * aPackColor + vec4 (0.05f);\n"
+ " vec4 aResultColor = (aPackColor * aFilmicCurve + vec4 (0.004f)) / (aPackColor * (aFilmicCurve + vec4 (0.55f)) + vec4 (0.0491f)) - vec4 (0.0821f);\n"
+ " return vec4 (aResultColor.rgb / aResultColor.www, 1.0);\n"
+ "}\n"
+ "\n"
+ "// =======================================================================\n"
"// function : main\n"
"// purpose :\n"
"// =======================================================================\n"
"\n"
"#ifdef PATH_TRACING\n"
"\n"
- " // apply gamma correction (we use gamma = 2)\n"
- " OutColor = vec4 (sqrt (aColor.rgb), 0.f);\n"
+ " aColor *= pow (2, uExposure);\n"
+ "\n"
+ "#ifdef TONE_MAPPING_FILMIC\n"
+ " aColor = ToneMappingFilmic (aColor, uWhitePoint);\n"
+ "#endif // TONE_MAPPING\n"
+ "\n"
+ " // apply gamma correction (we use gamma = 2)\n"
+ " OutColor = vec4 (sqrt (aColor.rgb), 0.f);\n"
"\n"
"#else // not PATH_TRACING\n"
"\n"
- " OutColor = aColor;\n"
+ " OutColor = aColor;\n"
"\n"
"#endif\n"
"}\n";