From d6288518c46799b930c8b727fcdd47fbe0d242ed Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Mon, 11 Aug 2014 19:23:03 +0200 Subject: [PATCH] Added RGB shift effect. --- app/ApplicationSettings.qml | 23 ++++++++++++++--------- app/SettingsEffectsTab.qml | 6 ++++++ app/ShaderTerminal.qml | 16 +++++++++++++++- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/app/ApplicationSettings.qml b/app/ApplicationSettings.qml index d3df275..faa56a6 100644 --- a/app/ApplicationSettings.qml +++ b/app/ApplicationSettings.qml @@ -77,6 +77,8 @@ Item{ property real horizontal_sincronization: 0.08 property real brightness_flickering: 0.1 + property real rgb_shift: 0.0 + readonly property int no_rasterization: 0 readonly property int scanline_rasterization: 1 readonly property int pixel_rasterization: 2 @@ -186,6 +188,7 @@ Item{ bloom_strength: bloom_strength, rasterization: rasterization, jitter: jitter, + rgb_shift: rgb_shift, brightness: brightness, contrast: contrast, ambient_light: ambient_light, @@ -258,6 +261,8 @@ Item{ jitter = settings.jitter !== undefined ? settings.jitter : jitter; + rgb_shift = settings.rgb_shift !== undefined ? settings.rgb_shift : rgb_shift; + ambient_light = settings.ambient_light !== undefined ? settings.ambient_light : ambient_light; contrast = settings.contrast !== undefined ? settings.contrast : contrast; brightness = settings.brightness !== undefined ? settings.brightness : brightness; @@ -315,47 +320,47 @@ Item{ id: profileslist ListElement{ text: "Default Amber" - obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.65,"brightness":0.5,"brightness_flickering":0.1,"contrast":0.85,"fontIndex":0,"font_color":"#ff8100","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.08,"jitter":0.18,"motion_blur":0.4,"noise_strength":0.1,"rasterization":0,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":0,"saturation_color":0}' + obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.65,"brightness":0.5,"brightness_flickering":0.1,"contrast":0.85,"fontIndex":0,"font_color":"#ff8100","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.08,"jitter":0.18,"motion_blur":0.4,"noise_strength":0.1,"rasterization":0,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":0,"saturation_color":0,"rgb_shift":0}' builtin: true } ListElement{ text: "Default Green" - obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4,"brightness":0.5,"brightness_flickering":0.1,"contrast":0.85,"fontIndex":0,"font_color":"#0ccc68","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.08,"jitter":0.18,"motion_blur":0.45,"noise_strength":0.1,"rasterization":0,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":0,"saturation_color":0}' + obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4,"brightness":0.5,"brightness_flickering":0.1,"contrast":0.85,"fontIndex":0,"font_color":"#0ccc68","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.08,"jitter":0.18,"motion_blur":0.45,"noise_strength":0.1,"rasterization":0,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":0,"saturation_color":0,"rgb_shift":0}' builtin: true } ListElement{ text: "Default Scanlines" - obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4,"brightness":0.5,"brightness_flickering":0.1,"contrast":0.85,"fontIndex":0,"font_color":"#00ff5b","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.07,"jitter":0.11,"motion_blur":0.4,"noise_strength":0.05,"rasterization":1,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":0,"saturation_color":0}' + obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4,"brightness":0.5,"brightness_flickering":0.1,"contrast":0.85,"fontIndex":0,"font_color":"#00ff5b","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.07,"jitter":0.11,"motion_blur":0.4,"noise_strength":0.05,"rasterization":1,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":0,"saturation_color":0,"rgb_shift":0}' builtin: true } ListElement{ text: "Default Pixelated" - obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4,"brightness":0.5,"brightness_flickering":0.1,"contrast":0.85,"fontIndex":0,"font_color":"#ff8100","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.1,"jitter":0,"motion_blur":0.45,"noise_strength":0.14,"rasterization":2,"screen_distortion":0.05,"windowOpacity":1,"chroma_color":0,"saturation_color":0}' + obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4,"brightness":0.5,"brightness_flickering":0.1,"contrast":0.85,"fontIndex":0,"font_color":"#ff8100","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.1,"jitter":0,"motion_blur":0.45,"noise_strength":0.14,"rasterization":2,"screen_distortion":0.05,"windowOpacity":1,"chroma_color":0,"saturation_color":0,"rgb_shift":0}' builtin: true } ListElement{ text: "Apple ][" - obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.5,"brightness":0.5,"brightness_flickering":0.2,"contrast":0.85,"fontIndex":2,"font_color":"#2fff91","frames_index":1,"glowing_line_strength":0.22,"horizontal_sincronization":0.08,"jitter":0.1,"motion_blur":0.65,"noise_strength":0.08,"rasterization":1,"screen_distortion":0.18,"windowOpacity":1,"chroma_color":0,"saturation_color":0}' + obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.5,"brightness":0.5,"brightness_flickering":0.2,"contrast":0.85,"fontIndex":2,"font_color":"#2fff91","frames_index":1,"glowing_line_strength":0.22,"horizontal_sincronization":0.08,"jitter":0.1,"motion_blur":0.65,"noise_strength":0.08,"rasterization":1,"screen_distortion":0.18,"windowOpacity":1,"chroma_color":0,"saturation_color":0,"rgb_shift":0}' builtin: true } ListElement{ text: "Vintage" - obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4,"brightness":0.5,"brightness_flickering":0.54,"contrast":0.85,"fontIndex":0,"font_color":"#00ff3e","frames_index":2,"glowing_line_strength":0.3,"horizontal_sincronization":0.2,"jitter":0.4,"motion_blur":0.75,"noise_strength":0.2,"rasterization":1,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":0,"saturation_color":0}' + obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4,"brightness":0.5,"brightness_flickering":0.54,"contrast":0.85,"fontIndex":0,"font_color":"#00ff3e","frames_index":2,"glowing_line_strength":0.3,"horizontal_sincronization":0.2,"jitter":0.4,"motion_blur":0.75,"noise_strength":0.2,"rasterization":1,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":0,"saturation_color":0,"rgb_shift":0}' builtin: true } ListElement{ text: "IBM Dos" - obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4,"brightness":0.5,"brightness_flickering":0.07,"contrast":0.85,"fontIndex":7,"font_color":"#ffffff","frames_index":1,"glowing_line_strength":0.13,"horizontal_sincronization":0,"jitter":0.08,"motion_blur":0.3,"noise_strength":0.03,"rasterization":0,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":1,"saturation_color":0}' + obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4,"brightness":0.5,"brightness_flickering":0.07,"contrast":0.85,"fontIndex":7,"font_color":"#ffffff","frames_index":1,"glowing_line_strength":0.13,"horizontal_sincronization":0,"jitter":0.08,"motion_blur":0.3,"noise_strength":0.03,"rasterization":0,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":1,"saturation_color":0,"rgb_shift":0.5}' builtin: true } ListElement{ text: "IBM 3278" - obj_string: '{"ambient_light":0.1,"background_color":"#000000","bloom_strength":0.15,"brightness":0.5,"brightness_flickering":0,"contrast":0.95,"fontIndex":8,"font_color":"#0ccc68","frames_index":1,"glowing_line_strength":0,"horizontal_sincronization":0,"jitter":0,"motion_blur":0.6,"noise_strength":0,"rasterization":0,"screen_distortion":0.1,"windowOpacity":1}' + obj_string: '{"ambient_light":0.1,"background_color":"#000000","bloom_strength":0.15,"brightness":0.5,"brightness_flickering":0,"contrast":0.95,"fontIndex":8,"font_color":"#0ccc68","frames_index":1,"glowing_line_strength":0,"horizontal_sincronization":0,"jitter":0,"motion_blur":0.6,"noise_strength":0,"rasterization":0,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":0,"saturation_color":0,"rgb_shift":0}' builtin: true } ListElement{ text: "Transparent Green" - obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4549689440993788,"brightness":0.5,"brightness_flickering":0.20341614906832298,"contrast":0.85,"fontIndex":0,"font_color":"#0ccc68","frames_index":0,"glowing_line_strength":0.15993788819875776,"horizontal_sincronization":0.05045871559633028,"jitter":0.20341614906832298,"motion_blur":0.24999999999999997,"noise_strength":0.20031055900621117,"rasterization":0,"screen_distortion":0.05045871559633028,"windowOpacity":0.5956221198156681,"chroma_color":0,"saturation_color":0}' + obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4549689440993788,"brightness":0.5,"brightness_flickering":0.20341614906832298,"contrast":0.85,"fontIndex":0,"font_color":"#0ccc68","frames_index":0,"glowing_line_strength":0.15993788819875776,"horizontal_sincronization":0.05045871559633028,"jitter":0.20341614906832298,"motion_blur":0.24999999999999997,"noise_strength":0.20031055900621117,"rasterization":0,"screen_distortion":0.05045871559633028,"windowOpacity":0.5956221198156681,"chroma_color":0,"saturation_color":0,"rgb_shift":0}' builtin: true } } diff --git a/app/SettingsEffectsTab.qml b/app/SettingsEffectsTab.qml index 093801d..2d71b48 100644 --- a/app/SettingsEffectsTab.qml +++ b/app/SettingsEffectsTab.qml @@ -74,6 +74,12 @@ Tab{ onNewValue: shadersettings.horizontal_sincronization = newValue; value: shadersettings.horizontal_sincronization; } + CheckableSlider{ + name: qsTr("RGB shift") + onNewValue: shadersettings.rgb_shift = newValue; + value: shadersettings.rgb_shift; + enabled: shadersettings.chroma_color !== 0 + } } } } diff --git a/app/ShaderTerminal.qml b/app/ShaderTerminal.qml index 06d4d7e..bdd3a87 100644 --- a/app/ShaderTerminal.qml +++ b/app/ShaderTerminal.qml @@ -42,6 +42,8 @@ ShaderEffect { property real chroma_color: shadersettings.chroma_color; property real saturation_color: shadersettings.saturation_color; + property real rgb_shift: shadersettings.rgb_shift * 0.2 + property real brightness_flickering: shadersettings.brightness_flickering property real horizontal_sincronization: shadersettings.horizontal_sincronization @@ -144,6 +146,8 @@ ShaderEffect { uniform lowp float chroma_color;" : "") + (jitter !== 0 ? " uniform lowp float jitter;" : "") + + (rgb_shift !== 0 ? " + uniform lowp float rgb_shift;" : "") + (brightness_flickering !== 0 ? " varying lowp float brightness;" : "") + (horizontal_sincronization !== 0 ? " @@ -199,7 +203,17 @@ ShaderEffect { color += randomPass(coords) * glowing_line_strength;" : "") + (chroma_color !== 0 ? - "vec4 realBackColor = texture2D(source, txt_coords);" + + (rgb_shift !== 0 ? " + float rgb_noise = abs(texture2D(noiseSource, vec2(fract(time/(1024.0 * 256.0)), fract(time/(1024.0*1024.0)))).a - 0.5); + vec4 realBackColor = texture2D(source, txt_coords); + vec2 rcolor = texture2D(source, txt_coords + vec2(0.1, 0.0) * rgb_shift * rgb_noise).ra; + vec2 bcolor = texture2D(source, txt_coords - vec2(0.1, 0.0) * rgb_shift * rgb_noise).ba; + realBackColor.r = rcolor.x; + realBackColor.b = bcolor.x; + realBackColor.a = 0.33 * (realBackColor.a + rcolor.y + bcolor.y);" + : + "vec4 realBackColor = texture2D(source, txt_coords);") + + "vec4 mixedColor = mix(font_color, realBackColor * font_color, chroma_color);" + "vec4 finalBackColor = mix(background_color, mixedColor, realBackColor.a);" +