Increase range of values allowed for offset

This commit is contained in:
shylie 2025-07-24 03:02:29 -04:00
parent 0ac6791e75
commit 5a14f0da22

View File

@ -41,9 +41,9 @@ vec4 position(mat4 transform_projection, vec4 vertex_position)
vec4 color = vec4(r, g, b, a) / vec4(256, 256, 256, 256); vec4 color = vec4(r, g, b, a) / vec4(256, 256, 256, 256);
uint layer = bitfieldExtract(InstanceData.w, 0, 8); uint layer = bitfieldExtract(InstanceData.w, 0, 8);
uint offset_x = bitfieldExtract(InstanceData.w, 8, 4); uint offset_x = bitfieldExtract(InstanceData.w, 8, 8);
uint offset_y = bitfieldExtract(InstanceData.w, 12, 4); uint offset_y = bitfieldExtract(InstanceData.w, 16, 8);
vec2 offset = vec2(offset_x, offset_y) - vec2(8, 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; 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 uv_scale = bit.bor(uv, scale)
local offset_x, offset_y = offset_map(i) local offset_x, offset_y = offset_map(i)
local offset_x_b = bit.lshift(bit.band(offset_x - 8, 0xF), 8) 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 - 8, 0xF), 12) local offset_y_b = bit.lshift(bit.band((offset_y + 1) / 2 * 0xFF, 0xFF), 16)
local layer = bit.band(i, 0xFF) local layer = bit.band(i, 0xFF)