From 5a14f0da22d2baf1744277c2c3950e57b76aed96 Mon Sep 17 00:00:00 2001 From: shylie Date: Thu, 24 Jul 2025 03:02:29 -0400 Subject: [PATCH] Increase range of values allowed for offset --- zprite.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zprite.lua b/zprite.lua index 330fdb9..a150376 100644 --- a/zprite.lua +++ b/zprite.lua @@ -41,9 +41,9 @@ vec4 position(mat4 transform_projection, vec4 vertex_position) vec4 color = vec4(r, g, b, a) / vec4(256, 256, 256, 256); uint layer = bitfieldExtract(InstanceData.w, 0, 8); - uint offset_x = bitfieldExtract(InstanceData.w, 8, 4); - uint offset_y = bitfieldExtract(InstanceData.w, 12, 4); - vec2 offset = vec2(offset_x, offset_y) - vec2(8, 8); + uint offset_x = bitfieldExtract(InstanceData.w, 8, 8); + uint offset_y = bitfieldExtract(InstanceData.w, 16, 8); + vec2 offset = (vec2(offset_x, offset_y) / vec2(128, 128)) - vec2(1, 1); vec2 pixel_offset = offset * vec2(layer * HeightScale, layer * HeightScale) / love_ScreenSize.xy; @@ -180,8 +180,8 @@ function zprite:put(x, y, quad, layer_count, color_map, offset_map) local uv_scale = bit.bor(uv, scale) local offset_x, offset_y = offset_map(i) - local offset_x_b = bit.lshift(bit.band(offset_x - 8, 0xF), 8) - local offset_y_b = bit.lshift(bit.band(offset_y - 8, 0xF), 12) + local offset_x_b = bit.lshift(bit.band((offset_x + 1) / 2 * 0xFF, 0xFF), 8) + local offset_y_b = bit.lshift(bit.band((offset_y + 1) / 2 * 0xFF, 0xFF), 16) local layer = bit.band(i, 0xFF)