mirror of
https://github.com/Ed94/VEFontCache-Odin.git
synced 2025-08-04 22:22:43 -07:00
59 lines
1.9 KiB
GLSL
59 lines
1.9 KiB
GLSL
// module naming rules are currently dumb with shdc rn...
|
|
// @module ve_blit_atlas
|
|
|
|
@header package ve_sokol
|
|
@header import sg "thirdparty:sokol/gfx"
|
|
|
|
@vs blit_atlas_vs
|
|
@include ./source_shared.shdc.glsl
|
|
@end
|
|
|
|
@fs blit_atlas_fs
|
|
in vec2 uv;
|
|
out vec4 frag_color;
|
|
|
|
layout(binding = 0) uniform texture2D blit_atlas_src_texture;
|
|
layout(binding = 0) uniform sampler blit_atlas_src_sampler;
|
|
|
|
layout(binding = 0) uniform blit_atlas_fs_params {
|
|
vec2 glyph_buffer_size;
|
|
float over_sample;
|
|
int region;
|
|
};
|
|
|
|
float down_sample_to_texture( vec2 uv, vec2 texture_size )
|
|
{
|
|
float down_sample = 1.0f / over_sample;
|
|
|
|
float value =
|
|
texture(sampler2D( blit_atlas_src_texture, blit_atlas_src_sampler ), uv + vec2( 0.0f, 0.0f ) * texture_size ).x * down_sample
|
|
+ texture(sampler2D( blit_atlas_src_texture, blit_atlas_src_sampler ), uv + vec2( 0.0f, 1.0f ) * texture_size ).x * down_sample
|
|
+ texture(sampler2D( blit_atlas_src_texture, blit_atlas_src_sampler ), uv + vec2( 1.0f, 0.0f ) * texture_size ).x * down_sample
|
|
+ texture(sampler2D( blit_atlas_src_texture, blit_atlas_src_sampler ), uv + vec2( 1.0f, 1.0f ) * texture_size ).x * down_sample;
|
|
|
|
return value;
|
|
}
|
|
|
|
void main()
|
|
{
|
|
const vec2 texture_size = 1.0f / glyph_buffer_size;
|
|
if ( region == 0 || region == 1 || region == 2 || region == 4 )
|
|
{
|
|
float down_sample = 1.0f / over_sample;
|
|
|
|
float alpha =
|
|
down_sample_to_texture( uv + vec2( -1.0f, -1.5f ) * texture_size, texture_size ) * down_sample
|
|
+ down_sample_to_texture( uv + vec2( 0.5f, -1.5f ) * texture_size, texture_size ) * down_sample
|
|
+ down_sample_to_texture( uv + vec2( -1.5f, 0.5f ) * texture_size, texture_size ) * down_sample
|
|
+ down_sample_to_texture( uv + vec2( 0.5f, 0.5f ) * texture_size, texture_size ) * down_sample;
|
|
frag_color = vec4( 1.0f, 1.0f, 1.0f, alpha );
|
|
}
|
|
else
|
|
{
|
|
frag_color = vec4( 0.0f, 0.0f, 0.0f, 1.0 );
|
|
}
|
|
}
|
|
@end
|
|
|
|
@program blit_atlas blit_atlas_vs blit_atlas_fs
|