104 int glyph_index = inst_index;
106 v_out.color_flat = srt.glyphs[glyph_index].glyph_color;
107 v_out.glyph_offset = srt.glyphs[glyph_index].offset;
108 v_out.glyph_dim = srt.glyphs[glyph_index].glyph_size;
109 v_out.glyph_flags = srt.glyphs[glyph_index].flags;
112 uint shadow_type = v_out.glyph_flags & 0xFu;
113 int interp_size = shadow_type > 4 ? 2 : (shadow_type > 0 ? 1 : 0);
116 float x =
float(vert_id % 2);
117 float y =
float(vert_id / 2);
122 v_out.uv_interp =
mix(-interp_offset, 1.0f + interp_offset, quad) *
float2(v_out.glyph_dim) +
129 out_pos = srt.ModelViewProjectionMatrix *
float4(final_pos, 0.0f, 1.0f);
141 float2 uv_base = v_out.uv_interp;
142 uint num_channels = (v_out.glyph_flags >> 4) & 0xFu;
143 uint shadow_type = v_out.glyph_flags & 0xFu;
146 if (num_channels == 4) {
147 frag_out.color = srt.sample_glyph_rgba(v_out.glyph_dim, v_out.glyph_offset, uv_base).rgba;
148 frag_out.color.a *= v_out.color_flat.a;
154 frag_out.color.rgb = v_out.color_flat.rgb;
156 if (shadow_type == 0) {
158 frag_out.color.a = srt.sample_glyph_bilinear(
159 v_out.glyph_dim, v_out.glyph_offset, bilin_f, uv_base);
165 frag_out.color.a = 0.0f;
168 int frag_offset = v_out.glyph_offset + texel.
y * v_out.glyph_dim.x + texel.
x;
170 if (shadow_type == 6) {
174 for (
int iy = 0; iy < 4; ++iy) {
176 for (
int ix = 0; ix < 4; ++ix) {
178 float v = srt.texel_fetch(frag_offset + ofsy * v_out.glyph_dim.x + ofsx);
184 float w00 = ix < 3 && iy < 3 ? 1.0f : 0.0f;
185 float w10 = ix > 0 && iy < 3 ? 1.0f : 0.0f;
186 float w01 = ix < 3 && iy > 0 ? 1.0f : 0.0f;
187 float w11 = ix > 0 && iy > 0 ? 1.0f : 0.0f;
188 float w =
mix(
mix(w00, w10, bilin_f.
x),
mix(w01, w11, bilin_f.
x), bilin_f.
y);
190 maxval =
max(maxval, v *
w);
193 frag_out.color.a = maxval;
195 else if (shadow_type <= 4) {
199 const float weights3x3[16] = {
200 1.0f, 2.0f, 1.0f, 0.0f,
201 2.0f, 4.0f, 2.0f, 0.0f,
202 1.0f, 2.0f, 1.0f, 0.0f,
203 0.0f, 0.0f, 0.0f, 0.0f
209 for (
int iy = 0; iy < 4; ++iy) {
211 for (
int ix = 0; ix < 4; ++ix) {
213 float v = srt.texel_fetch(frag_offset + ofsy * v_out.glyph_dim.x + ofsx);
219 float w00 = weights3x3[idx];
220 float w10 = ix > 0 ? weights3x3[idx - 1] : 0.0f;
221 float w01 = iy > 0 ? weights3x3[idx - 4] : 0.0f;
222 float w11 = ix > 0 && iy > 0 ? weights3x3[idx - 5] : 0.0f;
223 float w =
mix(
mix(w00, w10, bilin_f.
x),
mix(w01, w11, bilin_f.
x), bilin_f.
y);
229 frag_out.color.a = sum * (1.0f / 16.0f);
235 const float weights5x5[36] = {
236 1.0f, 2.0f, 2.0f, 2.0f, 1.0f, 0.0f,
237 2.0f, 5.0f, 6.0f, 5.0f, 2.0f, 0.0f,
238 2.0f, 6.0f, 8.0f, 6.0f, 2.0f, 0.0f,
239 2.0f, 5.0f, 6.0f, 5.0f, 2.0f, 0.0f,
240 1.0f, 2.0f, 2.0f, 2.0f, 1.0f, 0.0f,
241 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
247 for (
int iy = 0; iy < 6; ++iy) {
249 for (
int ix = 0; ix < 6; ++ix) {
251 float v = srt.texel_fetch(frag_offset + ofsy * v_out.glyph_dim.x + ofsx);
257 float w00 = weights5x5[idx];
258 float w10 = ix > 0 ? weights5x5[idx - 1] : 0.0f;
259 float w01 = iy > 0 ? weights5x5[idx - 6] : 0.0f;
260 float w11 = ix > 0 && iy > 0 ? weights5x5[idx - 7] : 0.0f;
261 float w =
mix(
mix(w00, w10, bilin_f.
x),
mix(w01, w11, bilin_f.
x), bilin_f.
y);
267 frag_out.color.a = sum * (1.0f / 80.0f);
271 frag_out.color.a *= v_out.color_flat.a;
272 frag_out.color =
colorspace.rec709_srgb_to_output_space(frag_out.color);