mirror of
https://github.com/coah80/LegacyVulkEdition.git
synced 2026-07-05 16:47:28 +00:00
last hurrah from me
This commit is contained in:
@@ -13,9 +13,11 @@
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STBI_ONLY_PNG
|
||||
#define STBI_ONLY_JPEG
|
||||
#define STBI_NO_STDIO
|
||||
#include "stb_image.h"
|
||||
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
#include "stb_truetype.h"
|
||||
|
||||
#include "VulkanBootstrapApp.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -31,6 +33,12 @@
|
||||
|
||||
VulkanBootstrapApp g_vulkanBackend;
|
||||
|
||||
// Brightness multiplier derived from the gamma setting. Updated by
|
||||
// C4JRender::UpdateGamma each time the user moves the brightness slider.
|
||||
// Range maps from ucGamma 0-32768 -> multiplier ~0.5 (dark) to ~2.0 (bright),
|
||||
// with the midpoint (gamma 0.5) producing a multiplier of 1.0 (no change).
|
||||
static float g_brightnessMul = 1.0f;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@@ -412,9 +420,9 @@ ConvertParams buildConvertParams()
|
||||
}
|
||||
else
|
||||
{
|
||||
params.colourScale[0] = context.renderState.colour[0];
|
||||
params.colourScale[1] = context.renderState.colour[1];
|
||||
params.colourScale[2] = context.renderState.colour[2];
|
||||
params.colourScale[0] = context.renderState.colour[0] * g_brightnessMul;
|
||||
params.colourScale[1] = context.renderState.colour[1] * g_brightnessMul;
|
||||
params.colourScale[2] = context.renderState.colour[2] * g_brightnessMul;
|
||||
params.colourScale[3] = context.renderState.colour[3];
|
||||
}
|
||||
// Blend factor alpha applies to per-vertex alpha in both recording and
|
||||
@@ -909,8 +917,15 @@ void C4JRender::Shutdown()
|
||||
void C4JRender::Tick() {}
|
||||
void C4JRender::UpdateGamma(unsigned short usGamma)
|
||||
{
|
||||
extern void Windows64_UpdateGamma(unsigned short);
|
||||
Windows64_UpdateGamma(usGamma);
|
||||
// usGamma range is 0-32768 (ucGamma 0-100 scaled by 327.68).
|
||||
// Map to a 0.0-1.0 normalised value, then derive a brightness multiplier
|
||||
// using the same power curve the old glfwSetGamma path used:
|
||||
// multiplier = 0.5 * 4^gamma
|
||||
// gamma 0.0 -> 0.5 (darker), 0.5 -> 1.0 (normal), 1.0 -> 2.0 (bright).
|
||||
float gamma = static_cast<float>(usGamma) / 32768.0f;
|
||||
if (gamma < 0.0f) gamma = 0.0f;
|
||||
if (gamma > 1.0f) gamma = 1.0f;
|
||||
g_brightnessMul = 0.5f * std::pow(4.0f, gamma);
|
||||
}
|
||||
void C4JRender::MatrixMode(int type) { getThreadContext().currentMatrixMode = type; }
|
||||
|
||||
@@ -1273,8 +1288,10 @@ bool C4JRender::CBuffCall(int index, bool)
|
||||
currentState.textureIndex = context.currentTextureIndex;
|
||||
|
||||
const auto &colour = context.renderState.colour;
|
||||
const float bMul = g_brightnessMul;
|
||||
const bool needsColourModulation =
|
||||
colour[0] != 1.0f || colour[1] != 1.0f || colour[2] != 1.0f || colour[3] != 1.0f;
|
||||
colour[0] != 1.0f || colour[1] != 1.0f || colour[2] != 1.0f || colour[3] != 1.0f ||
|
||||
bMul != 1.0f;
|
||||
|
||||
// Hoist shader variant outside the loop — the texture index and render state
|
||||
// don't change during display list replay, so this is invariant.
|
||||
@@ -1284,7 +1301,8 @@ bool C4JRender::CBuffCall(int index, bool)
|
||||
: determineShaderVariant(currentState.textureIndex);
|
||||
|
||||
// Pre-build the colour modulation array once instead of per-draw.
|
||||
const float colorMod[4] = {colour[0], colour[1], colour[2], colour[3]};
|
||||
// Fold brightness into the RGB channels so display list replay picks it up.
|
||||
const float colorMod[4] = {colour[0] * bMul, colour[1] * bMul, colour[2] * bMul, colour[3]};
|
||||
|
||||
// Apply the GL_TEXTURE matrix to UV coordinates when it is non-identity.
|
||||
// The precompiled item mesh (ItemInHandRenderer::list) stores UVs in the
|
||||
|
||||
Reference in New Issue
Block a user