Skip to content

Commit

Permalink
Use DoesWorldExistAt() to speed up capturing
Browse files Browse the repository at this point in the history
- Remove any delays
- Move UI rendering into capture coroutine, so wait(...) can be reduced
- Use wait(0) instead of wait(1) in coroutines
- Use default value of STREAMING_CHUNK_TARGET
- Don't suggest to change framerate to 600 Hz
- Don't suggest to disable mTrailerMode
- Add "Done!" screen
- Update README.md

fixes #1
fixes #5
  • Loading branch information
Dadido3 committed Jun 1, 2020
1 parent 8cf480d commit 151d1d8
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 151 deletions.
29 changes: 10 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ Addon that captures the map and saves it as image.

![missing image](images/example1.png)

A resulting image with 3.8 gigapixels can be [seen here](https://easyzoom.com/image/159431) (Warning: Spoilers).
A resulting image with 3.8 gigapixels can be [seen here](https://easyzoom.com/image/203402) (Warning: Spoilers).

## System requirements

- Windows Vista, ..., 10 (64 bit version)
- A few GB of free drive space
- 16-32 GB of RAM (But works with less as long as the software doesn't run out of virtual memory)
- A processor
- Optionally a monitor, keyboard and mouse to interact with the mod/software
- A sound card to listen to music while it's grabbing screenshots
- Windows Vista, ..., 10. (64 bit version)
- A few GB of free drive space.
- 4 or more GB of RAM for gigapixel images. (But it works with less as long as the software doesn't run out of virtual memory)
- A processor.
- Optionally a monitor, keyboard and mouse to interact with the mod/software.
- A sound card to listen to music while it's grabbing screenshots.
Capturing and stitching will take about 180 minutes (160 + 20).

## Usage

Expand All @@ -30,6 +31,7 @@ A resulting image with 3.8 gigapixels can be [seen here](https://easyzoom.com/im
- Don't cover the game window.
- Don't move the game window outside of screen space.
- If you need to pause, use the ESC menu.
- Also, make sure that the console window isn't selected, as you will end up with screenshots of the console instead of the game. You can select and use any other window while it's capturing screenshots, though.
8. When you think you are done, close noita.
9. Start `.../Noita/mods/noita-mapcap/bin/stitch/stitch.exe`.
- Use the default values to create a complete stitch.
Expand All @@ -50,15 +52,11 @@ Here is a step by step explanation how to do so:
<MagicNumbers
VIRTUAL_RESOLUTION_X="840"
VIRTUAL_RESOLUTION_Y="840"
STREAMING_CHUNK_TARGET="22"
...
>
```

`STREAMING_CHUNK_TARGET` seems to have some influence on missing chunks while grabbing screenshots.
If you have problems with not generated (only background) areas, modify this value.

3. Change the following values inside of `.../Noita/save_shared/config.xml` (Not the one in AppData!) to
3. Change the following values inside of `.../Noita/save_shared/config.xml` (Not the one in AppData!) to

``` xml
<Config
Expand All @@ -70,7 +68,6 @@ Here is a step by step explanation how to do so:
window_h="840"
window_w="840"
fullscreen="0"
framerate="600"
...
>
```
Expand All @@ -84,8 +81,6 @@ Here is a step by step explanation how to do so:

6. When the game is loaded (When you can control your character):
- Press `F5`, `F8` and `F12` (In that order).
- Press `F7`, and disable `mTrailerMode` in the menu. (This should reduce chunk loading problems)
- Press `F7` again to close the menu.

7. Press the `>> Start capturing full map <<` button.

Expand All @@ -95,10 +90,6 @@ Here is a step by step explanation how to do so:

## Advanced stuff

You can increase the "countdown" time in `.../Noita/mods/noita-mapcap/files/capture.lua`.
`CAPTURE_DELAY` is the time in frames the script has to wait until it can take a screenshot.
Also, when a chunk is captured, which is not a neighbor of the previous chunk, `CAPTURE_BIGJUMP_DELAY` gets added to the countdown.

If you use `noita_dev.exe`, you can enable the debug mode by pressing `F5`. Once in debug mode, you can use `F8` to toggle shaders (Includes fog of war), and you can use `F12` to disable the UI. There are some more options in the `F7` and `Shift + F7` menu.

You can capture in a different resolution if you want or need to. If you do so, you have to adjust some values inside of the mod.
Expand Down
48 changes: 27 additions & 21 deletions files/capture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

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_DELAY = 8 -- in frames
CAPTURE_BIGJUMP_DELAY = 20 -- in frames. Additional delay after doing a "larger than grid jump"
CAPTURE_FORCE_HP = 4 -- * 25HP

CAPTURE_LEFT = -25000 -- in ingame pixels. Left edge of the full map capture rectangle
Expand All @@ -26,31 +24,37 @@ local function preparePlayer()
setPlayerHP(CAPTURE_FORCE_HP)
end

local xOld, yOld = 0, 0
local function captureScreenshot(x, y, rx, ry)
-- "Larger than grid jump" delay
local delay = CAPTURE_DELAY - 1
if math.abs(x - xOld) > CAPTURE_GRID_SIZE or math.abs(y - yOld) > CAPTURE_GRID_SIZE then
delay = delay + CAPTURE_BIGJUMP_DELAY
end
xOld, yOld = x, y

-- Set pos several times, so that chunks will load even if nothing happens in the surrounding
-- This prevents black blocks in areas without entites
UiHideCountdown = delay
for i = 1, delay, 1 do
GameSetCameraPos(x, y)
wait(1)
UiHideCountdown = UiHideCountdown - 1
end
local virtualWidth, virtualHeight =
tonumber(MagicNumbersGetValue("VIRTUAL_RESOLUTION_X")),
tonumber(MagicNumbersGetValue("VIRTUAL_RESOLUTION_Y"))

local virtualHalfWidth, virtualHalfHeight = math.floor(virtualWidth / 2), math.floor(virtualHeight / 2)
local xMin, yMin = x - virtualHalfWidth, y - virtualHalfHeight
local xMax, yMax = xMin + virtualWidth, yMin + virtualHeight

UiCaptureDelay = 0
GameSetCameraPos(x, y)
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))
DrawUI()
wait(0)
UiCaptureDelay = UiCaptureDelay + 1
GameSetCameraPos(x, y)
end

DrawUI()
wait(0)
UiCaptureDelay = UiCaptureDelay + 1

UiHide = true -- Hide UI while capturing the screenshot
wait(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
if not TriggerCapture(rx, ry) then
UiCaptureProblem = "Screen capture failed. Please restart Noita."
end
UiHide = false

-- Reset monitor and PC standby each screenshot
ResetStandbyTimer()
Expand Down Expand Up @@ -161,6 +165,8 @@ function startCapturingHilbert()

t = t + 1
end

UiProgress.Done = true
end
)
end
1 change: 0 additions & 1 deletion files/magic_numbers.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<MagicNumbers VIRTUAL_RESOLUTION_X="1280"
VIRTUAL_RESOLUTION_Y="720"
STREAMING_CHUNK_TARGET="22"
DRAW_PARALLAX_BACKGROUND="0"
DEBUG_FREE_CAMERA_SPEED="10"
DEBUG_NO_LOGO_SPLASHES="1"
Expand Down
Loading

0 comments on commit 151d1d8

Please sign in to comment.