mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-10-31 07:04:20 +00:00 
			
		
		
		
	Added brightness slider.
This commit is contained in:
		| @@ -127,6 +127,11 @@ ApplicationWindow { | |||||||
|                             onValueChanged: shadersettings.contrast = value |                             onValueChanged: shadersettings.contrast = value | ||||||
|                             _value: shadersettings.contrast |                             _value: shadersettings.contrast | ||||||
|                         } |                         } | ||||||
|  |                         SettingComponent{ | ||||||
|  |                             name: "Brightness" | ||||||
|  |                             onValueChanged: shadersettings.brightness = value | ||||||
|  |                             _value: shadersettings.brightness | ||||||
|  |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -37,6 +37,8 @@ ShaderEffect { | |||||||
|     property real brightness_flickering: shadersettings.brightness_flickering |     property real brightness_flickering: shadersettings.brightness_flickering | ||||||
|     property real horizontal_sincronization: shadersettings.horizontal_sincronization |     property real horizontal_sincronization: shadersettings.horizontal_sincronization | ||||||
|  |  | ||||||
|  |     property real brightness: shadersettings.brightness * 1.5 + 0.5 | ||||||
|  |  | ||||||
|     property real deltay: 3 / terminal.height |     property real deltay: 3 / terminal.height | ||||||
|     property real deltax: 3 / terminal.width |     property real deltax: 3 / terminal.width | ||||||
|  |  | ||||||
| @@ -173,6 +175,6 @@ ShaderEffect { | |||||||
|             finalColor = mix(finalColor, vec3(0.0), brightness);" : "") + |             finalColor = mix(finalColor, vec3(0.0), brightness);" : "") + | ||||||
|  |  | ||||||
|         " |         " | ||||||
|         gl_FragColor = vec4(finalColor, 1.0); |         gl_FragColor = vec4(finalColor *"+brightness+", 1.0); | ||||||
|     }" |     }" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -26,6 +26,8 @@ Item{ | |||||||
|     property real ambient_light: 0.2 |     property real ambient_light: 0.2 | ||||||
|     property real contrast: 0.8 |     property real contrast: 0.8 | ||||||
|  |  | ||||||
|  |     property real brightness: 0.5 | ||||||
|  |  | ||||||
|     function mix(c1, c2, alpha){ |     function mix(c1, c2, alpha){ | ||||||
|         return Qt.rgba(c1.r * alpha + c2.r * (1-alpha), |         return Qt.rgba(c1.r * alpha + c2.r * (1-alpha), | ||||||
|                        c1.g * alpha + c2.g * (1-alpha), |                        c1.g * alpha + c2.g * (1-alpha), | ||||||
|   | |||||||
| @@ -10,6 +10,7 @@ ShaderEffect{ | |||||||
|     property real time: timetimer.time |     property real time: timetimer.time | ||||||
|     property variant randomFunctionSource: randfuncsource |     property variant randomFunctionSource: randfuncsource | ||||||
|     property real brightness_flickering: shadersettings.brightness_flickering |     property real brightness_flickering: shadersettings.brightness_flickering | ||||||
|  |     property real brightness: shadersettings.brightness * 1.5 + 0.5 | ||||||
|  |  | ||||||
|     property color reflection_color: Qt.rgba((font_color.r*0.3 + background_color.r*0.7), |     property color reflection_color: Qt.rgba((font_color.r*0.3 + background_color.r*0.7), | ||||||
|                                              (font_color.g*0.3 + background_color.g*0.7), |                                              (font_color.g*0.3 + background_color.g*0.7), | ||||||
| @@ -28,12 +29,11 @@ ShaderEffect{ | |||||||
|                     varying lowp float brightness; |                     varying lowp float brightness; | ||||||
|  |  | ||||||
|                     void main() { |                     void main() { | ||||||
|                         qt_TexCoord0 = qt_MultiTexCoord0;" + |                         qt_TexCoord0 = qt_MultiTexCoord0; | ||||||
|  |                         brightness = "+brightness+";" + | ||||||
|                         (brightness_flickering !== 0 ? |                         (brightness_flickering !== 0 ? | ||||||
|                             "brightness = texture2D(randomFunctionSource, vec2(fract(time/(1024.0*2.0)), fract(time/(1024.0*1024.0*2.0)))).r * "+brightness_flickering+";" |                             "brightness -= texture2D(randomFunctionSource, vec2(fract(time/(1024.0*2.0)), fract(time/(1024.0*1024.0*2.0)))).r * "+brightness_flickering+";" | ||||||
|                         : |                         : "") + " | ||||||
|                             "brightness = 0.0;") + " |  | ||||||
|  |  | ||||||
|                         gl_Position = qt_Matrix * qt_Vertex; |                         gl_Position = qt_Matrix * qt_Vertex; | ||||||
|                     }" |                     }" | ||||||
| @@ -61,7 +61,7 @@ ShaderEffect{ | |||||||
|                                 vec4 txt_normal = texture2D(normals, coords); |                                 vec4 txt_normal = texture2D(normals, coords); | ||||||
|                                 vec3 normal = normalize(txt_normal.rgb * 2.0 - 1.0); |                                 vec3 normal = normalize(txt_normal.rgb * 2.0 - 1.0); | ||||||
|                                 vec3 light_dir = normalize(vec3(0.5,0.5, 0.0) - vec3(qt_TexCoord0, 0.0)); |                                 vec3 light_dir = normalize(vec3(0.5,0.5, 0.0) - vec3(qt_TexCoord0, 0.0)); | ||||||
|                                 float reflection = (dot(normal, light_dir) * 0.4 + 0.2) * (1.0-brightness); |                                 float reflection = (dot(normal, light_dir) * 0.4 + 0.2) * brightness; | ||||||
|                                 vec3 final_color = reflection_color * reflection * 0.5; |                                 vec3 final_color = reflection_color * reflection * 0.5; | ||||||
|                                 final_color += txt_color * ambient_light; |                                 final_color += txt_color * ambient_light; | ||||||
|                                 gl_FragColor = vec4(final_color * txt_normal.a, txt_color.a); |                                 gl_FragColor = vec4(final_color * txt_normal.a, txt_color.a); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user