mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-10-31 07:04:20 +00:00 
			
		
		
		
	Add subpixel rasterization.
This commit is contained in:
		| @@ -104,7 +104,7 @@ QtObject { | ||||
|     readonly property int no_rasterization: 0 | ||||
|     readonly property int scanline_rasterization: 1 | ||||
|     readonly property int pixel_rasterization: 2 | ||||
|     readonly property int lcd_rasterization: 3 | ||||
|     readonly property int subpixel_rasterization: 3 | ||||
|  | ||||
|     property int rasterization: no_rasterization | ||||
|  | ||||
| @@ -148,7 +148,7 @@ QtObject { | ||||
|                 } | ||||
|             }, | ||||
|             State { | ||||
|                 when: rasterization == lcd_rasterization | ||||
|                 when: rasterization == subpixel_rasterization | ||||
|                 PropertyChanges { | ||||
|                     target: fontManager | ||||
|                     source: "FontPixels.qml" | ||||
|   | ||||
| @@ -41,7 +41,7 @@ ColumnLayout { | ||||
|                 property string selectedElement: model[currentIndex] | ||||
|  | ||||
|                 Layout.fillWidth: true | ||||
|                 model: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels"), qsTr("LCD")] | ||||
|                 model: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels"), qsTr("Sub-Pixels")] | ||||
|                 currentIndex: appSettings.rasterization | ||||
|                 onCurrentIndexChanged: { | ||||
|                     appSettings.rasterization = currentIndex | ||||
|   | ||||
| @@ -12,8 +12,6 @@ QtObject { | ||||
|             #define BRIGHTBOOST 0.30 | ||||
|  | ||||
|             lowp vec3 applyRasterization(vec2 screenCoords, lowp vec3 texel, vec2 virtualResolution, float intensity) { | ||||
|                 lowp vec3 result = texel; | ||||
|  | ||||
|                 lowp vec3 pixelHigh = ((1.0 + BRIGHTBOOST) - (0.2 * texel)) * texel; | ||||
|                 lowp vec3 pixelLow  = ((1.0 - INTENSITY) + (0.1 * texel)) * texel; | ||||
|  | ||||
| @@ -42,20 +40,25 @@ QtObject { | ||||
|                 return mix(texel, rasterizationColor, intensity); | ||||
|             }" : "") + | ||||
|  | ||||
|         (appSettings.rasterization === appSettings.lcd_rasterization ? " | ||||
|             #define brighten_scanlines 16.0 | ||||
|             #define brighten_lcd 4.0 | ||||
|         (appSettings.rasterization === appSettings.subpixel_rasterization ? " | ||||
|             #define INTENSITY 0.30 | ||||
|             #define BRIGHTBOOST 0.30 | ||||
|             #define SUBPIXELS 3.0 | ||||
|             const vec3 offsets = vec3(3.141592654) * vec3(1.0/2.0,1.0/2.0 - 2.0/3.0,1.0/2.0-4.0/3.0); | ||||
|  | ||||
|             lowp vec3 applyRasterization(vec2 screenCoords, lowp vec3 texel, vec2 virtualResolution, float intensity) { | ||||
|                 vec2 omega = vec2(3.141592654) * vec2(2.0) * virtualResolution; | ||||
|  | ||||
|                 vec2 angle = screenCoords * omega; | ||||
|                 vec3 xfactors = (SUBPIXELS + sin(angle.x + offsets)) / (SUBPIXELS + 1.0); | ||||
|  | ||||
|                 float yfactor = (brighten_scanlines + sin(angle.y)) / (brighten_scanlines + 1.0); | ||||
|                 vec3 xfactors = (brighten_lcd + sin(angle.x + offsets)) / (brighten_lcd + 1.0); | ||||
|                 lowp vec3 result = texel * xfactors; | ||||
|                 lowp vec3 pixelHigh = ((1.0 + BRIGHTBOOST) - (0.2 * result)) * result; | ||||
|                 lowp vec3 pixelLow  = ((1.0 - INTENSITY) + (0.1 * result)) * result; | ||||
|  | ||||
|                 lowp vec3 rasterizationColor = yfactor * xfactors * texel; | ||||
|                 vec2 coords = fract(screenCoords * virtualResolution) * 2.0 - vec2(1.0); | ||||
|                 lowp float mask = 1.0 - abs(coords.y); | ||||
|  | ||||
|                 lowp vec3 rasterizationColor = mix(pixelLow, pixelHigh, mask); | ||||
|                 return mix(texel, rasterizationColor, intensity); | ||||
|             }" : "") + | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user