Batch #14351 by SapitoSucio: 0 byte-identical, 2 confirmed by peer review. - fn_02260 RenderCommand::ApplyDepthAlpha: logic confirmed by peer review - fn_02261 LightmappedPrimitive::ApplyDepthAlpha: logic confirmed by peer review Peer-reviewed-by: secret, KWDev, codeplay Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
#include "Render/Primitives/DepthAlpha.h"
|
|
#include "Render/Primitives/LightmappedPrimitive.h"
|
|
#include "Render/Primitives/RenderPrimitive.h"
|
|
#include "Render/TextureQuad.h"
|
|
|
|
__declspec(noinline) std::uint32_t DepthAlpha(float reciprocalDepth);
|
|
|
|
// OFFSET: 0x0055D190
|
|
// FUNCTION: fn_02100
|
|
std::uint32_t DepthAlpha(float reciprocalDepth) {
|
|
float value = ((1.0f / reciprocalDepth) - 10.0f) / 1490.0f;
|
|
const float range = g_depthEnd - g_depthStart;
|
|
|
|
if (range != 0.0f) {
|
|
value = (value - g_depthStart) / range;
|
|
}
|
|
|
|
const float lower = 0.0f > value ? 0.0f : value;
|
|
const float upper = 1.0f < lower ? 1.0f : lower;
|
|
const float alpha = (1.0f - upper) * 255.0f;
|
|
|
|
return static_cast<std::uint32_t>(alpha) << 24;
|
|
}
|
|
|
|
// OFFSET: 0x005694A0
|
|
// FUNCTION: fn_02260
|
|
void RenderCommand::ApplyDepthAlpha() {
|
|
for (int index = 0; index < this->vertexCount; ++index) {
|
|
RenderVertex& vertex = this->vertices[index];
|
|
vertex.specular = DepthAlpha(vertex.rhw);
|
|
}
|
|
}
|
|
|
|
// OFFSET: 0x005694E0
|
|
// FUNCTION: fn_02261
|
|
void LightmappedPrimitive::ApplyDepthAlpha() {
|
|
for (int index = 0; index < this->vertexCount; ++index) {
|
|
auto& vertex = this->vertices[index];
|
|
vertex.specular = DepthAlpha(vertex.rhw);
|
|
}
|
|
}
|