| 
									
										
										
										
											2016-09-17 13:33:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-17 10:46:42 +10:00
										 |  |  | flat in vec4 color_flat; | 
					
						
							| 
									
										
										
										
											2018-04-08 00:44:35 +02:00
										 |  |  | flat in vec4 texCoord_rect; | 
					
						
							| 
									
										
										
										
											2017-05-17 10:46:42 +10:00
										 |  |  | noperspective in vec2 texCoord_interp; | 
					
						
							|  |  |  | out vec4 fragColor; | 
					
						
							| 
									
										
										
										
											2016-09-17 13:33:02 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | uniform sampler2D glyph; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-08 01:00:55 +02:00
										 |  |  | const vec2 offsets4[4] = vec2[4]( | 
					
						
							|  |  |  | 	vec2(-0.5,  0.5), vec2( 0.5,  0.5), | 
					
						
							|  |  |  | 	vec2(-0.5, -0.5), vec2(-0.5, -0.5) | 
					
						
							| 
									
										
										
										
											2018-04-08 00:44:35 +02:00
										 |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-08 01:00:55 +02:00
										 |  |  | const vec2 offsets16[16] = vec2[16]( | 
					
						
							|  |  |  | 	vec2(-1.5,  1.5), vec2(-0.5,  1.5), vec2( 0.5,  1.5), vec2( 1.5,  1.5), | 
					
						
							|  |  |  | 	vec2(-1.5,  0.5), vec2(-0.5,  0.5), vec2( 0.5,  0.5), vec2( 1.5,  0.5), | 
					
						
							|  |  |  | 	vec2(-1.5, -0.5), vec2(-0.5, -0.5), vec2( 0.5, -0.5), vec2( 1.5, -0.5), | 
					
						
							|  |  |  | 	vec2(-1.5, -1.5), vec2(-0.5, -1.5), vec2( 0.5, -1.5), vec2( 1.5, -1.5) | 
					
						
							| 
									
										
										
										
											2018-04-08 00:44:35 +02:00
										 |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define sample_glyph_offset(texco, texel, ofs) texture(glyph, texco + ofs * texel).r | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-17 13:33:02 +02:00
										 |  |  | void main() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	// input color replaces texture color | 
					
						
							| 
									
										
										
										
											2016-10-11 14:36:16 -04:00
										 |  |  | 	fragColor.rgb = color_flat.rgb; | 
					
						
							| 
									
										
										
										
											2016-09-17 13:33:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-08 00:44:35 +02:00
										 |  |  | 	vec2 texel = 1.0 / vec2(textureSize(glyph, 0)); | 
					
						
							|  |  |  | 	vec2 texco = mix(abs(texCoord_rect.xy), abs(texCoord_rect.zw), texCoord_interp); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-17 13:33:02 +02:00
										 |  |  | 	// modulate input alpha & texture alpha | 
					
						
							| 
									
										
										
										
											2018-04-08 00:44:35 +02:00
										 |  |  | 	if (texCoord_rect.x > 0) { | 
					
						
							|  |  |  | 		fragColor.a = texture(glyph, texco).r; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		fragColor.a = 0.0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (texCoord_rect.w > 0) { | 
					
						
							|  |  |  | 			/* 3x3 blur */ | 
					
						
							|  |  |  | 			/* Manual unroll for perf. (stupid glsl compiler) */ | 
					
						
							| 
									
										
										
										
											2018-04-08 01:00:55 +02:00
										 |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets4[0]); | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets4[1]); | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets4[2]); | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets4[3]); | 
					
						
							|  |  |  | 			fragColor.a *= (1.0 / 4.0); | 
					
						
							| 
									
										
										
										
											2018-04-08 00:44:35 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			/* 5x5 blur */ | 
					
						
							|  |  |  | 			/* Manual unroll for perf. (stupid glsl compiler) */ | 
					
						
							| 
									
										
										
										
											2018-04-08 01:00:55 +02:00
										 |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[ 0]); | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[ 1]); | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[ 2]); | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[ 3]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[ 4]); | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[ 5]) * 2.0; | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[ 6]) * 2.0; | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[ 7]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[ 8]); | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[ 9]) * 2.0; | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[10]) * 2.0; | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[11]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[12]); | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[13]); | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[14]); | 
					
						
							|  |  |  | 			fragColor.a += sample_glyph_offset(texco, texel, offsets16[15]); | 
					
						
							|  |  |  | 			fragColor.a *= (1.0 / 20.0); | 
					
						
							| 
									
										
										
										
											2018-04-08 00:44:35 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	fragColor.a *= color_flat.a; | 
					
						
							| 
									
										
										
										
											2016-09-17 13:33:02 +02:00
										 |  |  | } |