Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions runtime/control_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static const Setting settings[] = {
I(hdr_gamma, 0, 2, "none|2.2|bt1886"),
I(hdr_ui_nits, 0, 1000, NULL),
I(fov, 50, 200, NULL), I(hud_size, 0, 150, NULL), B(dynamic_hud), I(menu_speed, 70, 300, NULL), B(bloom), B(depth_of_field),
B(map_zoom_blur),
B(grass), I(grass_distance, 0, GRASS_DIST_COUNT - 1, "auto|potato|original|medium|high"), B(lens_flare), B(fast_fma),I(color_exposure, -20, 20, NULL), I(color_contrast, -50, 50, NULL),
I(color_saturation, -100, 100, NULL), I(color_temperature, -100, 100, NULL),
I(color_tint, -100, 100, NULL),
Expand Down
107 changes: 107 additions & 0 deletions runtime/nvn/vulkan/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -9114,6 +9114,51 @@ static void wait_built(_Atomic int *state) { // (0 building: until built or fai
perfcount_add(PC_BUILD_WAIT_NS, SDL_GetTicksNS() - t0);
}

// Map zoom blur off: switching levels, the game stops drawing the old level's tiles a frame or two before the new
// level's are in, and the map's terrain picture (2250x1080) is then the coarsest level alone (135x135 tiles enlarged
// many times): a blocky flash, which the blur hid. The game draws a coarsest-level tile under every place in view and
// a finer one over each that is in (a closest-level tile, 3000 pixels or more, over up to four). A picture is taken as
// whole when the finer tiles cover as many places as the coarsest, or when the counts have stayed the same for three
// frames (at the widest levels the finer ones never cover the whole view). The last whole picture is kept here and
// put back on the frames where the finer cover fell to under half of that picture's, for at most MAP_HOLD_MAX in a
// row: the gap itself, not the tiles coming in afterwards (the game's own look, a few places at the edges).
enum { MAP_HOLD_MAX = 8 };
static struct { VkImage img; VmaAllocation mem; uint64_t serial; VkFormat format; uint32_t w, h; bool valid; } map_hold;
static void map_hold_copy(TexBackend *b, bool save) {
if (map_hold.img && (map_hold.serial != b->serial || map_hold.format != b->format || map_hold.w != b->width ||
map_hold.h != b->height)) {
vk_defer_image(map_hold.img, map_hold.mem);
map_hold.img = VK_NULL_HANDLE;
map_hold.valid = false;
}
if (!map_hold.img) {
if (!save) return;
VkImageCreateInfo ci = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .imageType = VK_IMAGE_TYPE_2D, .format = b->format,
.extent = {b->width, b->height, 1}, .mipLevels = 1, .arrayLayers = 1,
.samples = VK_SAMPLE_COUNT_1_BIT, .tiling = VK_IMAGE_TILING_OPTIMAL,
.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT};
VmaAllocationCreateInfo ai = {.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE};
if (vmaCreateImage(g_vk.vma, &ci, &ai, &map_hold.img, &map_hold.mem, NULL) != VK_SUCCESS) {
map_hold.img = VK_NULL_HANDLE;
return;
}
map_hold.serial = b->serial, map_hold.format = b->format, map_hold.w = b->width, map_hold.h = b->height;
vk_end_pass();
vk_image_init_layout(vk_cmd(), map_hold.img, VK_IMAGE_ASPECT_COLOR_BIT);
}
if (!save && !map_hold.valid) return;
vk_end_pass();
VkCommandBuffer cb = vk_cmd();
vk_full_barrier(cb);
VkImageCopy c = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
.extent = {b->width, b->height, 1}};
if (save) rec_CmdCopyImage(cb, b->image, VK_IMAGE_LAYOUT_GENERAL, map_hold.img, VK_IMAGE_LAYOUT_GENERAL, 1, &c);
else rec_CmdCopyImage(cb, map_hold.img, VK_IMAGE_LAYOUT_GENERAL, b->image, VK_IMAGE_LAYOUT_GENERAL, 1, &c);
vk_full_barrier(cb);
map_hold.valid = true;
}
RT_ON_RESET(map_hold_reset) { map_hold.valid = false; }

