mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-10-30 22:54:21 +00:00 
			
		
		
		
	Simplify the unholy overengineered mess of rasterization.
This commit is contained in:
		| @@ -99,7 +99,7 @@ Item{ | |||||||
|  |  | ||||||
|     // FONTS ////////////////////////////////////////////////////////////////// |     // FONTS ////////////////////////////////////////////////////////////////// | ||||||
|  |  | ||||||
|     signal terminalFontChanged(string fontSource, int pixelSize, int lineSpacing, size virtualCharSize) |     signal terminalFontChanged(string fontSource, int pixelSize, int lineSpacing, real screenScaling) | ||||||
|  |  | ||||||
|     Loader{ |     Loader{ | ||||||
|         id: fontManager |         id: fontManager | ||||||
| @@ -141,9 +141,9 @@ Item{ | |||||||
|         var fontSource = fontManager.item.source; |         var fontSource = fontManager.item.source; | ||||||
|         var pixelSize = fontManager.item.pixelSize; |         var pixelSize = fontManager.item.pixelSize; | ||||||
|         var lineSpacing = fontManager.item.lineSpacing; |         var lineSpacing = fontManager.item.lineSpacing; | ||||||
|         var virtualCharSize = fontManager.item.virtualCharSize; |         var screenScaling = fontManager.item.screenScaling; | ||||||
|  |  | ||||||
|         terminalFontChanged(fontSource, pixelSize, lineSpacing, virtualCharSize); |         terminalFontChanged(fontSource, pixelSize, lineSpacing, screenScaling); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // FRAMES ///////////////////////////////////////////////////////////////// |     // FRAMES ///////////////////////////////////////////////////////////////// | ||||||
|   | |||||||
| @@ -27,45 +27,47 @@ Item{ | |||||||
|     property var _font: fontlist.get(selectedFontIndex) |     property var _font: fontlist.get(selectedFontIndex) | ||||||
|     property var _scaling: fontScalingList[selectedScalingIndex] |     property var _scaling: fontScalingList[selectedScalingIndex] | ||||||
|     property var source: _font.source |     property var source: _font.source | ||||||
|     property var fontScalingList: [0.75, 1.0, 1.25, 1.50, 1.75, 2.0, 2.25, 2.5] |     property var fontScalingList: [0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5] | ||||||
|     property int pixelSize: _font.pixelSize * _scaling |     property int pixelSize: _font.pixelSize | ||||||
|     property int lineSpacing: (_font.pixelSize / _font.virtualCharHeight) * _font.lineSpacing |     property int lineSpacing: _font.lineSpacing | ||||||
|     property size virtualCharSize: Qt.size(_font.virtualCharWidth, |     property real screenScaling: _scaling * _font.baseScaling | ||||||
|                                            _font.virtualCharHeight) |  | ||||||
|  |  | ||||||
|     ListModel{ |     ListModel{ | ||||||
|         id: fontlist |         id: fontlist | ||||||
|  |         ListElement{ | ||||||
|  |             text: "Commodore PET 2Y (1977)" | ||||||
|  |             source: "fonts/1977-commodore-pet/COMMODORE_PET_2y.ttf" | ||||||
|  |             lineSpacing: 2 | ||||||
|  |             pixelSize: 16 | ||||||
|  |             baseScaling: 3.0 | ||||||
|  |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             text: "Commodore PET (1977)" |             text: "Commodore PET (1977)" | ||||||
|             source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" |             source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" | ||||||
|             lineSpacing: 2 |             lineSpacing: 2 | ||||||
|             virtualCharWidth: 8 |             pixelSize: 8 | ||||||
|             virtualCharHeight: 8 |             baseScaling: 4.0 | ||||||
|             pixelSize: 32 |  | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             text: "Apple ][ (1977)" |             text: "Apple ][ (1977)" | ||||||
|             source: "fonts/1977-apple2/PrintChar21.ttf" |             source: "fonts/1977-apple2/PrintChar21.ttf" | ||||||
|             lineSpacing: 2 |             lineSpacing: 2 | ||||||
|             virtualCharWidth: 7 |             pixelSize: 8 | ||||||
|             virtualCharHeight: 8 |             baseScaling: 4.0 | ||||||
|             pixelSize: 32 |  | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             text: "Atari 400-800 (1979)" |             text: "Atari 400-800 (1979)" | ||||||
|             source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" |             source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" | ||||||
|             lineSpacing: 3 |             lineSpacing: 3 | ||||||
|             virtualCharWidth: 8 |             pixelSize: 8 | ||||||
|             virtualCharHeight: 8 |             baseScaling: 4.0 | ||||||
|             pixelSize: 32 |  | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             text: "Commodore 64 (1982)" |             text: "Commodore 64 (1982)" | ||||||
|             source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf" |             source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf" | ||||||
|             lineSpacing: 3 |             lineSpacing: 3 | ||||||
|             virtualCharWidth: 8 |             pixelSize: 8 | ||||||
|             virtualCharHeight: 8 |             baseScaling: 4.0 | ||||||
|             pixelSize: 32 |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -27,11 +27,10 @@ Item{ | |||||||
|     property var _font: fontlist.get(selectedFontIndex) |     property var _font: fontlist.get(selectedFontIndex) | ||||||
|     property var _scaling: fontScalingList[selectedScalingIndex] |     property var _scaling: fontScalingList[selectedScalingIndex] | ||||||
|     property var source: _font.source |     property var source: _font.source | ||||||
|     property var fontScalingList: [0.75, 1.0, 1.25, 1.50, 1.75, 2.0, 2.25, 2.50] |     property var fontScalingList: [0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5] | ||||||
|     property int pixelSize: _font.pixelSize * _scaling |     property int pixelSize: _font.pixelSize | ||||||
|     property int lineSpacing: (_font.pixelSize / _font.virtualCharHeight) * _font.lineSpacing |     property int lineSpacing: _font.lineSpacing | ||||||
|     property size virtualCharSize: Qt.size(_font.virtualCharWidth, |     property real screenScaling: _scaling * _font.baseScaling | ||||||
|                                            _font.virtualCharHeight) |  | ||||||
|  |  | ||||||
|     ListModel{ |     ListModel{ | ||||||
|         id: fontlist |         id: fontlist | ||||||
| @@ -39,41 +38,36 @@ Item{ | |||||||
|             text: "Commodore PET 2Y (1977)" |             text: "Commodore PET 2Y (1977)" | ||||||
|             source: "fonts/1977-commodore-pet/COMMODORE_PET_2y.ttf" |             source: "fonts/1977-commodore-pet/COMMODORE_PET_2y.ttf" | ||||||
|             lineSpacing: 2 |             lineSpacing: 2 | ||||||
|             virtualCharWidth: 4 |             pixelSize: 16 | ||||||
|             virtualCharHeight: 8 |             baseScaling: 3.0 | ||||||
|             pixelSize: 32 |  | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             text: "Commodore PET (1977)" |             text: "Commodore PET (1977)" | ||||||
|             source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" |             source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" | ||||||
|             lineSpacing: 2 |             lineSpacing: 2 | ||||||
|             virtualCharWidth: 8 |             pixelSize: 8 | ||||||
|             virtualCharHeight: 8 |             baseScaling: 4.0 | ||||||
|             pixelSize: 32 |  | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             text: "Apple ][ (1977)" |             text: "Apple ][ (1977)" | ||||||
|             source: "fonts/1977-apple2/PrintChar21.ttf" |             source: "fonts/1977-apple2/PrintChar21.ttf" | ||||||
|             lineSpacing: 2 |             lineSpacing: 2 | ||||||
|             virtualCharWidth: 8 |             pixelSize: 8 | ||||||
|             virtualCharHeight: 8 |             baseScaling: 4.0 | ||||||
|             pixelSize: 32 |  | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             text: "Atari 400-800 (1979)" |             text: "Atari 400-800 (1979)" | ||||||
|             source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" |             source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" | ||||||
|             lineSpacing: 3 |             lineSpacing: 3 | ||||||
|             virtualCharWidth: 8 |             pixelSize: 8 | ||||||
|             virtualCharHeight: 8 |             baseScaling: 4.0 | ||||||
|             pixelSize: 32 |  | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             text: "Commodore 64 (1982)" |             text: "Commodore 64 (1982)" | ||||||
|             source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf" |             source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf" | ||||||
|             lineSpacing: 3 |             lineSpacing: 3 | ||||||
|             virtualCharWidth: 8 |             pixelSize: 8 | ||||||
|             virtualCharHeight: 8 |             baseScaling: 4.0 | ||||||
|             pixelSize: 32 |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -30,6 +30,7 @@ Item{ | |||||||
|     property var fontScalingList: [0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5] |     property var fontScalingList: [0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5] | ||||||
|     property int pixelSize: _font.pixelSize * _scaling |     property int pixelSize: _font.pixelSize * _scaling | ||||||
|     property int lineSpacing: pixelSize * _font.lineSpacing |     property int lineSpacing: pixelSize * _font.lineSpacing | ||||||
|  |     property real screenScaling: 1.0 | ||||||
|  |  | ||||||
|     //In this configuration lineSpacing is proportional to pixelSize. |     //In this configuration lineSpacing is proportional to pixelSize. | ||||||
|  |  | ||||||
|   | |||||||
| @@ -46,9 +46,6 @@ Item{ | |||||||
|     property real _maxBlurCoefficient: 0.90 |     property real _maxBlurCoefficient: 0.90 | ||||||
|  |  | ||||||
|     property size virtualPxSize: Qt.size(1,1) |     property size virtualPxSize: Qt.size(1,1) | ||||||
|     property size virtual_resolution: Qt.size(width / virtualPxSize.width, height / virtualPxSize.height) |  | ||||||
|     property real deltay: 0.5 / virtual_resolution.height |  | ||||||
|     property real deltax: 0.5 / virtual_resolution.width |  | ||||||
|  |  | ||||||
|     property real mBloom: shadersettings.bloom_strength |     property real mBloom: shadersettings.bloom_strength | ||||||
|     property int mScanlines: shadersettings.rasterization |     property int mScanlines: shadersettings.rasterization | ||||||
| @@ -73,8 +70,10 @@ Item{ | |||||||
|  |  | ||||||
|     KTerminal { |     KTerminal { | ||||||
|         id: kterminal |         id: kterminal | ||||||
|         anchors.fill: parent |         width: parent.width | ||||||
|  |         height: parent.height | ||||||
|  |  | ||||||
|  |         smooth: false | ||||||
|         colorScheme: "cool-retro-term" |         colorScheme: "cool-retro-term" | ||||||
|  |  | ||||||
|         session: KSession { |         session: KSession { | ||||||
| @@ -89,30 +88,15 @@ Item{ | |||||||
|         FontLoader{ id: fontLoader } |         FontLoader{ id: fontLoader } | ||||||
|         Text{id: fontMetrics; text: "B"; visible: false} |         Text{id: fontMetrics; text: "B"; visible: false} | ||||||
|  |  | ||||||
|         function getPaintedSize(pixelSize){ |         function handleFontChange(fontSource, pixelSize, lineSpacing, screenScaling){ | ||||||
|             fontMetrics.font.family = fontLoader.name; |  | ||||||
|             fontMetrics.font.pixelSize = pixelSize; |  | ||||||
|             return Qt.size(fontMetrics.paintedWidth, fontMetrics.paintedHeight); |  | ||||||
|         } |  | ||||||
|         function isValid(size){ |  | ||||||
|             return size.width >= 0 && size.height >= 0; |  | ||||||
|         } |  | ||||||
|         function handleFontChange(fontSource, pixelSize, lineSpacing, virtualCharSize){ |  | ||||||
|             fontLoader.source = fontSource; |             fontLoader.source = fontSource; | ||||||
|             font.pixelSize = pixelSize * shadersettings.window_scaling; |             font.pixelSize = pixelSize; | ||||||
|             font.family = fontLoader.name; |             font.family = fontLoader.name; | ||||||
|  |  | ||||||
|             var paintedSize = getPaintedSize(pixelSize); |             width = Qt.binding(function() {return Math.floor(terminalContainer.width / screenScaling);}); | ||||||
|             var charSize = isValid(virtualCharSize) |             height = Qt.binding(function() {return Math.floor(terminalContainer.height / screenScaling);}); | ||||||
|                     ? virtualCharSize |  | ||||||
|                     : Qt.size(paintedSize.width / 2, paintedSize.height / 2); |  | ||||||
|  |  | ||||||
|             var virtualPxSize = Qt.size((paintedSize.width  / charSize.width) * shadersettings.window_scaling, |             setLineSpacing(lineSpacing); | ||||||
|                                         (paintedSize.height / charSize.height) * shadersettings.window_scaling) |  | ||||||
|  |  | ||||||
|             terminalContainer.virtualPxSize = virtualPxSize; |  | ||||||
|  |  | ||||||
|             setLineSpacing(lineSpacing * shadersettings.window_scaling); |  | ||||||
|             restartBlurredSource(); |             restartBlurredSource(); | ||||||
|         } |         } | ||||||
|         Component.onCompleted: { |         Component.onCompleted: { | ||||||
| @@ -157,10 +141,10 @@ Item{ | |||||||
|             var coord = correctDistortion(mouse.x, mouse.y); |             var coord = correctDistortion(mouse.x, mouse.y); | ||||||
|             kterminal.mouseReleaseEvent(coord, mouse.button, mouse.modifiers); |             kterminal.mouseReleaseEvent(coord, mouse.button, mouse.modifiers); | ||||||
|         } |         } | ||||||
| 	onPositionChanged: { |         onPositionChanged: { | ||||||
| 	    var coord = correctDistortion(mouse.x, mouse.y); |             var coord = correctDistortion(mouse.x, mouse.y); | ||||||
| 	    kterminal.mouseMoveEvent(coord, mouse.button, mouse.buttons, mouse.modifiers); |             kterminal.mouseMoveEvent(coord, mouse.button, mouse.buttons, mouse.modifiers); | ||||||
| 	} |         } | ||||||
|  |  | ||||||
|         //Frame displacement properties |         //Frame displacement properties | ||||||
|         property real dtop: frame.item.displacementTop |         property real dtop: frame.item.displacementTop | ||||||
| @@ -178,8 +162,8 @@ Item{ | |||||||
|             var cc = Qt.size(0.5 - x, 0.5 - y); |             var cc = Qt.size(0.5 - x, 0.5 - y); | ||||||
|             var distortion = (cc.height * cc.height + cc.width * cc.width) * shadersettings.screen_distortion; |             var distortion = (cc.height * cc.height + cc.width * cc.width) * shadersettings.screen_distortion; | ||||||
|  |  | ||||||
|             return Qt.point((x - cc.width  * (1+distortion) * distortion) * width, |             return Qt.point((x - cc.width  * (1+distortion) * distortion) * kterminal.width, | ||||||
|                            (y - cc.height * (1+distortion) * distortion) * height) |                            (y - cc.height * (1+distortion) * distortion) * kterminal.height) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     ShaderEffectSource{ |     ShaderEffectSource{ | ||||||
| @@ -212,24 +196,24 @@ Item{ | |||||||
|     ShaderEffectSource{ |     ShaderEffectSource{ | ||||||
|         id: finalSource |         id: finalSource | ||||||
|         sourceItem: blurredterminal |         sourceItem: blurredterminal | ||||||
|         sourceRect: frame.sourceRect |         //sourceRect: frame.sourceRect | ||||||
|         hideSource: true |         hideSource: true | ||||||
|  |         //Smooth looks ugly when rasterization is used. | ||||||
|  |         smooth: shadersettings.rasterization == shadersettings.no_rasterization | ||||||
|     } |     } | ||||||
|     ShaderEffect { |     ShaderEffect { | ||||||
|         id: blurredterminal |         id: blurredterminal | ||||||
|         anchors.fill: parent |         anchors.fill: kterminal | ||||||
|         property variant source: source |         property variant source: source | ||||||
|         property variant blurredSource: (mBlur !== 0) ? blurredSource : undefined |         property variant blurredSource: (mBlur !== 0) ? blurredSource : undefined | ||||||
|         property real blurCoefficient: (1.0 - motionBlurCoefficient) * fpsAttenuation |         property real blurCoefficient: (1.0 - motionBlurCoefficient) * fpsAttenuation | ||||||
|         property size virtual_resolution: parent.virtual_resolution |         property size virtual_resolution: Qt.size(kterminal.width, kterminal.height) | ||||||
|         property size delta: Qt.size((mScanlines == shadersettings.pixel_rasterization ? deltax : 0), |  | ||||||
|                                      mScanlines != shadersettings.no_rasterization ? deltay : 0) |  | ||||||
|         blending: false |         blending: false | ||||||
|  |  | ||||||
|         fragmentShader: |         fragmentShader: | ||||||
|             "uniform lowp float qt_Opacity;" + |             "uniform lowp float qt_Opacity;" + | ||||||
|             "uniform lowp sampler2D source;" + |             "uniform lowp sampler2D source;" + | ||||||
|             "uniform highp vec2 delta;" + |  | ||||||
|  |  | ||||||
|             "varying highp vec2 qt_TexCoord0; |             "varying highp vec2 qt_TexCoord0; | ||||||
|  |  | ||||||
| @@ -246,13 +230,6 @@ Item{ | |||||||
|  |  | ||||||
|             "void main() {" + |             "void main() {" + | ||||||
|                 "vec2 coords = qt_TexCoord0;" + |                 "vec2 coords = qt_TexCoord0;" + | ||||||
|                 (mScanlines != shadersettings.no_rasterization ? " |  | ||||||
|                             coords.y = floor(virtual_resolution.y * coords.y) / virtual_resolution.y;" + |  | ||||||
|                 (mScanlines == shadersettings.pixel_rasterization ? " |  | ||||||
|                             coords.x = floor(virtual_resolution.x * coords.x) / virtual_resolution.x;" : "") |  | ||||||
|                 : "") + |  | ||||||
|                 "coords = coords + delta;" + |  | ||||||
|  |  | ||||||
|                 "vec4 color = texture2D(source, coords) * 256.0; |                 "vec4 color = texture2D(source, coords) * 256.0; | ||||||
|                  color.a = rgb2grey(color.rgb);" + |                  color.a = rgb2grey(color.rgb);" + | ||||||
|  |  | ||||||
| @@ -291,7 +268,7 @@ Item{ | |||||||
|         sourceComponent: ShaderEffectSource{ |         sourceComponent: ShaderEffectSource{ | ||||||
|             sourceItem: bloomEffectLoader.item |             sourceItem: bloomEffectLoader.item | ||||||
|             hideSource: true |             hideSource: true | ||||||
|             sourceRect: frame.sourceRect |             //sourceRect: frame.sourceRect | ||||||
|             smooth: false |             smooth: false | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -301,7 +278,7 @@ Item{ | |||||||
|     ShaderEffect { |     ShaderEffect { | ||||||
|         id: staticNoiseEffect |         id: staticNoiseEffect | ||||||
|         anchors.fill: parent |         anchors.fill: parent | ||||||
|         property size virtual_resolution: terminalContainer.virtual_resolution |         property size virtual_resolution: Qt.size(kterminal.width, kterminal.height) | ||||||
|  |  | ||||||
|         blending: false |         blending: false | ||||||
|  |  | ||||||
| @@ -332,9 +309,9 @@ Item{ | |||||||
|                 return mix(s, n, inter.y); |                 return mix(s, n, inter.y); | ||||||
|             }" + |             }" + | ||||||
|  |  | ||||||
|         "void main() {" + |             "void main() {" + | ||||||
|             "gl_FragColor.a = smoothNoise(qt_TexCoord0 * virtual_resolution);" + |                 "gl_FragColor.a = smoothNoise(qt_TexCoord0 * virtual_resolution);" + | ||||||
|         "}" |             "}" | ||||||
|  |  | ||||||
|         onStatusChanged: if (log) console.log(log) //Print warning messages |         onStatusChanged: if (log) console.log(log) //Print warning messages | ||||||
|     } |     } | ||||||
| @@ -350,77 +327,117 @@ Item{ | |||||||
|  |  | ||||||
|     // RASTERIZATION ////////////////////////////////////////////////////////// |     // RASTERIZATION ////////////////////////////////////////////////////////// | ||||||
|  |  | ||||||
|     ShaderEffect{ | //    ShaderEffect{ | ||||||
|         id: rasterizationContainer | //        id: rasterizationContainer | ||||||
|         width: frame.sourceRect.width | //        width: frame.sourceRect.width | ||||||
|         height: frame.sourceRect.height | //        height: frame.sourceRect.height | ||||||
|         property size offset: Qt.size(width - rasterizationEffect.width, height - rasterizationEffect.height) | //        property size offset: Qt.size(width - rasterizationEffect.width, height - rasterizationEffect.height) | ||||||
|         property size txtRes: Qt.size(width, height) | //        property size txtRes: Qt.size(width, height) | ||||||
|  |  | ||||||
|  | //        blending: false | ||||||
|  |  | ||||||
|  | //        fragmentShader: | ||||||
|  | //            "uniform lowp float qt_Opacity; | ||||||
|  | //             uniform highp vec2 offset; | ||||||
|  | //             uniform highp vec2 txtRes;" + | ||||||
|  |  | ||||||
|  | //            "varying highp vec2 qt_TexCoord0;" + | ||||||
|  |  | ||||||
|  | //            "void main() {" + | ||||||
|  | //                "float color = 1.0; | ||||||
|  | //                 color *= smoothstep(0.0, offset.x / txtRes.x, qt_TexCoord0.x); | ||||||
|  | //                 color *= smoothstep(0.0, offset.y / txtRes.y, qt_TexCoord0.y); | ||||||
|  | //                 color *= smoothstep(0.0, offset.x / txtRes.x, 1.0 - qt_TexCoord0.x); | ||||||
|  | //                 color *= smoothstep(0.0, offset.y / txtRes.y, 1.0 - qt_TexCoord0.y);" + | ||||||
|  |  | ||||||
|  | //                "float distance = length(vec2(0.5) - qt_TexCoord0);" + | ||||||
|  | //                "color = mix(color, 0.0, 1.2 * distance * distance);" + | ||||||
|  |  | ||||||
|  | //                "gl_FragColor.a = color;" + | ||||||
|  | //            "}" | ||||||
|  |  | ||||||
|  | //        ShaderEffect { | ||||||
|  | //            id: rasterizationEffect | ||||||
|  | //            width: terminalContainer.width | ||||||
|  | //            height: terminalContainer.height | ||||||
|  | //            anchors.centerIn: parent | ||||||
|  | //            property size virtual_resolution: Qt.size(kterminal.width, kterminal.height) | ||||||
|  |  | ||||||
|  | //            blending: false | ||||||
|  |  | ||||||
|  | //            fragmentShader: | ||||||
|  | //                "uniform lowp float qt_Opacity;" + | ||||||
|  |  | ||||||
|  | //                "varying highp vec2 qt_TexCoord0; | ||||||
|  | //                     uniform highp vec2 virtual_resolution; | ||||||
|  |  | ||||||
|  | //                     float getScanlineIntensity(vec2 coords) { | ||||||
|  | //                        float result = 1.0;" + | ||||||
|  | //                        (mScanlines != shadersettings.no_rasterization ? | ||||||
|  | //                            "result *= abs(sin(coords.y * virtual_resolution.y * "+Math.PI+"));" : "") + | ||||||
|  | //                        (mScanlines == shadersettings.pixel_rasterization ? | ||||||
|  | //                            "result *= abs(sin(coords.x * virtual_resolution.x * "+Math.PI+"));" : "") + " | ||||||
|  | //                        return result; | ||||||
|  | //                     }" + | ||||||
|  |  | ||||||
|  | //            "void main() {" + | ||||||
|  | //                "float color = getScanlineIntensity(qt_TexCoord0);" + | ||||||
|  |  | ||||||
|  | //                "float distance = length(vec2(0.5) - qt_TexCoord0);" + | ||||||
|  | //                "color = mix(color, 0.0, 1.2 * distance * distance);" + | ||||||
|  |  | ||||||
|  | //                "gl_FragColor.a = color;" + | ||||||
|  | //            "}" | ||||||
|  |  | ||||||
|  | //            onStatusChanged: if (log) console.log(log) //Print warning messages | ||||||
|  | //        } | ||||||
|  | //        onStatusChanged: if (log) console.log(log) //Print warning messages | ||||||
|  | //    } | ||||||
|  | //    ShaderEffectSource{ | ||||||
|  | //        id: rasterizationEffectSource | ||||||
|  | //        sourceItem: rasterizationContainer | ||||||
|  | //        hideSource: true | ||||||
|  | //        smooth: true | ||||||
|  | //        //format: ShaderEffectSource.Alpha | ||||||
|  | //    } | ||||||
|  |     ShaderEffect { | ||||||
|  |         id: rasterizationEffect | ||||||
|  |         width: parent.width * 2 | ||||||
|  |         height: parent.height * 2 | ||||||
|  |         property size virtual_resolution: Qt.size(kterminal.width, kterminal.height) | ||||||
|  |  | ||||||
|         blending: false |         blending: false | ||||||
|  |  | ||||||
|         fragmentShader: |         fragmentShader: | ||||||
|             "uniform lowp float qt_Opacity; |             "uniform lowp float qt_Opacity;" + | ||||||
|              uniform highp vec2 offset; |  | ||||||
|              uniform highp vec2 txtRes;" + |  | ||||||
|  |  | ||||||
|             "varying highp vec2 qt_TexCoord0;" + |             "varying highp vec2 qt_TexCoord0; | ||||||
|  |                  uniform highp vec2 virtual_resolution; | ||||||
|  |  | ||||||
|             "void main() {" + |                  highp float getScanlineIntensity(vec2 coords) { | ||||||
|                 "float color = 1.0; |                     highp float result = 1.0;" + | ||||||
|                  color *= smoothstep(0.0, offset.x / txtRes.x, qt_TexCoord0.x); |                     (mScanlines != shadersettings.no_rasterization ? | ||||||
|                  color *= smoothstep(0.0, offset.y / txtRes.y, qt_TexCoord0.y); |                         "result *= abs(sin(coords.y * virtual_resolution.y * "+Math.PI+"));" : "") + | ||||||
|                  color *= smoothstep(0.0, offset.x / txtRes.x, 1.0 - qt_TexCoord0.x); |                     (mScanlines == shadersettings.pixel_rasterization ? | ||||||
|                  color *= smoothstep(0.0, offset.y / txtRes.y, 1.0 - qt_TexCoord0.y);" + |                         "result *= abs(sin(coords.x * virtual_resolution.x * "+Math.PI+"));" : "") + " | ||||||
|  |                     return result; | ||||||
|  |                  }" + | ||||||
|  |  | ||||||
|                 "float distance = length(vec2(0.5) - qt_TexCoord0);" + |         "void main() {" + | ||||||
|                 "color = mix(color, 0.0, 1.2 * distance * distance);" + |             "highp float color = getScanlineIntensity(qt_TexCoord0);" + | ||||||
|  |  | ||||||
|                 "gl_FragColor.a = color;" + |             "float distance = length(vec2(0.5) - qt_TexCoord0);" + | ||||||
|             "}" |             "color = mix(color, 0.0, 1.2 * distance * distance);" + | ||||||
|  |  | ||||||
|         ShaderEffect { |             "gl_FragColor.a = color;" + | ||||||
|             id: rasterizationEffect |         "}" | ||||||
|             width: terminalContainer.width |  | ||||||
|             height: terminalContainer.height |  | ||||||
|             anchors.centerIn: 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; |  | ||||||
|  |  | ||||||
|                      float getScanlineIntensity(vec2 coords) { |  | ||||||
|                         float result = 1.0;" + |  | ||||||
|                         (mScanlines != shadersettings.no_rasterization ? |  | ||||||
|                             "result *= abs(sin(coords.y * virtual_resolution.y * "+Math.PI+"));" : "") + |  | ||||||
|                         (mScanlines == shadersettings.pixel_rasterization ? |  | ||||||
|                             "result *= abs(sin(coords.x * virtual_resolution.x * "+Math.PI+"));" : "") + " |  | ||||||
|                         return result; |  | ||||||
|                      }" + |  | ||||||
|  |  | ||||||
|             "void main() {" + |  | ||||||
|                 "float color = getScanlineIntensity(qt_TexCoord0);" + |  | ||||||
|  |  | ||||||
|                 "float distance = length(vec2(0.5) - qt_TexCoord0);" + |  | ||||||
|                 "color = mix(color, 0.0, 1.2 * distance * distance);" + |  | ||||||
|  |  | ||||||
|                 "gl_FragColor.a = color;" + |  | ||||||
|             "}" |  | ||||||
|  |  | ||||||
|             onStatusChanged: if (log) console.log(log) //Print warning messages |  | ||||||
|         } |  | ||||||
|         onStatusChanged: if (log) console.log(log) //Print warning messages |         onStatusChanged: if (log) console.log(log) //Print warning messages | ||||||
|     } |     } | ||||||
|     ShaderEffectSource{ |     ShaderEffectSource{ | ||||||
|         id: rasterizationEffectSource |         id: rasterizationEffectSource | ||||||
|         sourceItem: rasterizationContainer |         sourceItem: rasterizationEffect | ||||||
|         hideSource: true |         hideSource: true | ||||||
|         smooth: true |         smooth: true | ||||||
|         //format: ShaderEffectSource.Alpha |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ | |||||||
| import QtQuick 2.2 | import QtQuick 2.2 | ||||||
| import QtGraphicalEffects 1.0 | import QtGraphicalEffects 1.0 | ||||||
|  |  | ||||||
|  |  | ||||||
| ShaderEffect { | ShaderEffect { | ||||||
|     property color font_color: shadersettings.font_color |     property color font_color: shadersettings.font_color | ||||||
|     property color background_color: shadersettings.background_color |     property color background_color: shadersettings.background_color | ||||||
| @@ -103,8 +104,7 @@ ShaderEffect { | |||||||
|             uniform lowp float horizontal_sincronization;" : "") + |             uniform lowp float horizontal_sincronization;" : "") + | ||||||
|         " |         " | ||||||
|         void main() { |         void main() { | ||||||
|             qt_TexCoord0.x = -"+str(disp_left)+"/txt_Size.x + qt_MultiTexCoord0.x / ((txt_Size.x -("+str(disp_left+disp_right)+")) / txt_Size.x);" + " |             qt_TexCoord0 = qt_MultiTexCoord0; | ||||||
|             qt_TexCoord0.y = -"+str(disp_top)+"/txt_Size.y + qt_MultiTexCoord0.y / ((txt_Size.y -("+str(disp_top+disp_bottom)+")) / txt_Size.y);" + " |  | ||||||
|             vec2 coords = vec2(fract(time/(1024.0*2.0)), fract(time/(1024.0*1024.0)));" + |             vec2 coords = vec2(fract(time/(1024.0*2.0)), fract(time/(1024.0*1024.0)));" + | ||||||
|             (brightness_flickering !== 0.0 ? " |             (brightness_flickering !== 0.0 ? " | ||||||
|                 brightness = 1.0 + (texture2D(randomFunctionSource, coords).g - 0.5) * brightness_flickering;" |                 brightness = 1.0 + (texture2D(randomFunctionSource, coords).g - 0.5) * brightness_flickering;" | ||||||
|   | |||||||
| @@ -148,8 +148,6 @@ ApplicationWindow{ | |||||||
|         width: parent.width * shadersettings.window_scaling |         width: parent.width * shadersettings.window_scaling | ||||||
|         height: parent.height * shadersettings.window_scaling |         height: parent.height * shadersettings.window_scaling | ||||||
|         scale: 1.0 / shadersettings.window_scaling |         scale: 1.0 / shadersettings.window_scaling | ||||||
|         smooth: false |  | ||||||
|         antialiasing: false |  | ||||||
|         opacity: shadersettings.windowOpacity * 0.3 + 0.7 |         opacity: shadersettings.windowOpacity * 0.3 + 0.7 | ||||||
|  |  | ||||||
|         Loader{ |         Loader{ | ||||||
| @@ -164,7 +162,6 @@ ApplicationWindow{ | |||||||
|         PreprocessedTerminal{ |         PreprocessedTerminal{ | ||||||
|             id: terminal |             id: terminal | ||||||
|             anchors.fill: parent |             anchors.fill: parent | ||||||
|             anchors.margins: 30 |  | ||||||
|         } |         } | ||||||
|         ShaderTerminal{ |         ShaderTerminal{ | ||||||
|             id: shadercontainer |             id: shadercontainer | ||||||
|   | |||||||
| @@ -87,7 +87,7 @@ const ColorEntry base_color_table[TABLE_COLORS] = | |||||||
| // scroll increment used when dragging selection at top/bottom of window. | // scroll increment used when dragging selection at top/bottom of window. | ||||||
|  |  | ||||||
| // static | // static | ||||||
| bool KTerminalDisplay::_antialiasText = true; | bool KTerminalDisplay::_antialiasText = false; | ||||||
| bool KTerminalDisplay::HAVE_TRANSPARENCY = true; | bool KTerminalDisplay::HAVE_TRANSPARENCY = true; | ||||||
|  |  | ||||||
| // we use this to force QPainter to display text in LTR mode | // we use this to force QPainter to display text in LTR mode | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user