mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-29 04:18:49 -04:00
Triforce v0.8.5
A Randomizer page in the launcher, a new title screen with Mods and Save Select tabs, scaling changes applied in game, the Jabu-Jabu bars fixed, renderer frame-time work and the brightness-flash fix, and fixes from the 0.8.4 reports.
This commit is contained in:
@@ -407,28 +407,59 @@ void linearize(ImDrawData* dd) {
|
||||
v.col = (v.col & IM_COL32_A_MASK) | (ImU32)lut[v.col >> IM_COL32_R_SHIFT & 0xFF] << IM_COL32_R_SHIFT |
|
||||
(ImU32)lut[v.col >> IM_COL32_G_SHIFT & 0xFF] << IM_COL32_G_SHIFT | (ImU32)lut[v.col >> IM_COL32_B_SHIFT & 0xFF] << IM_COL32_B_SHIFT;
|
||||
}
|
||||
/// (an HDR10 window image: ST 2084 (PQ) code values in Rec. 2020, framegen_hdr's) an sRGB colour as HDR10 shows it at the
|
||||
/// paper white of the Insert menu's HDR rows: decoded, its primaries to Rec. 2020, its white at paper white nits, PQ coded
|
||||
ImU32 hdr10_of(ImU32 c, float white) {
|
||||
/// ((Triforce, 11-26) How the overlays are coded for an HDR10 window: their white in nits, their primaries, the display gamma
|
||||
/// their codes are shown with. The owner, of our options beside the game's own with HDR Native and RenoDX: "washed out ...
|
||||
/// correct the shading to be exactly the same color and shading of the vanilla options". RenoDX's encoder (its zelda-oot-oz
|
||||
/// output_0x92D6F81D.frag.slang) codes the finished picture, the game's own menus in it, at the UI brightness row's nits, its
|
||||
/// colours taken as the Color space row says (BT.709, or Display P3: more saturated), after the Gamma correction row's
|
||||
/// power; with its tone mapper and its colour space both Vanilla, the game's own matrix and scale instead. The overlays were
|
||||
/// coded at Paper white as BT.709 with the sRGB curve whatever those rows said: in the owner's setup (PsychoV35, DCI-P3) as
|
||||
/// bright as the game's menus but less saturated (the lab's HDR shots: the game's chosen value's orange has a blue of 4,
|
||||
/// ours 54; a row's plate 174,125,58 against 166,126,69). They are coded as RenoDX codes the game's menus now, wherever its
|
||||
/// encoder codes them its own way; else at Paper white as BT.709, as before
|
||||
struct UiHdr {
|
||||
float white = 200; // (nits)
|
||||
bool p3 = false; // (Display P3's primaries, white D65; else BT.709's)
|
||||
float gamma = 0; // (the display gamma its codes are shown with, 2.2 or 2.4; 0: the sRGB curve)
|
||||
bool operator==(const UiHdr& o) const { return white == o.white && p3 == o.p3 && gamma == o.gamma; }
|
||||
};
|
||||
UiHdr ui_hdr_now() {
|
||||
UiHdr u;
|
||||
u.white = (float)std::clamp(opts.hdr_white, 80, 400);
|
||||
if (opts.hdr == 2 && renodx_chosen() && (opts.rdx_space != 0 || opts.rdx_tonemap != 0)) {
|
||||
u.white = (float)std::clamp(opts.rdx_ui_white, 80, 400);
|
||||
u.p3 = opts.rdx_space == 2;
|
||||
u.gamma = opts.rdx_gamma == 1 ? 2.2f : opts.rdx_gamma == 2 ? 2.4f : 0.0f;
|
||||
}
|
||||
return u;
|
||||
}
|
||||
/// (an HDR10 window image: ST 2084 (PQ) code values in Rec. 2020, framegen_hdr's) an sRGB colour as HDR10 shows it: decoded
|
||||
/// (ui_hdr_now: by the sRGB curve or a display's gamma), its primaries (BT.709's or Display P3's) to Rec. 2020, its white at
|
||||
/// that many nits, PQ coded
|
||||
ImU32 hdr10_of(ImU32 c, const UiHdr& u) {
|
||||
static float lin[256];
|
||||
static unsigned char pq[4097];
|
||||
static float pq_white = -1;
|
||||
if (pq_white != white) {
|
||||
pq_white = white;
|
||||
static UiHdr made{-1.0f, false, -1.0f};
|
||||
if (!(made == u)) {
|
||||
made = u;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
const float v = i / 255.0f;
|
||||
lin[i] = v <= 0.04045f ? v / 12.92f : std::pow((v + 0.055f) / 1.055f, 2.4f);
|
||||
lin[i] = u.gamma > 0 ? std::pow(v, u.gamma) : v <= 0.04045f ? v / 12.92f : std::pow((v + 0.055f) / 1.055f, 2.4f);
|
||||
}
|
||||
for (int i = 0; i <= 4096; i++) { // (linear light, 1 the paper white, to the 8-bit PQ code)
|
||||
const float y = std::pow(i / 4096.0f * white / 10000.0f, 0.1593017578125f);
|
||||
for (int i = 0; i <= 4096; i++) { // (linear light, 1 the white, to the 8-bit PQ code)
|
||||
const float y = std::pow(i / 4096.0f * u.white / 10000.0f, 0.1593017578125f);
|
||||
const float e = std::pow((0.8359375f + 18.8515625f * y) / (1 + 18.6875f * y), 78.84375f);
|
||||
pq[i] = (unsigned char)std::clamp((int)(e * 255.0f + 0.5f), 0, 255);
|
||||
}
|
||||
}
|
||||
const float r = lin[c >> IM_COL32_R_SHIFT & 0xFF], g = lin[c >> IM_COL32_G_SHIFT & 0xFF], b = lin[c >> IM_COL32_B_SHIFT & 0xFF];
|
||||
auto code = [&](float v) { return (ImU32)pq[std::clamp((int)(v * 4096.0f + 0.5f), 0, 4096)]; };
|
||||
return (c & IM_COL32_A_MASK) | code(0.6274f * r + 0.3293f * g + 0.0433f * b) << IM_COL32_R_SHIFT |
|
||||
code(0.0691f * r + 0.9195f * g + 0.0114f * b) << IM_COL32_G_SHIFT | code(0.0164f * r + 0.0880f * g + 0.8956f * b) << IM_COL32_B_SHIFT;
|
||||
// (BT.709 to Rec. 2020; ((11-26) Display P3 to Rec. 2020 through XYZ, as RenoDX's DISPLAYP3_TO_XYZ then XYZ_TO_BT2020)
|
||||
static const float k709[9] = {0.6274f, 0.3293f, 0.0433f, 0.0691f, 0.9195f, 0.0114f, 0.0164f, 0.0880f, 0.8956f};
|
||||
static const float kP3[9] = {0.753833f, 0.198597f, 0.047570f, 0.045744f, 0.941777f, 0.012479f, -0.001210f, 0.017602f, 0.983609f};
|
||||
const float* m = u.p3 ? kP3 : k709;
|
||||
return (c & IM_COL32_A_MASK) | code(m[0] * r + m[1] * g + m[2] * b) << IM_COL32_R_SHIFT |
|
||||
code(m[3] * r + m[4] * g + m[5] * b) << IM_COL32_G_SHIFT | code(m[6] * r + m[7] * g + m[8] * b) << IM_COL32_B_SHIFT;
|
||||
}
|
||||
/// (Triforce, 11-13, the user: "Why is the [shader loading screen] so dark for me after turning hdr on?") A texture's texel
|
||||
/// for an HDR10 window image. The pipeline multiplies a texel by its vertex's colour, and hdr10 below codes every vertex
|
||||
@@ -439,22 +470,22 @@ ImU32 hdr10_of(ImU32 c, float white) {
|
||||
/// screen. So a texel is its HDR10 code over the code of white: times a white tint it is its own code again, exactly, and a
|
||||
/// white shape under a coloured tint is the tint's code, exactly (a coloured texel under a coloured tint is still a
|
||||
/// product of two codes: close, not exact; the exact way is the conversion in the fragment shader, not done)
|
||||
ImU32 hdr10_texel(ImU32 c, float white) {
|
||||
ImU32 hdr10_texel(ImU32 c, const UiHdr& u) {
|
||||
static unsigned char over_white[256];
|
||||
static float made_for = -1;
|
||||
if (made_for != white) {
|
||||
const float w = (float)(hdr10_of(IM_COL32_WHITE, white) >> IM_COL32_R_SHIFT & 0xFF);
|
||||
static UiHdr made_for{-1.0f, false, -1.0f};
|
||||
if (!(made_for == u)) {
|
||||
const float w = (float)(hdr10_of(IM_COL32_WHITE, u) >> IM_COL32_R_SHIFT & 0xFF);
|
||||
for (int i = 0; i < 256; i++) over_white[i] = (unsigned char)std::clamp((int)(i * 255.0f / std::max(w, 1.0f) + 0.5f), 0, 255);
|
||||
made_for = white;
|
||||
made_for = u;
|
||||
}
|
||||
const ImU32 v = hdr10_of(c, white);
|
||||
const ImU32 v = hdr10_of(c, u);
|
||||
return (v & IM_COL32_A_MASK) | (ImU32)over_white[v >> IM_COL32_R_SHIFT & 0xFF] << IM_COL32_R_SHIFT |
|
||||
(ImU32)over_white[v >> IM_COL32_G_SHIFT & 0xFF] << IM_COL32_G_SHIFT | (ImU32)over_white[v >> IM_COL32_B_SHIFT & 0xFF] << IM_COL32_B_SHIFT;
|
||||
}
|
||||
void hdr10(ImDrawData* dd) {
|
||||
const float white = (float)std::clamp(opts.hdr_white, 80, 400);
|
||||
const UiHdr u = ui_hdr_now();
|
||||
for (ImDrawList* list : dd->CmdLists)
|
||||
for (ImDrawVert& v : list->VtxBuffer) v.col = hdr10_of(v.col, white);
|
||||
for (ImDrawVert& v : list->VtxBuffer) v.col = hdr10_of(v.col, u);
|
||||
}
|
||||
void layout(VkCommandBuffer cmd, VkImage image, VkImageLayout from, VkImageLayout to, VkPipelineStageFlags2 src_stage,
|
||||
VkAccessFlags2 src, VkPipelineStageFlags2 dst_stage, VkAccessFlags2 dst) {
|
||||
@@ -474,13 +505,13 @@ void pixels(ImTextureData* tex, int x, int y, int w, int h, unsigned char* dst)
|
||||
for (int row = 0; row < h; row++) {
|
||||
const unsigned char* src = (const unsigned char*)tex->GetPixelsAt(x, y + row);
|
||||
if (tex->Format == ImTextureFormat_RGBA32 && dev.hdr && tex != ImGui::GetIO().Fonts->TexData) { // (the logo, as HDR10 shows it)
|
||||
const float white = (float)std::clamp(opts.hdr_white, 80, 400);
|
||||
const UiHdr u = ui_hdr_now();
|
||||
for (int i = 0; i < w; i++) {
|
||||
ImU32 c;
|
||||
memcpy(&c, src + i * 4, 4);
|
||||
// (over white's code: see hdr10_texel. RX_VK_HDR_TEXEL_OLD=1, a lab switch: coded as a colour, as before)
|
||||
static const bool as_before = getenv("RX_VK_HDR_TEXEL_OLD") != nullptr;
|
||||
c = as_before ? hdr10_of(c, white) : hdr10_texel(c, white);
|
||||
c = as_before ? hdr10_of(c, u) : hdr10_texel(c, u);
|
||||
memcpy(dst + ((size_t)row * w + i) * 4, &c, 4);
|
||||
}
|
||||
} else if (tex->Format == ImTextureFormat_RGBA32) { // (the glyphs: white, their coverage in alpha, the same in any space)
|
||||
|
||||
Reference in New Issue
Block a user