static void draw_(CmdRec *r, bool indexed) {
if (profd) prof_tp_ = SDL_GetTicksNS();
ProfZone pz0 = PZ_NOW();
Expand Down Expand Up @@ -9199,6 +9244,60 @@ static void draw_(CmdRec *r, bool indexed) {
if (bloom) { stat_skipped++; return; }
}
if (!g_settings.depth_of_field && g_cur_fs_hash == UINT64_C(0xf7731492223eb16a)) { stat_skipped++; return; }
// Map zoom blur off: as it opens and after each zoom, the world map blurs the screen (1280x720, four passes each
// way) and blends that back over the map for about half a second, through a mask and a ramp. Its two blend draws
// are skipped while the map is open (the blur passes themselves are shared with other effects): known open from the
// screens, or from the map's terrain picture (2250x1080) put on screen earlier this frame (fs c94630386244616e), as
// the screens don't say so on every way into the map.
// Zooming in to the closest level, the blur is blended through that same draw instead: the screen shrunk to 320x180,
// blurred and enlarged to 1280x720, put over the map through a dot mask (192x192) for about 100 frames.
// The game has several programs for that blend (c94630386244616e, d1d87dfe0c81ad63 and more): any draw reading the
// blurred 1280x720 image with a square mask after the map's picture this frame is taken as one.
static uint64_t map_frame = UINT64_MAX, map_target_frame = UINT64_MAX;
static NvnTexture *map_target; // (this frame's only: map_target_frame)
static unsigned map_fine, map_coarse, map_held; // (this frame's places covered: by finer levels, the coarsest)
static unsigned map_last_fine, map_last_coarse, map_same; // (the previous map frame's, and frames unchanged since)
static unsigned map_whole_fine; // (the held picture's)
NvnTexture *rt0 = st.rt.ncolor > 0 ? st.rt.color[0] : NULL;
if (!g_settings.map_zoom_blur && rt0 && rt0->target == 1 && rt0->width == 2250 && rt0->height == 1080 &&
pr->fi->ntex > 0) { // (a tile of the map's picture: finer than the coarsest level's 135x135)
NvnTexture *t = shader_texture_object(1, &pr->fi->tex[0]);
if (map_target_frame != renderer_present_count()) map_fine = map_coarse = 0;
map_target = rt0, map_target_frame = renderer_present_count();
if (t && t->width == t->height && t->width >= 300) map_fine += t->width >= 3000 ? 4 : 1;
else if (t && t->width == t->height && t->width >= 64) map_coarse++;
}
if (g_cur_fs_hash == UINT64_C(0xc94630386244616e) && pr->fi->ntex > 0) {
NvnTexture *t = shader_texture_object(1, &pr->fi->tex[0]);
if (t && t->width == 2250 && t->height == 1080) {
if (map_frame + 1 != renderer_present_count() && map_frame != renderer_present_count())
map_hold.valid = false, map_whole_fine = 0; // (the map just opened: not last visit's picture)
map_frame = renderer_present_count();
if (!g_settings.map_zoom_blur && map_target_frame == map_frame) {
TexBackend *b = vk_tex(map_target, true);
if (b && b->image && b->samples == 1 && b->levels >= 1 && b->layers >= 1) {
map_same = map_fine == map_last_fine && map_coarse == map_last_coarse ? map_same + 1 : 0;
map_last_fine = map_fine, map_last_coarse = map_coarse;
if ((map_fine && map_fine >= map_coarse) || map_same >= 2) {
map_hold_copy(b, true), map_held = 0;
map_whole_fine = map_fine;
} else if (map_fine * 2 < map_whole_fine && map_held < MAP_HOLD_MAX) {
map_hold_copy(b, false), map_held++;
} else map_held = 0;
}
}
}
}
if (!g_settings.map_zoom_blur && map_frame == renderer_present_count() && pr->fi->ntex == 2) {
NvnTexture *t = shader_texture_object(1, &pr->fi->tex[0]), *m = shader_texture_object(1, &pr->fi->tex[1]);
if (t && m && t->width == 1280 && t->height == 720 && m->width == m->height && m->width <= 256) {
stat_skipped++;
return;
}
}
if (!g_settings.map_zoom_blur && (g_cur_fs_hash == UINT64_C(0x6da1591e7d7e6726) ||
g_cur_fs_hash == UINT64_C(0xdfddd20310007579)) &&
(map_frame == renderer_present_count() || framepace_map_ui())) { stat_skipped++; return; }
// The bloom's fixed tap offsets must address adjacent console-size texels.
// Enlarging those images spaces the taps apart and produces separate copies
// of emissive details; odd mip scratch sizes also stopped inheriting scale.
Expand Down Expand Up @@ -9535,6 +9634,14 @@ static void draw_(CmdRec *r, bool indexed) {
memcpy(k.s.blend[i] + 1, st.blend[i] + 1, 6); // (the factors and ops; 0 is the target index, 7 padding)
}
}
// Map zoom blur off: on a zoom the map's terrain capture (2250x1080) fades the old level's tiles out and the new
// level's in (fs 10e88719ecc264ca, alpha-blended), over the coarsest level magnified many times: the blur seen in
// the zoom. Those tiles are drawn opaque instead (colour only; the capture's alpha is left as it is).
if (!g_settings.map_zoom_blur && g_cur_fs_hash == UINT64_C(0x10e88719ecc264ca) && st.rt.color[0] &&
st.rt.color[0]->target == 1 && st.rt.color[0]->width == 2250 && st.rt.color[0]->height == 1080) {
k.s.blend_on &= (uint8_t)~1u;
k.s.write_mask[0] &= 0x7;
}
if (ps.mvec >= 0 && (pr->fi->mvec || pr->fi->mvec_still)) k.s.write_mask[ps.mvec] = 0xF; // (mvec.c: only motion and still programs write it)
if (ps.mvec >= 0 && pr->fi->mvec_mask) { // (the reactive mask: .z alone, the strongest effect kept)
static const uint8_t max_blend[8] = {0, 2, 2, 2, 2, 5, 5, 0}; // (ONE, ONE, MAX: blend_factor, blend_op)
Expand Down
3 changes: 3 additions & 0 deletions runtime/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Settings g_settings = {
.haze = 100,
.bloom = true,
.depth_of_field = true,
.map_zoom_blur = true,
.grass = true,
.lens_flare = true,
.fast_fma = true,
Expand Down Expand Up @@ -689,6 +690,7 @@ void settings_load(void) {
}
else if (!strcmp(key, "bloom")) g_settings.bloom = atoi(val) != 0;
else if (!strcmp(key, "depth_of_field")) g_settings.depth_of_field = atoi(val) != 0;
else if (!strcmp(key, "map_zoom_blur")) g_settings.map_zoom_blur = atoi(val) != 0;
else if (!strcmp(key, "grass")) g_settings.grass = atoi(val) != 0;
else if (!strcmp(key, "grass_distance")) {
g_settings.grass_distance = GRASS_DIST_FOLLOW;
Expand Down Expand Up @@ -991,6 +993,7 @@ bool settings_save_to(const char *path) {
fprintf(f, "haze = %d\n", g_settings.haze);
fprintf(f, "bloom = %d\n", g_settings.bloom ? 1 : 0);
fprintf(f, "depth_of_field = %d\n", g_settings.depth_of_field ? 1 : 0);
fprintf(f, "map_zoom_blur = %d\n", g_settings.map_zoom_blur ? 1 : 0);
fprintf(f, "grass = %d\n", g_settings.grass ? 1 : 0);
int gd = g_settings.grass_distance;
fprintf(f, "grass_distance = %s\n", k_grass_dist[gd >= 0 && gd < GRASS_DIST_COUNT ? gd : GRASS_DIST_FOLLOW]);
Expand Down
2 changes: 2 additions & 0 deletions runtime/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ typedef struct {
int haze; // the air's haze, percent of the game's (services/fs.c haze_patch; from the next start)
bool bloom; // the glow around bright light (off: its draws clear their images: vulkan/exec.c)
bool depth_of_field; // the distance blur over far pixels (off: its draw is skipped: vulkan/exec.c)
bool map_zoom_blur; // the blur the world map lays over itself as it opens and after each zoom (off: its blend
// draws are skipped: vulkan/exec.c)
bool grass; // grass blades and crossed quads (off: draw_distance.c hides both layers)
int grass_distance; // GRASS_DIST_*: independent grass draw distance (0: follow draw_distance)
bool lens_flare; // sun glare / lens flare (off: vulkan/exec.c skips sun occlusion queries)
Expand Down
3 changes: 3 additions & 0 deletions runtime/ui/game_options.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,9 @@ void build_items(void) {
v.push_back(toggle(P_VIDEO_ADV, "Depth of field", "Blurs the far distance. Off: sharp out to the horizon.",
[](const Item &) { return (int)g_settings.depth_of_field; },
[](const Item &, int x) { g_settings.depth_of_field = x; }, 1));
v.push_back(toggle(P_VIDEO_ADV, "Map zoom blur", "Blurs the map for a moment when it opens and after each zoom. Off: sharp straight away.",
[](const Item &) { return (int)g_settings.map_zoom_blur; },
[](const Item &, int x) { g_settings.map_zoom_blur = x; }, 1));
v.push_back(toggle(P_VIDEO_ADV, "Grass", "Grass blades and ground cover. Off: bare terrain, faster.",
[](const Item &) { return (int)g_settings.grass; },
[](const Item &, int x) { g_settings.grass = x; }, 1));
Expand Down
2 changes: 2 additions & 0 deletions runtime/ui/i18n/de.inc
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,8 @@ T("Bloom", "Bloom")
T("The glow around bright light. Off: a little faster.", "Das Leuchten um helles Licht. Aus: etwas schneller.")
T("Depth of field", "Tiefenschärfe")
T("Blurs the far distance. Off: sharp out to the horizon.", "Macht die Ferne unscharf. Aus: scharf bis zum Horizont.")
T("Map zoom blur", "Kartenzoom-Unschärfe")
T("Blurs the map for a moment when it opens and after each zoom. Off: sharp straight away.", "Macht die Karte beim Öffnen und nach jedem Zoomen kurz unscharf. Aus: sofort scharf.")
T("Sets the draw distance, shadows, upscaler, anti-aliasing, texture filtering and the Advanced options at once. Potato: for weak PCs (nearer, smaller shadows, FSR 1, no bloom or depth of field). Original: as on the console. High and Savage: further and sharper, for faster PCs.", "Stellt Sichtweite, Schatten, Upscaler, Kantenglättung, Texturfilterung und die erweiterten Optionen auf einmal ein. Potato: für schwache PCs (näher, kleinere Schatten, FSR 1, kein Bloom und keine Tiefenschärfe). Original: wie auf der Konsole. Hoch und Savage: weiter und schärfer, für schnellere PCs.")
T("Advanced", "Erweitert")
T("The glow around bright light: the sun, fire, glowing eyes. Off: a little faster, a flatter image.", "Das Leuchten um helles Licht: Sonne, Feuer, leuchtende Augen. Aus: etwas schneller, ein flacheres Bild.")
Expand Down
2 changes: 2 additions & 0 deletions runtime/ui/i18n/es.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,8 @@ T("Bloom", "Bloom")
T("The glow around bright light. Off: a little faster.", "El resplandor alrededor de las luces fuertes. Desactivado: un poco más rápido.")
T("Depth of field", "Profundidad de campo")
T("Blurs the far distance. Off: sharp out to the horizon.", "Desenfoca la lejanía. Desactivada: nítido hasta el horizonte.")
T("Map zoom blur", "Desenfoque al hacer zoom en el mapa")
T("Blurs the map for a moment when it opens and after each zoom. Off: sharp straight away.", "Desenfoca el mapa un momento al abrirlo y tras cada zoom. Desactivado: nítido al instante.")
T("Sets the draw distance, shadows, upscaler, anti-aliasing, texture filtering and the Advanced options at once. Potato: for weak PCs (nearer, smaller shadows, FSR 1, no bloom or depth of field). Original: as on the console. High and Savage: further and sharper, for faster PCs.", "Ajusta a la vez la distancia de dibujado, las sombras, el escalador, el antialiasing, el filtrado de texturas y las opciones avanzadas. Potato: para PCs modestos (más cerca, sombras más pequeñas, FSR 1, sin bloom ni profundidad de campo). Original: como en la consola. Alta y Savage: más lejos y más nítido, para PCs más rápidos.")
T("Advanced", "Avanzado")
T("The glow around bright light: the sun, fire, glowing eyes. Off: a little faster, a flatter image.", "El resplandor alrededor de las luces fuertes: el sol, el fuego, los ojos que brillan. Desactivado: un poco más rápido, una imagen más plana.")
Expand Down
2 changes: 2 additions & 0 deletions runtime/ui/i18n/fr.inc
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,8 @@ T("Bloom", "Bloom")
T("The glow around bright light. Off: a little faster.", "Le halo autour des lumières vives. Désactivé : un peu plus rapide.")
T("Depth of field", "Profondeur de champ")
T("Blurs the far distance. Off: sharp out to the horizon.", "Floute le lointain. Désactivée : net jusqu'à l'horizon.")
T("Map zoom blur", "Flou du zoom de la carte")
T("Blurs the map for a moment when it opens and after each zoom. Off: sharp straight away.", "Rend la carte floue un instant à l'ouverture et après chaque zoom. Désactivé : nette tout de suite.")
T("Sets the draw distance, shadows, upscaler, anti-aliasing, texture filtering and the Advanced options at once. Potato: for weak PCs (nearer, smaller shadows, FSR 1, no bloom or depth of field). Original: as on the console. High and Savage: further and sharper, for faster PCs.", "Règle d'un coup la distance d'affichage, les ombres, l'upscaler, l'anticrénelage, le filtrage des textures et les options avancées. Potato : pour les PC modestes (plus proche, ombres plus petites, FSR 1, sans bloom ni profondeur de champ). Original : comme sur la console. Élevé et Savage : plus loin et plus net, pour les PC plus rapides.")
T("Advanced", "Avancé")
T("The glow around bright light: the sun, fire, glowing eyes. Off: a little faster, a flatter image.", "Le halo autour des lumières vives : le soleil, le feu, les yeux qui brillent. Désactivé : un peu plus rapide, une image plus plate.")
Expand Down
2 changes: 2 additions & 0 deletions runtime/ui/i18n/he.inc
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,8 @@ T("Bloom", "Bloom")
T("The glow around bright light. Off: a little faster.", "הזוהר סביב אור חזק. כבוי: מעט מהיר יותר.")
T("Depth of field", "עומק שדה")
T("Blurs the far distance. Off: sharp out to the horizon.", "מטשטש את המרחק. כבוי: חד עד האופק.")
T("Map zoom blur", "טשטוש בזום המפה")
T("Blurs the map for a moment when it opens and after each zoom. Off: sharp straight away.", "מטשטש את המפה לרגע בפתיחה ואחרי כל זום. כבוי: חדה מיד.")
T("Sets the draw distance, shadows, upscaler, anti-aliasing, texture filtering and the Advanced options at once. Potato: for weak PCs (nearer, smaller shadows, FSR 1, no bloom or depth of field). Original: as on the console. High and Savage: further and sharper, for faster PCs.", "מגדיר בבת אחת את מרחק התצוגה, הצללים, ההגדלה, החלקת הקצוות, סינון המרקמים והאפשרויות המתקדמות. Potato: למחשבים חלשים (קרוב יותר, צללים קטנים יותר, FSR 1, בלי בלום ועומק שדה). Original: כמו בקונסולה. גבוה ו-Savage: רחוק וחד יותר, למחשבים מהירים יותר.")
T("Advanced", "מתקדם")
T("The glow around bright light: the sun, fire, glowing eyes. Off: a little faster, a flatter image.", "הזוהר סביב אור חזק: השמש, אש, עיניים זוהרות. כבוי: מעט מהיר יותר, תמונה שטוחה יותר.")
Expand Down
2 changes: 2 additions & 0 deletions runtime/ui/i18n/it.inc
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,8 @@ T("Bloom", "Bloom")
T("The glow around bright light. Off: a little faster.", "Il bagliore attorno alle luci forti. Disattivato: un po' più veloce.")
T("Depth of field", "Profondità di campo")
T("Blurs the far distance. Off: sharp out to the horizon.", "Sfoca la distanza. Disattivata: nitido fino all'orizzonte.")
T("Map zoom blur", "Sfocatura dello zoom della mappa")
T("Blurs the map for a moment when it opens and after each zoom. Off: sharp straight away.", "Sfoca la mappa per un attimo all'apertura e dopo ogni zoom. Disattivata: nitida subito.")
T("Sets the draw distance, shadows, upscaler, anti-aliasing, texture filtering and the Advanced options at once. Potato: for weak PCs (nearer, smaller shadows, FSR 1, no bloom or depth of field). Original: as on the console. High and Savage: further and sharper, for faster PCs.", "Imposta insieme la distanza di visualizzazione, le ombre, l'upscaler, l'antialiasing, il filtro delle texture e le opzioni avanzate. Potato: per PC deboli (più vicino, ombre più piccole, FSR 1, senza bloom né profondità di campo). Original: come su console. Alta e Savage: più lontano e più nitido, per PC più veloci.")
T("Advanced", "Avanzate")
T("The glow around bright light: the sun, fire, glowing eyes. Off: a little faster, a flatter image.", "Il bagliore attorno alle luci forti: il sole, il fuoco, gli occhi che brillano. Disattivato: un po' più veloce, un'immagine più piatta.")
Expand Down
Loading