mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-01-18 20:20:45 +00:00
Improved noise
This commit is contained in:
parent
6c461acf28
commit
2423957cc8
@ -27,10 +27,12 @@ ShaderEffect {
|
|||||||
property variant source: terminal.theSource
|
property variant source: terminal.theSource
|
||||||
property variant bloomSource: terminal.bloomSource
|
property variant bloomSource: terminal.bloomSource
|
||||||
property variant rasterizationSource: terminal.rasterizationSource
|
property variant rasterizationSource: terminal.rasterizationSource
|
||||||
|
property variant noiseSource: terminal.staticNoiseSource
|
||||||
property size txt_Size: Qt.size(frame.sourceRect.width, frame.sourceRect.height)
|
property size txt_Size: Qt.size(frame.sourceRect.width, frame.sourceRect.height)
|
||||||
property real bloom: shadersettings.bloom_strength
|
property real bloom: shadersettings.bloom_strength
|
||||||
|
|
||||||
property int rasterization: shadersettings.rasterization
|
property int rasterization: shadersettings.rasterization
|
||||||
|
property real rasterization_strength: 0.5
|
||||||
|
|
||||||
property real noise_strength: shadersettings.noise_strength
|
property real noise_strength: shadersettings.noise_strength
|
||||||
property real screen_distorsion: shadersettings.screen_distortion
|
property real screen_distorsion: shadersettings.screen_distortion
|
||||||
@ -51,6 +53,8 @@ ShaderEffect {
|
|||||||
property real time: timetimer.time
|
property real time: timetimer.time
|
||||||
property variant randomFunctionSource: randfuncsource
|
property variant randomFunctionSource: randfuncsource
|
||||||
|
|
||||||
|
blending: false
|
||||||
|
|
||||||
function str(num){
|
function str(num){
|
||||||
return num.toFixed(8);
|
return num.toFixed(8);
|
||||||
}
|
}
|
||||||
@ -102,7 +106,8 @@ ShaderEffect {
|
|||||||
(bloom !== 0 ? "
|
(bloom !== 0 ? "
|
||||||
uniform highp sampler2D bloomSource;" : "") +
|
uniform highp sampler2D bloomSource;" : "") +
|
||||||
(noise_strength !== 0 ? "
|
(noise_strength !== 0 ? "
|
||||||
uniform highp float noise_strength;" : "") +
|
uniform highp float noise_strength;
|
||||||
|
uniform lowp sampler2D noiseSource;" : "") +
|
||||||
(screen_distorsion !== 0 ? "
|
(screen_distorsion !== 0 ? "
|
||||||
uniform highp float screen_distorsion;" : "")+
|
uniform highp float screen_distorsion;" : "")+
|
||||||
(glowing_line_strength !== 0 ? "
|
(glowing_line_strength !== 0 ? "
|
||||||
@ -112,22 +117,6 @@ ShaderEffect {
|
|||||||
(horizontal_sincronization !== 0 ? "
|
(horizontal_sincronization !== 0 ? "
|
||||||
varying lowp float horizontal_distortion;" : "") +
|
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 ? "
|
(glowing_line_strength !== 0 ? "
|
||||||
float randomPass(vec2 coords){
|
float randomPass(vec2 coords){
|
||||||
return fract(smoothstep(-0.2, 0.0, coords.y - 3.0 * fract(time * 0.0001))) * glowing_line_strength;
|
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;" +
|
"float color = texture2D(source, coords).a;" +
|
||||||
|
|
||||||
(noise_strength !== 0 ? "
|
(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 ? "
|
(glowing_line_strength !== 0 ? "
|
||||||
color += randomPass(coords) * glowing_line_strength;" : "") +
|
color += randomPass(coords) * glowing_line_strength;" : "") +
|
||||||
@ -172,7 +161,7 @@ ShaderEffect {
|
|||||||
|
|
||||||
"vec3 finalColor = mix(background_color, font_color, color).rgb;" +
|
"vec3 finalColor = mix(background_color, font_color, color).rgb;" +
|
||||||
"finalColor = mix(finalColor * 1.1, vec3(0.0), 1.2 * distance * distance);" +
|
"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 ? "
|
(brightness_flickering !== 0 ? "
|
||||||
finalColor *= brightness;" : "") +
|
finalColor *= brightness;" : "") +
|
||||||
|
@ -29,6 +29,7 @@ Item{
|
|||||||
property variant theSource: finalSource
|
property variant theSource: finalSource
|
||||||
property variant bloomSource: bloomSourceLoader.item
|
property variant bloomSource: bloomSourceLoader.item
|
||||||
property variant rasterizationSource: rasterizationEffectSource
|
property variant rasterizationSource: rasterizationEffectSource
|
||||||
|
property variant staticNoiseSource: staticNoiseSource
|
||||||
|
|
||||||
property alias kterminal: kterminal
|
property alias kterminal: kterminal
|
||||||
|
|
||||||
@ -227,7 +228,7 @@ Item{
|
|||||||
property size virtual_resolution: parent.virtual_resolution
|
property size virtual_resolution: parent.virtual_resolution
|
||||||
property size delta: Qt.size((mScanlines == shadersettings.pixel_rasterization ? deltax : 0),
|
property size delta: Qt.size((mScanlines == shadersettings.pixel_rasterization ? deltax : 0),
|
||||||
mScanlines != shadersettings.no_rasterization ? deltay : 0)
|
mScanlines != shadersettings.no_rasterization ? deltay : 0)
|
||||||
z: 2
|
blending: false
|
||||||
|
|
||||||
fragmentShader:
|
fragmentShader:
|
||||||
"uniform lowp float qt_Opacity;" +
|
"uniform lowp float qt_Opacity;" +
|
||||||
@ -286,12 +287,57 @@ Item{
|
|||||||
smooth: false
|
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
|
//Rasterization mask
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
id: rasterizationEffect
|
id: rasterizationEffect
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
property size virtual_resolution: terminalContainer.virtual_resolution
|
property size virtual_resolution: terminalContainer.virtual_resolution
|
||||||
|
|
||||||
|
blending: false
|
||||||
|
|
||||||
fragmentShader:
|
fragmentShader:
|
||||||
"uniform lowp float qt_Opacity;" +
|
"uniform lowp float qt_Opacity;" +
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 3.0.1, 2014-06-07T14:58:56. -->
|
<!-- Written by QtCreator 3.0.1, 2014-06-11T00:00:49. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user