mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
fix(Metal): use sRGB texture format for gamma correct interpolation
otherwise images will be too dark when scaled
This commit is contained in:
@@ -96,6 +96,7 @@ pub const MTLVertexStepFunction = enum(c_ulong) {
|
||||
pub const MTLPixelFormat = enum(c_ulong) {
|
||||
r8unorm = 10,
|
||||
rgba8unorm = 70,
|
||||
rgba8unorm_srgb = 71,
|
||||
rgba8uint = 73,
|
||||
bgra8unorm = 80,
|
||||
bgra8unorm_srgb = 81,
|
||||
|
@@ -441,7 +441,7 @@ pub const Image = union(enum) {
|
||||
};
|
||||
|
||||
// Set our properties
|
||||
desc.setProperty("pixelFormat", @intFromEnum(mtl.MTLPixelFormat.rgba8unorm));
|
||||
desc.setProperty("pixelFormat", @intFromEnum(mtl.MTLPixelFormat.rgba8unorm_srgb));
|
||||
desc.setProperty("width", @as(c_ulong, @intCast(p.width)));
|
||||
desc.setProperty("height", @as(c_ulong, @intCast(p.height)));
|
||||
|
||||
|
@@ -668,12 +668,12 @@ fragment float4 image_fragment(
|
||||
|
||||
float4 rgba = image.sample(textureSampler, in.tex_coord);
|
||||
|
||||
return load_color(
|
||||
uchar4(rgba * 255.0),
|
||||
// We assume all images are sRGB regardless of the configured colorspace
|
||||
// TODO: Maybe support wide gamut images?
|
||||
false,
|
||||
uniforms.use_linear_blending
|
||||
);
|
||||
if (!uniforms.use_linear_blending) {
|
||||
rgba = unlinearize(rgba);
|
||||
}
|
||||
|
||||
rgba.rgb *= rgba.a;
|
||||
|
||||
return rgba;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user