fix sprites on mac

This commit is contained in:
Tuomas Katajisto 2026-01-27 16:53:55 +02:00
parent 19ec772a02
commit ac5c52ea9f
3 changed files with 29 additions and 20 deletions

View File

@ -379,12 +379,14 @@ vs_billboard_source_metal_macos := u8.[
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> sprite [[texture(0)]], sampler spritesmp [[sampler(0)]]) fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> sprite [[texture(0)]], sampler spritesmp [[sampler(0)]])
{ {
main0_out out = {}; main0_out out = {};
float4 _27 = sprite.sample(spritesmp, in.uv_in); float2 _12 = in.uv_in;
if (_27.w < 0.00999999977648258209228515625) _12.y = 1.0 - _12.y;
float4 _35 = sprite.sample(spritesmp, _12);
if (_35.w < 0.00999999977648258209228515625)
{ {
discard_fragment(); discard_fragment();
} }
out.color = float4(_27.xyz * 0.5, 1.0); out.color = float4(_35.xyz * 0.5, 1.0);
return out; return out;
} }
@ -411,19 +413,22 @@ fs_billboard_source_metal_macos := u8.[
0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d, 0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,
0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f, 0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,
0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20, 0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x37,0x20,0x3d,0x20,0x73,0x70, 0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x31,0x32,0x20,0x3d,0x20,0x69,0x6e,
0x72,0x69,0x74,0x65,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x73,0x70,0x72,0x69, 0x2e,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x31,0x32,0x2e,
0x74,0x65,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x75,0x76,0x5f,0x69,0x6e,0x29, 0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,0x31,0x32,0x2e,0x79,0x3b,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x32,0x37,0x2e,0x77,0x20, 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x33,0x35,0x20,
0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36, 0x3d,0x20,0x73,0x70,0x72,0x69,0x74,0x65,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,
0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32, 0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x3b,
0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x33,0x35,0x2e,0x77,0x20,0x3c,
0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x5f,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e, 0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,
0x74,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x6f, 0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,
0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74, 0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x34,0x28,0x5f,0x32,0x37,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x35,0x2c, 0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x5f,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72, 0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,
0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, 0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x28,0x5f,0x33,0x35,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x35,0x2c,0x20,
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,
0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
]; ];
billboard_shader_desc :: (backend: sg_backend) -> sg_shader_desc { billboard_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc: sg_shader_desc; desc: sg_shader_desc;

View File

@ -35,9 +35,7 @@ layout(binding = 0) uniform sampler spritesmp;
void main() { void main() {
vec2 uv = uv_in; vec2 uv = uv_in;
#if SOKOL_GLSL
uv.y = 1.0 - uv.y; uv.y = 1.0 - uv.y;
#endif
vec4 sampled = texture(sampler2D(sprite, spritesmp), uv); vec4 sampled = texture(sampler2D(sprite, spritesmp), uv);
if(sampled.a < 0.01) discard; if(sampled.a < 0.01) discard;
color = vec4(sampled.rgb * 0.5, 1.0); color = vec4(sampled.rgb * 0.5, 1.0);

View File

@ -399,7 +399,13 @@ draw_ui_rect_animation:: (r: GR.Rect, animationPlayer: *Animation_Player) {
cast(float) frame.w / cast(float)animation.sheet_w, cast(float) frame.w / cast(float)animation.sheet_w,
cast(float) frame.h / cast(float)animation.sheet_h, cast(float) frame.h / cast(float)animation.sheet_h,
}; };
immediate_quad(.{r.x, r.y}, .{r.x + r.w, r.y}, .{r.x + r.w, r.y + r.h}, .{r.x, r.y + r.h}, .{0.9,0.9,0.9,1}, .{uv.x, uv.y}, .{uv.x + uv.z, uv.y}, .{uv.x + uv.z, uv.y + uv.w}, .{uv.x, uv.y + uv.w});
uv0 := flip_y_if_plat(Vector2.{uv.x, uv.y});
uv1 := flip_y_if_plat(Vector2.{uv.x + uv.z, uv.y});
uv2 := flip_y_if_plat(Vector2.{uv.x + uv.z, uv.y + uv.w});
uv3 := flip_y_if_plat(Vector2.{uv.x, uv.y + uv.w});
immediate_quad(.{r.x, r.y}, .{r.x + r.w, r.y}, .{r.x + r.w, r.y + r.h}, .{r.x, r.y + r.h}, .{0.9,0.9,0.9,1}, uv0, uv1, uv2, uv3);
immediate_flush(); immediate_flush();
set_shader_for_color(); set_shader_for_color();
} }