GLSL 1.40 shader for invert effect
REVIEW: 110573
This commit is contained in:
parent
95656c3936
commit
58ffb7b627
4 changed files with 36 additions and 3 deletions
|
@ -13,8 +13,11 @@ install( FILES
|
|||
|
||||
# Data files
|
||||
install( FILES
|
||||
invert/data/invert.frag
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kwin )
|
||||
invert/data/1.10/invert.frag
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kwin/shaders/1.10 )
|
||||
install( FILES
|
||||
invert/data/1.40/invert.frag
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kwin/shaders/1.40 )
|
||||
|
||||
#######################################
|
||||
# Config
|
||||
|
|
25
effects/invert/data/1.40/invert.frag
Normal file
25
effects/invert/data/1.40/invert.frag
Normal file
|
@ -0,0 +1,25 @@
|
|||
#version 140
|
||||
uniform sampler2D sampler;
|
||||
uniform vec4 modulation;
|
||||
uniform float saturation;
|
||||
|
||||
in vec2 varyingTexCoords;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex = texture(sampler, varyingTexCoords);
|
||||
|
||||
if (saturation != 1.0) {
|
||||
vec3 desaturated = tex.rgb * vec3( 0.30, 0.59, 0.11 );
|
||||
desaturated = vec3( dot( desaturated, tex.rgb ));
|
||||
tex.rgb = tex.rgb * vec3( saturation ) + desaturated * vec3( 1.0 - saturation );
|
||||
}
|
||||
|
||||
tex *= modulation;
|
||||
tex.rgb = vec3(1.0) - tex.rgb;
|
||||
tex.rgb *= tex.a;
|
||||
|
||||
fragColor = tex;
|
||||
}
|
|
@ -72,7 +72,12 @@ bool InvertEffect::loadData()
|
|||
{
|
||||
m_inited = true;
|
||||
|
||||
const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/invert.frag");
|
||||
QString shadersDir = "kwin/shaders/1.10/";
|
||||
#ifndef KWIN_HAVE_OPENGLES
|
||||
if (GLPlatform::instance()->glslVersion() >= kVersionNumber(1, 40))
|
||||
shadersDir = "kwin/shaders/1.40/";
|
||||
#endif
|
||||
const QString fragmentshader = KGlobal::dirs()->findResource("data", shadersDir + "invert.frag");
|
||||
|
||||
m_shader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
|
||||
if (!m_shader->isValid()) {
|
||||
|
|
Loading…
Reference in a new issue