mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-10-31 15:12:28 +00:00 
			
		
		
		
	Smooth static noise and fixes
This commit is contained in:
		| @@ -32,7 +32,6 @@ ShaderEffect { | |||||||
|     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 | ||||||
| @@ -151,7 +150,8 @@ ShaderEffect { | |||||||
|             "float color = texture2D(source, coords).a;" + |             "float color = texture2D(source, coords).a;" + | ||||||
|  |  | ||||||
|             (noise_strength !== 0 ? " |             (noise_strength !== 0 ? " | ||||||
|                 color += texture2D(noiseSource, qt_TexCoord0 * 0.25 + fract(time / 100.0)).a * noise * (1.0 - distance * distance * 2.0);" : "") + |                 float noiseVal = texture2D(noiseSource, qt_TexCoord0 + vec2(fract(time / 51.0), fract(time / 237.0))).a; | ||||||
|  |                 color += noiseVal * noise * (1.0 - distance * 1.3);" : "") + | ||||||
|  |  | ||||||
|             (glowing_line_strength !== 0 ? " |             (glowing_line_strength !== 0 ? " | ||||||
|                 color += randomPass(coords) * glowing_line_strength;" : "") + |                 color += randomPass(coords) * glowing_line_strength;" : "") + | ||||||
| @@ -161,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) / "+rasterization_strength+";" + |             "finalColor *= texture2D(rasterizationSource, coords).a;" + | ||||||
|  |  | ||||||
|             (brightness_flickering !== 0 ? " |             (brightness_flickering !== 0 ? " | ||||||
|                 finalColor *= brightness;" : "") + |                 finalColor *= brightness;" : "") + | ||||||
|   | |||||||
| @@ -250,16 +250,16 @@ Item{ | |||||||
|         (mScanlines == shadersettings.pixel_rasterization ? " |         (mScanlines == shadersettings.pixel_rasterization ? " | ||||||
|                         coords.x = floor(virtual_resolution.x * coords.x) / virtual_resolution.x;" : "") |                         coords.x = floor(virtual_resolution.x * coords.x) / virtual_resolution.x;" : "") | ||||||
|         : "") + |         : "") + | ||||||
|  |         "coords = coords + delta;" + | ||||||
|         "float color = texture2D(source, coords + delta).r * 256.0;" + |         "float color = texture2D(source, coords).r * 256.0;" + | ||||||
|         (mBlur !== 0 ? |         (mBlur !== 0 ? | ||||||
|         "float blurredSourceColor = texture2D(blurredSource, qt_TexCoord0).a * 256.0;" + |         "float blurredSourceColor = texture2D(blurredSource, coords).a * 256.0;" + | ||||||
|         "blurredSourceColor = blurredSourceColor - blurredSourceColor * " + (1.0 - motionBlurCoefficient) * fpsAttenuation+ ";" + |         "blurredSourceColor = blurredSourceColor - blurredSourceColor * " + (1.0 - motionBlurCoefficient) * fpsAttenuation+ ";" + | ||||||
|         "color = step(1.0, color) * color + step(color, 1.0) * blurredSourceColor;" |         "color = step(1.0, color) * color + step(color, 1.0) * blurredSourceColor;" | ||||||
|         : "") + |         : "") + | ||||||
|  |  | ||||||
|  |  | ||||||
|         "gl_FragColor.a = vec4(floor(color) / 256.0);" + |         "gl_FragColor.a = floor(color) / 256.0;" + | ||||||
|         "}" |         "}" | ||||||
|     } |     } | ||||||
|     ////////////////////////////////////////////////////////////////////// |     ////////////////////////////////////////////////////////////////////// | ||||||
| @@ -301,7 +301,7 @@ Item{ | |||||||
|              varying highp vec2 qt_TexCoord0; |              varying highp vec2 qt_TexCoord0; | ||||||
|              uniform highp vec2 virtual_resolution;" + |              uniform highp vec2 virtual_resolution;" + | ||||||
|  |  | ||||||
|             "highp float rand(vec2 co) |             "highp float noise(vec2 co) | ||||||
|             { |             { | ||||||
|                 highp float a = 12.9898; |                 highp float a = 12.9898; | ||||||
|                 highp float b = 78.233; |                 highp float b = 78.233; | ||||||
| @@ -311,13 +311,20 @@ Item{ | |||||||
|                 return fract(sin(sn) * c); |                 return fract(sin(sn) * c); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             float stepNoise(vec2 p){ |             vec2 sw(vec2 p) {return vec2( floor(p.x) , floor(p.y) );} | ||||||
|                 vec2 newP = p * virtual_resolution; |             vec2 se(vec2 p) {return vec2( ceil(p.x)  , floor(p.y) );} | ||||||
|                 return rand(newP); |             vec2 nw(vec2 p) {return vec2( floor(p.x) , ceil(p.y)  );} | ||||||
|  |             vec2 ne(vec2 p) {return vec2( ceil(p.x)  , ceil(p.y)  );} | ||||||
|  |  | ||||||
|  |             float smoothNoise(vec2 p) { | ||||||
|  |                 vec2 inter = smoothstep(0., 1., fract(p)); | ||||||
|  |                 float s = mix(noise(sw(p)), noise(se(p)), inter.x); | ||||||
|  |                 float n = mix(noise(nw(p)), noise(ne(p)), inter.x); | ||||||
|  |                 return mix(s, n, inter.y); | ||||||
|             }" + |             }" + | ||||||
|  |  | ||||||
|         "void main() {" + |         "void main() {" + | ||||||
|             "gl_FragColor.a = stepNoise(qt_TexCoord0);" + |             "gl_FragColor.a = smoothNoise(qt_TexCoord0 * virtual_resolution);" + | ||||||
|         "}" |         "}" | ||||||
|     } |     } | ||||||
|     ShaderEffectSource{ |     ShaderEffectSource{ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user