mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-22 21:17:33 +00:00
Fix chunk/pixel alignment
- Adjust coordinates, so that chunks are always in the center of the window - Modify VIRTUAL_RESOLUTION_OFFSET_X/Y to match window output with expected coordinates - Fix black line at the bottom of window - Remove tile bleed/inset while stitching, as it is not needed anymore
This commit is contained in:
parent
151d1d88bd
commit
478a6262e8
@ -81,10 +81,8 @@ func Stitch(tiles []imageTile, destImage *image.RGBA) error {
|
||||
return fmt.Errorf("Couldn't get image: %w", err)
|
||||
}
|
||||
imgCopy := *img
|
||||
imgCopy.Rect = imgCopy.Rect.Add(tile.offset).Inset(4) // Reduce image bounds by 4 pixels on each side, because otherwise there will be artifacts.
|
||||
imgCopy.Rect = imgCopy.Rect.Add(tile.offset)
|
||||
images = append(images, &imgCopy)
|
||||
// TODO: Fix transparent pixels at the output image border because of inset
|
||||
// TODO: Fix downscaled images to cause artifacts because of the inset
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,7 +223,7 @@ func Compare(tiles []imageTile, bounds image.Rectangle) error {
|
||||
return fmt.Errorf("Couldn't get image: %w", err)
|
||||
}
|
||||
imgCopy := *img
|
||||
imgCopy.Rect = imgCopy.Rect.Add(tile.offset).Inset(4) // Reduce image bounds by 4 pixels on each side, because otherwise there will be artifacts.
|
||||
imgCopy.Rect = imgCopy.Rect.Add(tile.offset)
|
||||
images = append(images, &imgCopy)
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
-- https://opensource.org/licenses/MIT
|
||||
|
||||
CAPTURE_PIXEL_SIZE = 1 -- Screen to virtual pixel ratio
|
||||
CAPTURE_GRID_SIZE = 420 -- in ingame pixels. There will always be 3 to 6 images overlapping
|
||||
CAPTURE_GRID_SIZE = 512 -- in ingame pixels. There will always be exactly 4 images overlapping if the virtual resolution is 1024x1024
|
||||
CAPTURE_FORCE_HP = 4 -- * 25HP
|
||||
|
||||
CAPTURE_LEFT = -25000 -- in ingame pixels. Left edge of the full map capture rectangle
|
||||
@ -38,7 +38,7 @@ local function captureScreenshot(x, y, rx, ry)
|
||||
repeat
|
||||
if UiCaptureDelay > 100 then
|
||||
-- Wiggle the screen a bit, as chunks sometimes don't want to load
|
||||
GameSetCameraPos(x+math.random(-100, 100), y+math.random(-100, 100))
|
||||
GameSetCameraPos(x + math.random(-100, 100), y + math.random(-100, 100))
|
||||
DrawUI()
|
||||
wait(0)
|
||||
UiCaptureDelay = UiCaptureDelay + 1
|
||||
@ -48,7 +48,6 @@ local function captureScreenshot(x, y, rx, ry)
|
||||
DrawUI()
|
||||
wait(0)
|
||||
UiCaptureDelay = UiCaptureDelay + 1
|
||||
|
||||
until DoesWorldExistAt(xMin, yMin, xMax, yMax) -- Chunks will be drawn on the *next* frame
|
||||
|
||||
wait(0) -- Without this line empty chunks may still appear, also it's needed for the UI to disappear
|
||||
@ -63,6 +62,7 @@ end
|
||||
function startCapturingSpiral()
|
||||
local ox, oy = GameGetCameraPos()
|
||||
ox, oy = math.floor(ox / CAPTURE_GRID_SIZE) * CAPTURE_GRID_SIZE, math.floor(oy / CAPTURE_GRID_SIZE) * CAPTURE_GRID_SIZE
|
||||
ox, oy = ox + 256, oy + 256 -- Align screen with ingame chunk grid that is 512x512
|
||||
local x, y = ox, oy
|
||||
|
||||
local virtualWidth, virtualHeight =
|
||||
@ -156,6 +156,7 @@ function startCapturingHilbert()
|
||||
local hx, hy = mapHilbert(t, gridPOTSize)
|
||||
if hx < gridWidth and hy < gridHeight then
|
||||
local x, y = (hx + gridLeft) * CAPTURE_GRID_SIZE, (hy + gridTop) * CAPTURE_GRID_SIZE
|
||||
x, y = x + 256, y + 256 -- Align screen with ingame chunk grid that is 512x512
|
||||
local rx, ry = x * CAPTURE_PIXEL_SIZE - virtualHalfWidth, y * CAPTURE_PIXEL_SIZE - virtualHalfHeight
|
||||
if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then
|
||||
captureScreenshot(x, y, rx, ry)
|
||||
|
@ -1,5 +1,7 @@
|
||||
<MagicNumbers VIRTUAL_RESOLUTION_X="1280"
|
||||
VIRTUAL_RESOLUTION_Y="720"
|
||||
VIRTUAL_RESOLUTION_OFFSET_X="-2"
|
||||
VIRTUAL_RESOLUTION_OFFSET_Y="0"
|
||||
DRAW_PARALLAX_BACKGROUND="0"
|
||||
DEBUG_FREE_CAMERA_SPEED="10"
|
||||
DEBUG_NO_LOGO_SPLASHES="1"
|
||||
|
Loading…
Reference in New Issue
Block a user