Added brightness slider.

This commit is contained in:
Filippo Scognamiglio 2014-03-31 17:26:51 +02:00
parent 120561ff95
commit 8611f815e7
4 changed files with 16 additions and 7 deletions

View File

@ -127,6 +127,11 @@ ApplicationWindow {
onValueChanged: shadersettings.contrast = value
_value: shadersettings.contrast
}
SettingComponent{
name: "Brightness"
onValueChanged: shadersettings.brightness = value
_value: shadersettings.brightness
}
}
}
}

View File

@ -37,6 +37,8 @@ ShaderEffect {
property real brightness_flickering: shadersettings.brightness_flickering
property real horizontal_sincronization: shadersettings.horizontal_sincronization
property real brightness: shadersettings.brightness * 1.5 + 0.5
property real deltay: 3 / terminal.height
property real deltax: 3 / terminal.width
@ -173,6 +175,6 @@ ShaderEffect {
finalColor = mix(finalColor, vec3(0.0), brightness);" : "") +
"
gl_FragColor = vec4(finalColor, 1.0);
gl_FragColor = vec4(finalColor *"+brightness+", 1.0);
}"
}

View File

@ -26,6 +26,8 @@ Item{
property real ambient_light: 0.2
property real contrast: 0.8
property real brightness: 0.5
function mix(c1, c2, alpha){
return Qt.rgba(c1.r * alpha + c2.r * (1-alpha),
c1.g * alpha + c2.g * (1-alpha),

View File

@ -10,6 +10,7 @@ ShaderEffect{
property real time: timetimer.time
property variant randomFunctionSource: randfuncsource
property real brightness_flickering: shadersettings.brightness_flickering
property real brightness: shadersettings.brightness * 1.5 + 0.5
property color reflection_color: Qt.rgba((font_color.r*0.3 + background_color.r*0.7),
(font_color.g*0.3 + background_color.g*0.7),
@ -28,12 +29,11 @@ ShaderEffect{
varying lowp float brightness;
void main() {
qt_TexCoord0 = qt_MultiTexCoord0;" +
qt_TexCoord0 = qt_MultiTexCoord0;
brightness = "+brightness+";" +
(brightness_flickering !== 0 ?
"brightness = texture2D(randomFunctionSource, vec2(fract(time/(1024.0*2.0)), fract(time/(1024.0*1024.0*2.0)))).r * "+brightness_flickering+";"
:
"brightness = 0.0;") + "
"brightness -= texture2D(randomFunctionSource, vec2(fract(time/(1024.0*2.0)), fract(time/(1024.0*1024.0*2.0)))).r * "+brightness_flickering+";"
: "") + "
gl_Position = qt_Matrix * qt_Vertex;
}"
@ -61,7 +61,7 @@ ShaderEffect{
vec4 txt_normal = texture2D(normals, coords);
vec3 normal = normalize(txt_normal.rgb * 2.0 - 1.0);
vec3 light_dir = normalize(vec3(0.5,0.5, 0.0) - vec3(qt_TexCoord0, 0.0));
float reflection = (dot(normal, light_dir) * 0.4 + 0.2) * (1.0-brightness);
float reflection = (dot(normal, light_dir) * 0.4 + 0.2) * brightness;
vec3 final_color = reflection_color * reflection * 0.5;
final_color += txt_color * ambient_light;
gl_FragColor = vec4(final_color * txt_normal.a, txt_color.a);