Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/shaders/gpu_shader_text_frag.glsl
| flat in vec4 color_flat; | flat in vec4 color_flat; | ||||
| flat in vec4 texCoord_rect; | |||||
| noperspective in vec2 texCoord_interp; | noperspective in vec2 texCoord_interp; | ||||
| out vec4 fragColor; | out vec4 fragColor; | ||||
| uniform sampler2D glyph; | uniform sampler2D glyph; | ||||
| const vec2 offsets4[4] = vec2[4]( | 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)); | vec2(-0.5, 0.5), vec2(0.5, 0.5), vec2(-0.5, -0.5), vec2(-0.5, -0.5)); | ||||
| Show All 17 Lines | |||||
| #define sample_glyph_offset(texco, texel, ofs) texture(glyph, texco + ofs * texel).r | #define sample_glyph_offset(texco, texel, ofs) texture(glyph, texco + ofs * texel).r | ||||
| void main() | void main() | ||||
| { | { | ||||
| // input color replaces texture color | // input color replaces texture color | ||||
| fragColor.rgb = color_flat.rgb; | fragColor.rgb = color_flat.rgb; | ||||
| vec2 texel = 1.0 / vec2(textureSize(glyph, 0)); | vec2 texel = 1.0 / vec2(textureSize(glyph, 0)); | ||||
| vec2 texco = mix(abs(texCoord_rect.xy), abs(texCoord_rect.zw), texCoord_interp); | vec2 texco = abs(texCoord_interp); | ||||
| // modulate input alpha & texture alpha | // modulate input alpha & texture alpha | ||||
| if (texCoord_rect.x > 0) { | if (texCoord_interp.x > 0) { | ||||
| fragColor.a = texture(glyph, texco).r; | fragColor.a = texture(glyph, texco).r; | ||||
| } | } | ||||
| else { | else { | ||||
| fragColor.a = 0.0; | fragColor.a = 0.0; | ||||
| if (texCoord_rect.w > 0) { | if (texCoord_interp.y > 0) { | ||||
| /* 3x3 blur */ | /* 3x3 blur */ | ||||
| /* Manual unroll for perf. (stupid glsl compiler) */ | /* Manual unroll for perf. (stupid glsl compiler) */ | ||||
| fragColor.a += sample_glyph_offset(texco, texel, offsets4[0]); | 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[1]); | ||||
| fragColor.a += sample_glyph_offset(texco, texel, offsets4[2]); | fragColor.a += sample_glyph_offset(texco, texel, offsets4[2]); | ||||
| fragColor.a += sample_glyph_offset(texco, texel, offsets4[3]); | fragColor.a += sample_glyph_offset(texco, texel, offsets4[3]); | ||||
| fragColor.a *= (1.0 / 4.0); | fragColor.a *= (1.0 / 4.0); | ||||
| } | } | ||||
| Show All 28 Lines | |||||