Working mipmaps

This commit is contained in:
sergeypdev 2024-02-15 16:38:16 +04:00
parent d3f0664da6
commit 406c40280c
2 changed files with 3 additions and 2 deletions

View File

@ -367,7 +367,7 @@ fn loadTextureErr(self: *AssetManager, id: AssetId) !*const LoadedTexture {
); );
for (0..mip_level_count) |mip_level| { for (0..mip_level_count) |mip_level| {
const desc = transcoder.getImageLevelDescriptor(0, 0) catch unreachable; const desc = transcoder.getImageLevelDescriptor(0, @intCast(mip_level)) catch unreachable;
const out_buf = try self.frame_arena.alloc( const out_buf = try self.frame_arena.alloc(
u8, u8,
@intCast(try transcoder.calcTranscodedSize(0, @intCast(mip_level), format)), @intCast(try transcoder.calcTranscodedSize(0, @intCast(mip_level), format)),

View File

@ -181,6 +181,7 @@ fn processTexture(allocator: std.mem.Allocator, input: [*:0]const u8, output: []
var y: c_int = undefined; var y: c_int = undefined;
var comps: c_int = undefined; var comps: c_int = undefined;
c.stbi_set_flip_vertically_on_load(1);
const FORCED_COMPONENTS = 3; // force rgb const FORCED_COMPONENTS = 3; // force rgb
const data_c = @as(?[*]u8, @ptrCast(c.stbi_load(input, &x, &y, &comps, FORCED_COMPONENTS))) orelse return error.ImageLoadError; const data_c = @as(?[*]u8, @ptrCast(c.stbi_load(input, &x, &y, &comps, FORCED_COMPONENTS))) orelse return error.ImageLoadError;
defer c.stbi_image_free(data_c); defer c.stbi_image_free(data_c);
@ -197,7 +198,7 @@ fn processTexture(allocator: std.mem.Allocator, input: [*:0]const u8, output: []
// TODO: configure per-texture somehow // TODO: configure per-texture somehow
params.setQualityLevel(64); params.setQualityLevel(64);
params.setBasisFormat(basisu.BasisTextureFormat.etc1s); params.setBasisFormat(basisu.BasisTextureFormat.uastc4x4);
params.setColorSpace(basisu.ColorSpace.srgb); params.setColorSpace(basisu.ColorSpace.srgb);
params.setGenerateMipMaps(true); params.setGenerateMipMaps(true);