Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(gameclient): aura ring opacity follows the map's ground light

Olcay Seyganc64a00583ce9
diff --git a/GeneralsMD/Code/Data/INI/BalanceReforged.ini b/GeneralsMD/Code/Data/INI/BalanceReforged.ini
index 85727c9c0..34a9f4c53 100644
--- a/GeneralsMD/Code/Data/INI/BalanceReforged.ini
+++ b/GeneralsMD/Code/Data/INI/BalanceReforged.ini
@@ -1899,35 +1899,50 @@ Veterancy
; One dial: every ring is the full AuraRadius and each texture keeps to its own band of it
; (Tools/aura_rings.py), rate of fire outermost, so any set of auras reads as one instrument. One
; pale family with a slight tint each, no throb, the ticks and the scale turning very slowly.
+ ; Additive light reads louder the darker the ground, so the opacity is as written where flat ground
+ ; is lit LightReference bright (the map's ambient plus its sun on level ground, 0 to about 1.5) and
+ ; scales with that light, never below LightScaleMin nor above LightScaleMax.
AuraRing_RateOfFire
Texture = ReforgedAuraRateOfFire
Style = SHADOW_ADDITIVE_DECAL
Color = R:230 G:205 B:165
- OpacityMin = 35%
- OpacityMax = 35%
+ OpacityMin = 40%
+ OpacityMax = 40%
SpinTime = 90000
+ LightReference = 0.9
+ LightScaleMin = 0.35
+ LightScaleMax = 1.2
End
AuraRing_Sight
Texture = ReforgedAuraSight
Style = SHADOW_ADDITIVE_DECAL
Color = R:175 G:200 B:230
- OpacityMin = 35%
- OpacityMax = 35%
+ OpacityMin = 40%
+ OpacityMax = 40%
+ LightReference = 0.9
+ LightScaleMin = 0.35
+ LightScaleMax = 1.2
End
AuraRing_Guard
Texture = ReforgedAuraGuard
Style = SHADOW_ADDITIVE_DECAL
Color = R:180 G:215 B:180
- OpacityMin = 35%
- OpacityMax = 35%
+ OpacityMin = 40%
+ OpacityMax = 40%
+ LightReference = 0.9
+ LightScaleMin = 0.35
+ LightScaleMax = 1.2
End
AuraRing_Range
Texture = ReforgedAuraRange
Style = SHADOW_ADDITIVE_DECAL
Color = R:205 G:185 B:225
- OpacityMin = 28%
- OpacityMax = 28%
+ OpacityMin = 32%
+ OpacityMax = 32%
SpinTime = -120000
+ LightReference = 0.9
+ LightScaleMin = 0.35
+ LightScaleMax = 1.2
End
AuraRing_Rally
Texture = ReforgedAuraRally
@@ -1935,6 +1950,9 @@ Veterancy
Color = R:215 G:215 B:210
OpacityMin = 30%
OpacityMax = 30%
+ LightReference = 0.9
+ LightScaleMin = 0.25
+ LightScaleMax = 1.2
End
End
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/RadiusDecal.h b/GeneralsMD/Code/GameEngine/Include/GameClient/RadiusDecal.h
index 65f268c96..f8d42d04a 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/RadiusDecal.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/RadiusDecal.h
@@ -79,6 +79,11 @@ private:
Color m_color;
Bool m_onlyVisibleToOwningPlayer;
Int m_spinTime; ///< milliseconds a turn takes, below 0 the other way; 0 stands still
+ Real m_lightReference; ///< flat-ground light at which the opacity is as written; 0 leaves it unscaled
+ Real m_lightScaleMin; ///< the opacity scale never falls below this (dark maps)
+ Real m_lightScaleMax; ///< nor rises above this (bright maps)
+
+ Real lightScale() const;
public:
RadiusDecalTemplate();
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp
index 0ab0de6de..63eb9c14e 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp
@@ -31,6 +31,7 @@
#define DEFINE_SHADOW_NAMES
+#include "Common/GlobalData.h"
#include "Common/Player.h"
#include "Common/PlayerList.h"
#include "Common/Xfer.h"
@@ -55,10 +56,38 @@ RadiusDecalTemplate::RadiusDecalTemplate() :
m_color(0),
m_onlyVisibleToOwningPlayer(true),
m_spinTime(0),
+ m_lightReference(0.0f),
+ m_lightScaleMin(1.0f),
+ m_lightScaleMax(1.0f),
m_name(AsciiString::TheEmptyString) // Added By Sadullah Nader for Init purposes
{
}
+// ------------------------------------------------------------------------------------------------
+/** How bright flat ground is lit at the map's time of day against LightReference, clamped to
+ * LightScaleMin..LightScaleMax. An additive mark adds the same light whatever lies under it, so on a
+ * night map it reads far louder than by day; scaling by the ground's own light keeps it as quiet.
+ * The light the terrain shades a flat cell with (BaseHeightMap's doTheLight): the first light's
+ * ambient, plus each light's diffuse by how steeply it falls. */
+// ------------------------------------------------------------------------------------------------
+static Real groundLight()
+{
+ RGBColor shade = TheGlobalData->m_terrainAmbient[0];
+ for (Int i = 0; i < TheGlobalData->m_numGlobalLights; ++i)
+ {
+ const Real down = MAX(0.0f, -TheGlobalData->m_terrainLightPos[i].z);
+ shade.red += TheGlobalData->m_terrainDiffuse[i].red * down;
+ shade.green += TheGlobalData->m_terrainDiffuse[i].green * down;
+ shade.blue += TheGlobalData->m_terrainDiffuse[i].blue * down;
+ }
+ return 0.30f * shade.red + 0.59f * shade.green + 0.11f * shade.blue;
+}
+
+Real RadiusDecalTemplate::lightScale() const
+{
+ return MIN(m_lightScaleMax, MAX(m_lightScaleMin, groundLight() / m_lightReference));
+}
+
// ------------------------------------------------------------------------------------------------
void RadiusDecalTemplate::createRadiusDecal(const Coord3D& pos, Real radius, const Player* owningPlayer, RadiusDecal& result) const
{
@@ -94,8 +123,10 @@ void RadiusDecalTemplate::createRadiusDecal(const Coord3D& pos, Real radius, con
{
result.m_decal->setAngle(0.0f);
result.m_decal->setColor(m_color == 0 ? clientPlayerColor(owningPlayer) : m_color);
- result.m_decal->setPosition(pos.x, pos.y, pos.z);
+ result.m_decal->setPosition(pos.x, pos.y, pos.z);
result.m_template = this;
+ if (m_lightReference > 0.0f)
+ DEBUG_LOG(("AURA RING LIGHT %s ground=%.3f scale=%.2f\n", m_name.str(), groundLight(), lightScale()));
}
else
{
@@ -134,6 +165,9 @@ void RadiusDecalTemplate::xferRadiusDecalTemplate( Xfer *xfer )
{ "Color", INI::parseColorInt, NULL, offsetof( RadiusDecalTemplate, m_color ) },
{ "OnlyVisibleToOwningPlayer", INI::parseBool, NULL, offsetof( RadiusDecalTemplate, m_onlyVisibleToOwningPlayer ) },
{ "SpinTime", INI::parseInt, NULL, offsetof( RadiusDecalTemplate, m_spinTime ) },
+ { "LightReference", INI::parseReal, NULL, offsetof( RadiusDecalTemplate, m_lightReference ) },
+ { "LightScaleMin", INI::parseReal, NULL, offsetof( RadiusDecalTemplate, m_lightScaleMin ) },
+ { "LightScaleMax", INI::parseReal, NULL, offsetof( RadiusDecalTemplate, m_lightScaleMax ) },
{ 0, 0, 0, 0 }
};
@@ -211,7 +245,10 @@ void RadiusDecal::update()
Int opac;
if( TheGameLogic->getDrawIconUI() && !CinemaDirector_hidesHud() )
{
- opac = REAL_TO_INT((m_template->m_minOpacity + percent * (m_template->m_maxOpacity - m_template->m_minOpacity)) * 255.0f);
+ Real opacity = m_template->m_minOpacity + percent * (m_template->m_maxOpacity - m_template->m_minOpacity);
+ if (m_template->m_lightReference > 0.0f)
+ opacity *= m_template->lightScale();
+ opac = REAL_TO_INT(opacity * 255.0f);
}
else
{