Triforce v0.8.0

Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-25 10:21:32 -06:00
parent 861702476a
commit 4fa4f9188b
881 changed files with 179428 additions and 15581 deletions

View File

@@ -4,6 +4,7 @@
#pragma once
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <vector>
@@ -22,6 +23,99 @@ inline uint64_t key(uint64_t vbuf, uint64_t ibuf, int count, int base_vertex, ui
}
inline bool same_model(uint64_t a, uint64_t b) { return a >> 8 == b >> 8; }
/// (Triforce) A copy of a model, for pair_by_place: where it is (place_of) and which draw of the model it is (its n-th)
struct Placed {
float place[3];
int nth;
};
/// (Triforce) Which of the frame before's copies of a model each of this frame's copies is, by place: for each of `now`, an
/// index into `then`, or -1 (none: the camera's motion then, never another copy's). All copies are paired at once, the
/// nearest pairs first, and never further apart than `reach` (in world units, moved between the two frames). On a tie (the
/// same geometry drawn twice for one object, both at one place) the same n-th draw pairs first. The pairing by draw order
/// (each copy with the frame before's same n-th) is kept when it is as good: every pair of it within the reach, and either
/// more copies paired than nearest first, or as many with the distance moved over all of them no longer (two copies 0.9
/// apart both moving 0.5 pair one by nearest first, at 0.4, and two by draw order, at 0.5 each, which is right). So the
/// reach is all that keeps draw order from pairing a row of copies each with its neighbour: it must stay under the copies'
/// spacing (2 at the most: the Gossip Stones stand 2.3 apart).
/// By draw order alone, the four Gossip Stones (one skinned model drawn four times, in another order from frame to frame,
/// and by two models) took each other's places as their own frame before, and frame generation drew a stone part way to the
/// next one. Nearest first alone fails the other way: two copies 0.6 apart that both move 0.35 have the first one's new
/// place nearest the second's old one
inline std::vector<int> pair_by_place(const std::vector<Placed>& now, const std::vector<Placed>& then, float reach) {
struct Candidate {
double d; // (squared)
bool other; // (not the same n-th: on a tie at one place, the same n-th pairs first)
int i, j;
};
const auto distance2 = [&](int i, int j) {
double d = 0.0;
for (int c = 0; c < 3; c++) {
const double e = (double)now[i].place[c] - (double)then[j].place[c];
d += e * e;
}
return d;
};
std::vector<Candidate> candidates;
const double r2 = (double)reach * (double)reach;
for (int i = 0; i < (int)now.size(); i++)
for (int j = 0; j < (int)then.size(); j++) {
const double d = distance2(i, j);
if (std::isfinite(d) && d <= r2) candidates.push_back({d, now[i].nth != then[j].nth, i, j});
}
std::sort(candidates.begin(), candidates.end(), [](const Candidate& a, const Candidate& b) {
return a.d != b.d ? a.d < b.d : a.other != b.other ? !a.other : a.i != b.i ? a.i < b.i : a.j < b.j;
});
std::vector<int> pairs(now.size(), -1);
std::vector<char> taken(then.size(), 0);
int nearest_n = 0;
double nearest_total = 0.0;
for (const Candidate& c : candidates)
if (pairs[c.i] < 0 && !taken[c.j])
pairs[c.i] = c.j, taken[c.j] = 1, nearest_n++, nearest_total += std::sqrt(c.d);
// (by draw order: kept when it is no worse, as above. A copy without a same n-th then is left unpaired by it)
std::vector<int> by_order(now.size(), -1);
std::vector<char> used(then.size(), 0);
int order_n = 0;
double order_total = 0.0;
for (int i = 0; i < (int)now.size(); i++) {
int j = 0;
while (j < (int)then.size() && then[j].nth != now[i].nth) j++;
if (j == (int)then.size()) continue;
const double d = std::sqrt(distance2(i, j));
if (used[j] || !(d <= (double)reach)) return pairs; // (not within the reach: nearest first; NaN fails here too)
by_order[i] = j, used[j] = 1, order_n++, order_total += d;
}
if (order_n > nearest_n || (order_n == nearest_n && order_total <= nearest_total + 1e-6)) return by_order;
return pairs;
}
/// (Triforce) Where a skinned draw is, to tell copies of one model apart: its origin (3 floats) plus the mean of its bones'
/// translations (nbones 3 x 4 row-major matrices: world = sum(w B p) + origin). A model placed by its origin differs there;
/// copies placed by their bones at one origin (the game's copies of one model share an origin, the Gossip Stones among them)
/// differ in the bones; the sum is the place either way. Bones with a translation that is not finite are left out
inline void place_of(const uint8_t* origin, const uint8_t* bones, uint32_t nbones, float place[3]) {
float o[3];
std::memcpy(o, origin, sizeof o);
double t[3] = {0.0, 0.0, 0.0};
uint32_t used = 0;
for (uint32_t b = 0; b < nbones; b++) {
float m[12];
std::memcpy(m, bones + (size_t)b * 48, sizeof m);
if (!std::isfinite(m[3]) || !std::isfinite(m[7]) || !std::isfinite(m[11])) continue;
t[0] += m[3], t[1] += m[7], t[2] += m[11];
used++;
}
for (int c = 0; c < 3; c++) place[c] = o[c] + (used ? (float)(t[c] / used) : 0.0f);
}
/// (Triforce) The reach of pair_by_place: speed (world units a second) times the time between the two frames, that time
/// taken as 1/60 s at the least and 1/30 s at the most (at the default 60 a second, 1 to 2 units: under the Gossip Stones'
/// 2.3 after any gap, and some ten times a running Link a frame)
inline float place_reach(float speed, double seconds) {
return speed * (float)std::clamp(std::isfinite(seconds) ? seconds : 1.0 / 60.0, 1.0 / 60.0, 1.0 / 30.0);
}
/// shaders/dlss_actor.vert's push constants (the fragment stage's the same)
struct Push {
uint64_t vertices; // (the vertex stream's device address)