mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-11-01 15:42:12 +00:00
Add subpixels rasterization and improve existing ones.
This commit is contained in:
@@ -69,64 +69,70 @@ ShaderTerminal{
|
||||
|
||||
bloomSource: bloomSourceLoader.item
|
||||
|
||||
// This shader might be useful in the future. Since we used it only for a couple
|
||||
// of calculations is probably best to move those in the main shader. If in the future
|
||||
// we need to store another fullScreen channel this might be handy.
|
||||
Loader {
|
||||
id: rasterizationEffectLoader
|
||||
active: appSettings.rasterization != appSettings.no_rasterization
|
||||
asynchronous: true
|
||||
sourceComponent: ShaderEffect {
|
||||
id: rasterizationEffect
|
||||
width: 16
|
||||
height: 16
|
||||
|
||||
// ShaderEffect {
|
||||
// id: rasterizationEffect
|
||||
// width: parent.width
|
||||
// height: parent.height
|
||||
// property real outColor: 0.0
|
||||
// property real dispX: (5 / width) * appSettings.windowScaling
|
||||
// property real dispY: (5 / height) * appSettings.windowScaling
|
||||
// property size virtual_resolution: terminal.virtualResolution
|
||||
blending: false
|
||||
|
||||
// blending: false
|
||||
fragmentShader:
|
||||
"uniform lowp float qt_Opacity;" +
|
||||
|
||||
// fragmentShader:
|
||||
// "uniform lowp float qt_Opacity;" +
|
||||
"varying highp vec2 qt_TexCoord0;
|
||||
|
||||
// "varying highp vec2 qt_TexCoord0;
|
||||
// uniform highp vec2 virtual_resolution;
|
||||
// uniform highp float dispX;
|
||||
// uniform highp float dispY;
|
||||
// uniform mediump float outColor;
|
||||
highp float getScanlineIntensity(vec2 coords) {
|
||||
highp float result = 1.0;" +
|
||||
|
||||
// highp float getScanlineIntensity(vec2 coords) {
|
||||
// highp float result = 1.0;" +
|
||||
(appSettings.rasterization == appSettings.scanline_rasterization ?
|
||||
"result *= (smoothstep(0.0, 0.5, coords.y) - smoothstep(0.5, 1.0, coords.y));" : "") +
|
||||
|
||||
// (appSettings.rasterization != appSettings.no_rasterization ?
|
||||
// "result *= abs(sin(coords.y * virtual_resolution.y * "+Math.PI+"));" : "") +
|
||||
// (appSettings.rasterization == appSettings.pixel_rasterization ?
|
||||
// "result *= abs(sin(coords.x * virtual_resolution.x * "+Math.PI+"));" : "") + "
|
||||
(appSettings.rasterization == appSettings.pixel_rasterization ?
|
||||
"result *= (smoothstep(0.0, 0.25, coords.y) - smoothstep(0.75, 1.0, coords.y));
|
||||
result *= (smoothstep(0.0, 0.25, coords.x) - smoothstep(0.75, 1.0, coords.x));" : "") +
|
||||
|
||||
// return result;
|
||||
// }" +
|
||||
(appSettings.rasterization == appSettings.subpixel_rasterization ?
|
||||
"result *= (smoothstep(0.0, 0.25, coords.y) - smoothstep(0.75, 1.0, coords.y));" : "") + "
|
||||
|
||||
// "void main() {" +
|
||||
// "highp float color = getScanlineIntensity(qt_TexCoord0);" +
|
||||
return result;
|
||||
}" +
|
||||
|
||||
// "float distance = length(vec2(0.5) - qt_TexCoord0);" +
|
||||
// "color = mix(color, 0.0, 1.2 * distance * distance);" +
|
||||
"void main() {" +
|
||||
|
||||
// "color *= outColor + smoothstep(0.00, dispX, qt_TexCoord0.x) * (1.0 - outColor);" +
|
||||
// "color *= outColor + smoothstep(0.00, dispY, qt_TexCoord0.y) * (1.0 - outColor);" +
|
||||
// "color *= outColor + (1.0 - smoothstep(1.00 - dispX, 1.00, qt_TexCoord0.x)) * (1.0 - outColor);" +
|
||||
// "color *= outColor + (1.0 - smoothstep(1.00 - dispY, 1.00, qt_TexCoord0.y)) * (1.0 - outColor);" +
|
||||
(appSettings.rasterization == appSettings.subpixel_rasterization ?
|
||||
"highp vec3 color = vec3(0.0);
|
||||
color += vec3(1.0, 0.25, 0.25) * (step(0.0, qt_TexCoord0.x) - step(1.0/3.0, qt_TexCoord0.x));
|
||||
color += vec3(0.25, 1.0, 0.25) * (step(1.0/3.0, qt_TexCoord0.x) - step(2.0/3.0, qt_TexCoord0.x));
|
||||
color += vec3(0.25, 0.25, 1.0) * (step(2.0/3.0, qt_TexCoord0.x) - step(3.0/3.0, qt_TexCoord0.x));"
|
||||
:
|
||||
"highp vec3 color = vec3(1.0);" ) +
|
||||
|
||||
// "gl_FragColor.a = color;" +
|
||||
// "}"
|
||||
"color *= getScanlineIntensity(qt_TexCoord0);
|
||||
gl_FragColor = vec4(color, 1.0);" +
|
||||
"}"
|
||||
|
||||
// onStatusChanged: if (log) console.log(log) //Print warning messages
|
||||
// }
|
||||
onStatusChanged: if (log) console.log(log) //Print warning messages
|
||||
}
|
||||
}
|
||||
|
||||
// rasterizationSource: ShaderEffectSource{
|
||||
// id: rasterizationEffectSource
|
||||
// sourceItem: rasterizationEffect
|
||||
// hideSource: true
|
||||
// smooth: true
|
||||
// wrapMode: ShaderEffectSource.ClampToEdge
|
||||
// visible: false
|
||||
// }
|
||||
Loader {
|
||||
id: rasterizationSourceLoader
|
||||
active: appSettings.rasterization != appSettings.no_rasterization
|
||||
asynchronous: true
|
||||
|
||||
sourceComponent: ShaderEffectSource {
|
||||
sourceItem: rasterizationEffectLoader.item
|
||||
hideSource: true
|
||||
smooth: true
|
||||
wrapMode: ShaderEffectSource.Repeat
|
||||
visible: false
|
||||
mipmap: true
|
||||
}
|
||||
}
|
||||
|
||||
rasterizationSource: rasterizationSourceLoader.item
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user