mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-10-31 15:12:28 +00:00 
			
		
		
		
	Added simple screen reflection for ambient light
This commit is contained in:
		| @@ -1,5 +1,6 @@ | |||||||
| import QtQuick 2.1 | import QtQuick 2.1 | ||||||
| import "utils" | import "utils" | ||||||
|  | import QtGraphicalEffects 1.0 | ||||||
|  |  | ||||||
| TerminalFrame{ | TerminalFrame{ | ||||||
|     id: frame |     id: frame | ||||||
| @@ -13,7 +14,7 @@ TerminalFrame{ | |||||||
|     borderBottom: 232 |     borderBottom: 232 | ||||||
|     imageSource: "../images/black-frame.png" |     imageSource: "../images/black-frame.png" | ||||||
|     normalsSource: "../images/black-frame-normals.png" |     normalsSource: "../images/black-frame-normals.png" | ||||||
|     sourceRect: Qt.rect(-80, -90, terminal.width + 160, terminal.height + 180 ) |     sourceRect: Qt.rect(-80, -90, terminal.width + 160, terminal.height + 180) | ||||||
|  |  | ||||||
|     shaderString: "WhiteFrameShader.qml" |     shaderString: "WhiteFrameShader.qml" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -32,7 +32,7 @@ ShaderEffect{ | |||||||
|                                 vec4 txt_color = texture2D(source, coords); |                                 vec4 txt_color = texture2D(source, coords); | ||||||
|                                 vec4 normala = texture2D(normals, coords); |                                 vec4 normala = texture2D(normals, coords); | ||||||
|                                 vec3 normal = normalize(normala.rgb) * txt_color.a; |                                 vec3 normal = normalize(normala.rgb) * txt_color.a; | ||||||
|                                 float reflection = dot(normal, vec3(1.0, 1.0, 0.0)) * 0.3 * brightness; |                                 float reflection = dot(normal, vec3(1.0, 1.0, 0.0)) * 0.4 * brightness; | ||||||
|                                 vec3 reflection_color = mix(font_color, background_color, 0.7).rgb * reflection; |                                 vec3 reflection_color = mix(font_color, background_color, 0.7).rgb * reflection; | ||||||
|                                 vec3 final_color = mix(txt_color.rgb, reflection_color, 1.0 - ambient_light); |                                 vec3 final_color = mix(txt_color.rgb, reflection_color, 1.0 - ambient_light); | ||||||
|                                 gl_FragColor = vec4(final_color, txt_color.a); |                                 gl_FragColor = vec4(final_color, txt_color.a); | ||||||
|   | |||||||
| @@ -77,7 +77,7 @@ ApplicationWindow{ | |||||||
|             id: shadercontainer |             id: shadercontainer | ||||||
|             anchors.fill: terminal |             anchors.fill: terminal | ||||||
|             blending: true |             blending: true | ||||||
|             z: 2 |             z: 1.9 | ||||||
|             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 | ||||||
|             property variant source: theSource |             property variant source: theSource | ||||||
| @@ -239,13 +239,14 @@ ApplicationWindow{ | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         RadialGradient{ |         RadialGradient{ | ||||||
|             z: 4 |             id: ambientreflection | ||||||
|  |             z: 2.0 | ||||||
|             anchors.fill: parent |             anchors.fill: parent | ||||||
|             cached: true |             cached: true | ||||||
|             opacity: 0.1 |             opacity: shadersettings.ambient_light * 0.66 | ||||||
|             gradient: Gradient{ |             gradient: Gradient{ | ||||||
|                 GradientStop{position: 0.0; color: shadersettings.font_color} |                 GradientStop{position: 0.0; color: "white"} | ||||||
|                 GradientStop{position: 1.0; color: "#00000000"} |                 GradientStop{position: 0.7; color: "#00000000"} | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user