diff --git a/app/ShaderManager.qml b/app/ShaderManager.qml index ce3dedd..0643a48 100644 --- a/app/ShaderManager.qml +++ b/app/ShaderManager.qml @@ -27,10 +27,12 @@ ShaderEffect { property variant source: terminal.theSource property variant bloomSource: terminal.bloomSource property variant rasterizationSource: terminal.rasterizationSource + property variant noiseSource: terminal.staticNoiseSource property size txt_Size: Qt.size(frame.sourceRect.width, frame.sourceRect.height) property real bloom: shadersettings.bloom_strength property int rasterization: shadersettings.rasterization + property real rasterization_strength: 0.5 property real noise_strength: shadersettings.noise_strength property real screen_distorsion: shadersettings.screen_distortion @@ -51,6 +53,8 @@ ShaderEffect { property real time: timetimer.time property variant randomFunctionSource: randfuncsource + blending: false + function str(num){ return num.toFixed(8); } @@ -102,7 +106,8 @@ ShaderEffect { (bloom !== 0 ? " uniform highp sampler2D bloomSource;" : "") + (noise_strength !== 0 ? " - uniform highp float noise_strength;" : "") + + uniform highp float noise_strength; + uniform lowp sampler2D noiseSource;" : "") + (screen_distorsion !== 0 ? " uniform highp float screen_distorsion;" : "")+ (glowing_line_strength !== 0 ? " @@ -112,22 +117,6 @@ ShaderEffect { (horizontal_sincronization !== 0 ? " varying lowp float horizontal_distortion;" : "") + - " - highp float rand(vec2 co) - { - highp float a = 12.9898; - highp float b = 78.233; - highp float c = 43758.5453; - highp float dt= dot(co.xy ,vec2(a,b)); - highp float sn= mod(dt,3.14); - return fract(sin(sn) * c); - } - - float stepNoise(vec2 p){ - vec2 newP = p * txt_Size * 0.5; - return rand(floor(newP) + fract(time / 100.0)); - }" + - (glowing_line_strength !== 0 ? " float randomPass(vec2 coords){ return fract(smoothstep(-0.2, 0.0, coords.y - 3.0 * fract(time * 0.0001))) * glowing_line_strength; @@ -162,7 +151,7 @@ ShaderEffect { "float color = texture2D(source, coords).a;" + (noise_strength !== 0 ? " - color += stepNoise(coords) * noise * (1.0 - distance * distance * 2.0);" : "") + + color += texture2D(noiseSource, qt_TexCoord0 * 0.25 + fract(time / 100.0)).a * noise * (1.0 - distance * distance * 2.0);" : "") + (glowing_line_strength !== 0 ? " color += randomPass(coords) * glowing_line_strength;" : "") + @@ -172,7 +161,7 @@ ShaderEffect { "vec3 finalColor = mix(background_color, font_color, color).rgb;" + "finalColor = mix(finalColor * 1.1, vec3(0.0), 1.2 * distance * distance);" + - "finalColor *= texture2D(rasterizationSource, coords).a;" + + "finalColor *= (texture2D(rasterizationSource, coords).a) / "+rasterization_strength+";" + (brightness_flickering !== 0 ? " finalColor *= brightness;" : "") + diff --git a/app/Terminal.qml b/app/Terminal.qml index 38686a1..68b4fc9 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -29,6 +29,7 @@ Item{ property variant theSource: finalSource property variant bloomSource: bloomSourceLoader.item property variant rasterizationSource: rasterizationEffectSource + property variant staticNoiseSource: staticNoiseSource property alias kterminal: kterminal @@ -227,7 +228,7 @@ Item{ property size virtual_resolution: parent.virtual_resolution property size delta: Qt.size((mScanlines == shadersettings.pixel_rasterization ? deltax : 0), mScanlines != shadersettings.no_rasterization ? deltay : 0) - z: 2 + blending: false fragmentShader: "uniform lowp float qt_Opacity;" + @@ -286,12 +287,57 @@ Item{ smooth: false } } + + //Rasterization mask + ShaderEffect { + id: staticNoiseEffect + anchors.fill: parent + property size virtual_resolution: terminalContainer.virtual_resolution + + blending: false + + fragmentShader: + "uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + uniform highp vec2 virtual_resolution;" + + + "highp float rand(vec2 co) + { + highp float a = 12.9898; + highp float b = 78.233; + highp float c = 43758.5453; + highp float dt= dot(co.xy ,vec2(a,b)); + highp float sn= mod(dt,3.14); + return fract(sin(sn) * c); + } + + float stepNoise(vec2 p){ + vec2 newP = p * virtual_resolution; + return rand(newP); + }" + + + "void main() {" + + "gl_FragColor.a = stepNoise(qt_TexCoord0);" + + "}" + } + ShaderEffectSource{ + id: staticNoiseSource + sourceItem: staticNoiseEffect + textureSize: Qt.size(parent.width, parent.height) + wrapMode: ShaderEffectSource.Repeat + smooth: true + hideSource: true + format: ShaderEffectSource.Alpha + } + //Rasterization mask ShaderEffect { id: rasterizationEffect anchors.fill: parent property size virtual_resolution: terminalContainer.virtual_resolution + blending: false + fragmentShader: "uniform lowp float qt_Opacity;" + diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 82a8fa2..8966cde 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget