Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
SignalLightAttenuation.h
Go to the documentation of this file.
1
#pragma once
2
#include "
../Rendering/ClientRenderer11.h
"
3
#include <algorithm>
4
#include <cmath>
5
6
namespace
SignalLightAttenuation
7
{
8
inline
DirectX::XMFLOAT4
Factor
(
const
RiseMath::Color
& emission,
float
transmission)
9
{
10
// Preserve the authored clear-air color and squared flare texture.
11
// SRC_COLOR blending squares the shader output, so sqrt(T) applies
12
// fog/cloud extinction once: (texture * color)^2 * T, not ... * T^2.
13
const
DWORD
packed = emission;
14
const
float
scale = std::sqrt((std::max)(0.f, (std::min)(1.f, transmission))) / 255.f;
15
return
{float((packed >> 16) & 255) * scale, float((packed >> 8) & 255) * scale,
16
float(packed & 255) * scale, emission.
a
};
17
}
18
19
// Native additive bulbs use the same visibility policy as the legacy
20
// signal sprites, without squaring their authored texture/color profile.
21
inline
float
EmissionTransmission
(
float
transmission,
bool
isSimulator)
22
{
23
const
float
t = (std::max)(0.f, (std::min)(1.f, transmission));
24
return
isSimulator ? t * t : t;
25
}
26
27
inline
void
Apply
(
Rendering::RenderDevice
& device,
const
RiseMath::Color
& emission,
28
float
transmission,
bool
isSimulator)
29
{
30
// The caller has already set the original attenuated, packed color.
31
// Retain that exact baseline (including quantization) in the simulator.
32
if
(isSimulator)
return
;
33
// Apply after the caller's TEXTUREFACTOR state so extinction retains
34
// float precision instead of being rounded to an intermediate DWORD.
35
device.
Draws
().
Fixed
().
textureFactor
=
Factor
(emission, transmission);
36
}
37
}
ClientRenderer11.h
DWORD
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
Definition
Controls.cpp:5032
Rendering::DrawContext11::Fixed
FixedState11 & Fixed()
Definition
DrawContext11.h:35
Rendering::RenderDevice
Definition
ClientRenderer11.h:92
Rendering::RenderDevice::Draws
DrawContext11 & Draws()
Definition
ClientRenderer11.h:96
SignalLightAttenuation
Definition
SignalLightAttenuation.h:7
SignalLightAttenuation::Apply
void Apply(Rendering::RenderDevice &device, const RiseMath::Color &emission, float transmission, bool isSimulator)
Definition
SignalLightAttenuation.h:27
SignalLightAttenuation::Factor
DirectX::XMFLOAT4 Factor(const RiseMath::Color &emission, float transmission)
Definition
SignalLightAttenuation.h:8
SignalLightAttenuation::EmissionTransmission
float EmissionTransmission(float transmission, bool isSimulator)
Definition
SignalLightAttenuation.h:21
Rendering::FixedState11::textureFactor
DirectX::XMFLOAT4 textureFactor
Definition
FixedFunction11.h:71
RiseMath::Color
Definition
ClientMath.h:67
RiseMath::Color::a
float a
Definition
ClientMath.h:68
Viewscreen
SignalLightAttenuation.h
Generated on
for Rise by
1.18.0