2012-04-27 06:30:09 +00:00
|
|
|
//#version 420 // Keep it for editor detection
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Contrast, saturation, brightness
|
|
|
|
** Code of this function is from TGM's shader pack
|
|
|
|
** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct vertex_basic
|
|
|
|
{
|
|
|
|
vec4 p;
|
|
|
|
vec2 t;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef FRAGMENT_SHADER
|
|
|
|
|
2013-07-12 21:12:34 +00:00
|
|
|
#if !GL_ES && __VERSION__ > 140
|
2013-07-11 17:08:42 +00:00
|
|
|
|
|
|
|
in SHADER
|
|
|
|
{
|
|
|
|
vec4 p;
|
|
|
|
vec2 t;
|
|
|
|
} PSin;
|
|
|
|
|
2013-05-26 13:05:03 +00:00
|
|
|
#define PSin_p (PSin.p)
|
|
|
|
#define PSin_t (PSin.t)
|
2013-07-11 17:08:42 +00:00
|
|
|
|
2013-05-26 13:05:03 +00:00
|
|
|
#else
|
2013-07-11 17:08:42 +00:00
|
|
|
|
2013-05-27 16:53:38 +00:00
|
|
|
#ifdef DISABLE_SSO
|
|
|
|
in vec4 SHADERp;
|
|
|
|
in vec2 SHADERt;
|
|
|
|
#else
|
|
|
|
layout(location = 0) in vec4 SHADERp;
|
|
|
|
layout(location = 1) in vec2 SHADERt;
|
|
|
|
#endif
|
|
|
|
#define PSin_p SHADERp
|
|
|
|
#define PSin_t SHADERt
|
2013-07-11 17:08:42 +00:00
|
|
|
|
2013-05-26 13:05:03 +00:00
|
|
|
#endif
|
2012-04-27 06:30:09 +00:00
|
|
|
|
|
|
|
layout(location = 0) out vec4 SV_Target0;
|
|
|
|
|
2013-04-19 19:16:26 +00:00
|
|
|
#ifdef DISABLE_GL42
|
|
|
|
layout(std140) uniform cb12
|
|
|
|
#else
|
|
|
|
layout(std140, binding = 12) uniform cb12
|
|
|
|
#endif
|
2012-04-27 06:30:09 +00:00
|
|
|
{
|
|
|
|
vec4 BGColor;
|
|
|
|
};
|
|
|
|
|
2013-10-24 20:54:27 +00:00
|
|
|
#ifdef ENABLE_BINDLESS_TEX
|
|
|
|
layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler;
|
|
|
|
#else
|
2013-05-25 14:28:16 +00:00
|
|
|
#ifdef DISABLE_GL42
|
|
|
|
uniform sampler2D TextureSampler;
|
|
|
|
#else
|
2012-04-27 06:30:09 +00:00
|
|
|
layout(binding = 0) uniform sampler2D TextureSampler;
|
2013-05-25 14:28:16 +00:00
|
|
|
#endif
|
2013-10-24 20:54:27 +00:00
|
|
|
#endif
|
2012-04-27 06:30:09 +00:00
|
|
|
|
|
|
|
// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
|
|
|
|
vec4 ContrastSaturationBrightness(vec4 color)
|
|
|
|
{
|
|
|
|
const float sat = SB_SATURATION / 50.0;
|
|
|
|
const float brt = SB_BRIGHTNESS / 50.0;
|
|
|
|
const float con = SB_CONTRAST / 50.0;
|
|
|
|
|
|
|
|
// Increase or decrease theese values to adjust r, g and b color channels seperately
|
|
|
|
const float AvgLumR = 0.5;
|
|
|
|
const float AvgLumG = 0.5;
|
|
|
|
const float AvgLumB = 0.5;
|
|
|
|
|
|
|
|
const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
|
|
|
|
|
|
|
|
vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);
|
|
|
|
vec3 brtColor = color.rgb * brt;
|
|
|
|
float dot_intensity = dot(brtColor, LumCoeff);
|
|
|
|
vec3 intensity = vec3(dot_intensity, dot_intensity, dot_intensity);
|
|
|
|
vec3 satColor = mix(intensity, brtColor, sat);
|
|
|
|
vec3 conColor = mix(AvgLumin, satColor, con);
|
|
|
|
|
|
|
|
color.rgb = conColor;
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ps_main()
|
|
|
|
{
|
2013-05-26 13:05:03 +00:00
|
|
|
vec4 c = texture(TextureSampler, PSin_t);
|
2012-04-27 06:30:09 +00:00
|
|
|
SV_Target0 = ContrastSaturationBrightness(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|