2014-04-17 13:56:13 +02:00
|
|
|
import QtQuick 2.2
|
2014-07-06 23:57:47 +02:00
|
|
|
import QtGraphicalEffects 1.0
|
2014-03-24 11:09:34 +01:00
|
|
|
|
|
|
|
ShaderEffect{
|
|
|
|
property variant source: framesource
|
|
|
|
property variant normals: framesourcenormals
|
2014-04-05 15:14:52 +02:00
|
|
|
property real screen_distorsion: shadersettings.screen_distortion * framecontainer.distortionCoefficient
|
2014-03-24 11:09:34 +01:00
|
|
|
property real ambient_light: shadersettings.ambient_light
|
|
|
|
property color font_color: shadersettings.font_color
|
|
|
|
property color background_color: shadersettings.background_color
|
2014-03-31 17:26:51 +02:00
|
|
|
property real brightness: shadersettings.brightness * 1.5 + 0.5
|
2014-03-24 11:09:34 +01:00
|
|
|
|
2014-07-06 23:57:47 +02:00
|
|
|
property bool frameReflections: shadersettings.frameReflections
|
|
|
|
property variant lightSource: reflectionEffectSourceLoader.item
|
2014-04-05 15:14:52 +02:00
|
|
|
|
2014-08-07 00:18:44 +02:00
|
|
|
property real chroma_color: shadersettings.chroma_color
|
|
|
|
|
2014-07-06 23:57:47 +02:00
|
|
|
Loader{
|
|
|
|
id: reflectionEffectLoader
|
|
|
|
width: parent.width * 0.33
|
|
|
|
height: parent.height * 0.33
|
|
|
|
active: frameReflections
|
2014-03-24 11:09:34 +01:00
|
|
|
|
2014-07-06 23:57:47 +02:00
|
|
|
sourceComponent: FastBlur{
|
|
|
|
id: frameReflectionEffect
|
|
|
|
radius: 128
|
|
|
|
source: terminal.kterminal
|
|
|
|
smooth: false
|
|
|
|
}
|
|
|
|
}
|
2014-03-31 14:13:51 +02:00
|
|
|
|
2014-07-06 23:57:47 +02:00
|
|
|
Loader{
|
|
|
|
id: reflectionEffectSourceLoader
|
|
|
|
active: frameReflections
|
|
|
|
sourceComponent: ShaderEffectSource{
|
|
|
|
id: frameReflectionSource
|
|
|
|
sourceItem: reflectionEffectLoader.item
|
|
|
|
hideSource: true
|
|
|
|
smooth: true
|
|
|
|
}
|
|
|
|
}
|
2014-03-31 14:13:51 +02:00
|
|
|
|
2014-07-06 23:57:47 +02:00
|
|
|
blending: true
|
2014-03-24 11:09:34 +01:00
|
|
|
|
|
|
|
fragmentShader: "
|
|
|
|
uniform sampler2D source;
|
|
|
|
uniform sampler2D normals;
|
|
|
|
uniform highp float screen_distorsion;
|
|
|
|
uniform highp float ambient_light;
|
2014-08-08 22:57:51 +02:00
|
|
|
uniform highp float qt_Opacity;
|
|
|
|
uniform lowp float chroma_color;" +
|
2014-03-24 11:09:34 +01:00
|
|
|
|
2014-07-06 23:57:47 +02:00
|
|
|
(frameReflections ?
|
|
|
|
"uniform sampler2D lightSource;" : "") + "
|
|
|
|
|
|
|
|
uniform vec4 font_color;
|
|
|
|
uniform vec4 background_color;
|
2014-03-31 14:13:51 +02:00
|
|
|
varying lowp float brightness;
|
2014-03-24 11:09:34 +01:00
|
|
|
|
|
|
|
varying highp vec2 qt_TexCoord0;
|
|
|
|
|
|
|
|
vec2 distortCoordinates(vec2 coords){
|
|
|
|
vec2 cc = coords - vec2(0.5);
|
|
|
|
float dist = dot(cc, cc) * screen_distorsion;
|
|
|
|
return (coords + cc * (1.0 + dist) * dist);
|
|
|
|
}
|
|
|
|
|
2014-08-07 00:18:44 +02:00
|
|
|
float rgb2grey(vec3 v){
|
|
|
|
return dot(v, vec3(0.21, 0.72, 0.04));
|
|
|
|
}
|
|
|
|
|
2014-03-24 11:09:34 +01:00
|
|
|
void main(){
|
|
|
|
vec2 coords = distortCoordinates(qt_TexCoord0);
|
|
|
|
vec4 txt_color = texture2D(source, coords);
|
|
|
|
vec4 txt_normal = texture2D(normals, coords);
|
|
|
|
vec3 normal = normalize(txt_normal.rgb * 2.0 - 1.0);
|
2014-07-06 23:57:47 +02:00
|
|
|
vec3 light_direction = normalize(vec3(0.5, 0.5, 0.0) - vec3(qt_TexCoord0, 0.0));
|
|
|
|
|
|
|
|
float dotProd = dot(normal, light_direction);" +
|
|
|
|
|
|
|
|
(frameReflections ? "
|
2014-08-07 00:18:44 +02:00
|
|
|
vec3 realLightColor = texture2D(lightSource, coords).rgb;
|
|
|
|
float screenLight = rgb2grey(realLightColor);
|
2014-07-06 23:57:47 +02:00
|
|
|
float clampedDotProd = clamp(dotProd, 0.05, 1.0);
|
|
|
|
float diffuseReflection = clamp(screenLight * 1.5 * clampedDotProd, 0.0, 0.35);
|
2014-08-07 00:18:44 +02:00
|
|
|
float reflectionAlpha = mix(1.0, 0.90, dotProd);
|
2014-08-08 22:57:51 +02:00
|
|
|
vec3 lightColor = mix(font_color.rgb * screenLight, font_color.rgb * realLightColor, chroma_color);"
|
2014-07-06 23:57:47 +02:00
|
|
|
: "
|
|
|
|
float diffuseReflection = 0.0;
|
2014-08-07 00:18:44 +02:00
|
|
|
float reflectionAlpha = 1.0;
|
|
|
|
vec3 lightColor = font_color.rgb;") + "
|
|
|
|
|
2014-07-06 23:57:47 +02:00
|
|
|
|
|
|
|
vec3 back_color = background_color.rgb * (0.2 + 0.5 * dotProd);
|
2014-08-07 00:18:44 +02:00
|
|
|
vec3 front_color = lightColor * (0.05 + diffuseReflection);
|
2014-07-06 23:57:47 +02:00
|
|
|
|
|
|
|
vec4 dark_color = vec4((back_color + front_color) * txt_normal.a, txt_normal.a * reflectionAlpha);
|
2014-04-17 15:20:15 +02:00
|
|
|
gl_FragColor = mix(dark_color, txt_color, ambient_light);
|
2014-03-24 11:09:34 +01:00
|
|
|
}"
|
2014-04-04 02:32:52 +02:00
|
|
|
|
2014-04-16 19:37:33 +02:00
|
|
|
onStatusChanged: if (log) console.log(log) //Print warning messages
|
2014-03-24 11:09:34 +01:00
|
|
|
}
|