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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(data): EA's fireballs back in place of the toy flipbook blasts
Olcay Seyganb7f84cbc6874
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 782409fe1..84d6ff0e7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -79,6 +79,7 @@ found and fixed, EA's own, not port damage.**- Options has a Water Style box. Modern rolls the sea in waves whose crests catch the sun all the way into the shallows, and at the shore they turn along the bank and pile up foam. Boats push foam off their hulls. Classic stays the default, and either way a map keeps the water colour and depth its maker gave it.- Windows has it now on the default renderer, and the box switches it in the middle of a match. The Direct3D 9 renderer and macOS keep the Classic water and hide the box. Linux still draws one thing Windows does not, a second band of foam laid over the surf where waves break on a beach. The first Modern frame on a fresh install stops for about ten seconds while its two water shaders compile; every match after that loads them from the cache.+- The main menu runs smoothly again. 3.4.0's quality slider switched Modern water on for every detail level from Medium up, and for anyone who had never touched the Water Style box, so the sea under the menu cost a pass 11 to 45 ms where Classic water takes 3 to 6 on an RTX 2060. Modern water is your pick again: the slider and the detail presets leave the box as you set it, and Classic is what you get until you choose otherwise.## Volumetric hazard clouds@@ -1774,7 +1775,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same- A bright cloud no longer shows what is behind it as a line drawing. Inside a nuke's white cloud, or a falling War Factory's fireball, every tree and wreck under it used to come out as a thin grey outline, and the picture's sharpening ringed each dark piece in white. Both stop where the frame is bright. A yellow or orange fireball still drew them, because the shading that darkens corners was laid over the finished picture and read the fire as dark: an Aurora's bomb on a War Factory showed its chimneys, its lattice and the trees beside it as dark outlines through the flames. Corners are now shaded before any fire or smoke is drawn, so a blast of any colour covers what is behind it.- Smoke and fire no longer end on a straight line where they meet the ground or a building. A puff that sinks into a hillside or drifts against a wall thins out over its last few metres, softly enough that a nuke's haze and a Scud's grey smoke no longer come out as stacked, stair-stepped terraces, and a toxin cloud lying low over the ground keeps its body instead of breaking into hard-edged green islands. A China mine field blinks where you can see it again: its lights hang just off the ground, and the fade had eaten all but a thirtieth of their bright middle. No effect fades over more than its own size now, so a small spark close to the ground keeps its light. This is the default renderer; Classic and the old renderer keep the hard edge they had in 2003.- Fire burns instead of fading. Every flame and fireball in the game, 182 kinds from a burning soldier to a nuke's mushroom, starts white-hot and cools through yellow, orange and red to a sooty dark as it dies, eats away from its thin edges in rather than going see-through all at once, and licks and flickers, so a fire that used to be a still picture getting dimmer now moves. Green toxin and anthrax fires keep their colour. Default renderer only; Classic and the old renderer draw fire as they did.-- A tank shell landing, a tank dying and a mid-sized building going down now explode as a rolling fireball that swells and cools from yellow through deep orange to soot instead of a still picture of one, with a column of turning smoke climbing behind it. A building no longer goes down behind a white flare. Both are animated paintings, so they move on every renderer.+- A tank dying and a mid-sized building going down leave a column of dark smoke climbing out of the wreck after the fireball, and a building no longer goes down behind a white flare. From 3.3.0 to 3.4.1 those two and a tank shell landing went off as a smooth orange ball with grey smoke puffs stacked over it like cotton wool, which looked like a toy; they explode in the game's own fire again, ragged and streaked with soot.- Gunfire shows at the zoom you play at. A rifle's tracer was a third of a unit wide, about one pixel from the default camera, and a bullet hit nothing you could see. Tracers from rifles, Gattlings, Humvees, Technicals and Quad Cannons are now twice as wide and half again as long, the muzzle flash is half as big again, and every hit kicks up sparks and a puff of dirt where it lands. A tank shell burns a short hot streak behind it all the way to the target, where it used to be a grey sliver you could not pick out between the flash and the blast. A Crusader's, Battlemaster's, Scorpion's, Paladin's or Overlord's shot used to be a soft white glow drifting out in front of the gun, wider than the tank; it is now a short orange blast at the barrel tip, with a bigger flame and smoke puff behind it. A shell landing throws dirt and sparks around its blast. The colours are the ones the game always used, and no weapon does anything different.- Blasts throw fragments that smoke. The bigger explosions fling hot sparks into the air, each drawing a thin dark line of smoke that climbs, fans around the blast and curves down. A Stinger, a rocket pod, a tank shell or a rocket used to throw them too, and a fight filled with them; they now show on a bomb, a heavy shell, a Scud or a building, five that climb several times a tank's length, and on a nuke, a MOAB, a Daisy Cutter or a large building, eight that arc over its own fireball and hang for a couple of seconds. A vehicle that blows up throws burning pieces that drag near-black smoke and bounce where they land, and the turret, wheels and plates it throws off trail smoke and flame too, then smoulder a moment on the ground. The fragments and their smoke are the first effects the particle limit and a lower detail setting drop, so a bigger fight keeps its explosions and loses some lines. What a weapon does is unchanged. Rather have the explosions as they always were? Explosion Debris Trails in the launcher's Options turns all of it off, for you alone: the other players in your match keep whatever they picked, and nobody's game falls out of step over it.- A China mine field tells you what kind it is. EA's field had no model at all, only a soft white glint swelling and fading on each of its eight spots, so your own minefield looked like a patch of fireflies. Each mine is now marked by a small arming light that snaps on for a quarter of a second every second and a half, red on standard and cluster mines and blue on EMP mines, with a white-hot point and a dark rim that keep it readable on grass, sand or snow. No mine body is drawn on the ground, only the light. The enemy still sees nothing until he detects the field. A mine going off under a tank now throws a column of dark earth twice the tank's height, scatters clods round it and leaves a low black smoke and a scorch, with a short jolt of the screen; it used to puff a pale spray of specks that looked like dust kicked up. An EMP mine throws no earth, so you can tell which kind went off: it lights a blue ring across the ground, a crackle of blue sparks and a short blue flash at the spot; EA's flash grew until it washed the whole screen white for a fifth of a second. What a mine does is unchanged.diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifestindex 32bbedb1e..d450226cd 100644--- a/GeneralsMD/Code/BuildFingerprint.manifest+++ b/GeneralsMD/Code/BuildFingerprint.manifest@@ -14,8 +14,6 @@ Data/Art/Textures/ReforgedBarChinaRight.tgaData/Art/Textures/ReforgedBarGLACenter.tgaData/Art/Textures/ReforgedBarGLALeft.tgaData/Art/Textures/ReforgedBarGLARight.tga-Data/Art/Textures/ReforgedExplosionFire.dds-Data/Art/Textures/ReforgedExplosionSmoke.ddsData/Art/Textures/ReforgedForceAttack.tgaData/Art/Textures/ReforgedHudAmericaCommandBar.ddsData/Art/Textures/ReforgedHudAmericaPowers.dds@@ -4043,7 +4041,6 @@ Tools/china_beacon.pyTools/control_client.pyTools/d3d9posix_check.pyTools/diplomacy_layout.py-Tools/explosion_flipbook.pyTools/ffmpeg-build-posix.shTools/ffmpeg-build.batTools/ffmpeg-build.shdiff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedExplosionFire.dds b/GeneralsMD/Code/Data/Art/Textures/ReforgedExplosionFire.ddsdeleted file mode 100644index 99977b922..000000000Binary files a/GeneralsMD/Code/Data/Art/Textures/ReforgedExplosionFire.dds and /dev/null differdiff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedExplosionSmoke.dds b/GeneralsMD/Code/Data/Art/Textures/ReforgedExplosionSmoke.ddsdeleted file mode 100644index 4b2a9cdc7..000000000Binary files a/GeneralsMD/Code/Data/Art/Textures/ReforgedExplosionSmoke.dds and /dev/null differdiff --git a/GeneralsMD/Code/Data/Cinema/explfx.txt b/GeneralsMD/Code/Data/Cinema/explfx.txtindex 114af4db0..43af50fa9 100644--- a/GeneralsMD/Code/Data/Cinema/explfx.txt+++ b/GeneralsMD/Code/Data/Cinema/explfx.txt@@ -1,4 +1,4 @@-# Scenarios/explfx.txt filmed close, for the flipbook explosions (-video 120 1440). Three takes on+# Scenarios/explfx.txt filmed close, for the explosions (-video 120 1440). Three takes on# Twilight Flame round start 0 (537,3188): Battlemasters and Crusaders trading shells with the first# Crusaders dying, the barracks falling under Overlord fire, and the second Crusader wave meeting the# Battlemasters and the Overlords.diff --git a/GeneralsMD/Code/Data/INI/FXListReforged.ini b/GeneralsMD/Code/Data/INI/FXListReforged.iniindex 1a8e8b8a6..45a7e90f8 100644--- a/GeneralsMD/Code/Data/INI/FXListReforged.ini+++ b/GeneralsMD/Code/Data/INI/FXListReforged.ini@@ -83,19 +83,12 @@ FXList WeaponFX_GenericTankShellDetonationSoundName = ExplosionRocketBuggyMissileEnd- ; the flipbook fireball, its hot core and its smoke column in place of EA's BuggyMissileExplosion- ; and its smokeParticleSystem- Name = ReforgedShellFireball- Offset = X:0.0 Y:0.0 Z:4.0- End- ParticleSystem- Name = ReforgedShellFireCore- Offset = X:0.0 Y:0.0 Z:4.0+ Name = BuggyMissileExplosion+ UseCallersRadius = Yes ; Override the radius with the damage radius of the weapon.EndParticleSystem- Name = ReforgedShellSmoke- Offset = X:0.0 Y:0.0 Z:3.0+ Name = BuggyMissileExplosionSmokeEnd; a shell landing throws EA's dirt clods and sparks, which only a tank being struck used to showParticleSystem@@ -229,23 +222,16 @@ FXList FX_GenericTankDeathExplosionParticleSystemName = ReforgedVehicleShrapnelEnd- ; the flipbook fireball, two smaller ones after it and a smoke column, in place of EA's- ; MammothTankExplosionSmoke and MammothTankSubExplosionSmoke- ParticleSystem- Name = ReforgedTankFireball- Offset = X:0.0 Y:0.0 Z:8.0- EndParticleSystem- Name = ReforgedTankFireCore- Offset = X:0.0 Y:0.0 Z:8.0+ Name = MammothTankExplosionSmokeEndParticleSystem- Name = ReforgedShellFireball- Count = 2- Radius = 8 16 UNIFORM- Height = 4 16 UNIFORM- InitialDelay = 167 500 UNIFORM+ Name = MammothTankSubExplosionSmoke+ Radius = 15 30 UNIFORM+ Height = 0 20 UNIFORM+ InitialDelay = 167 667 UNIFORMEnd+ ; a column of dark smoke climbing from the wreck after EA's fireballParticleSystemName = ReforgedTankSmokeOffset = X:0.0 Y:0.0 Z:6.0@@ -3161,28 +3147,16 @@ FXList FX_StructureMediumDeathParticleSystemName = StructureTransitionMediumSmokeEnd- ; the flipbook fireball, two tank-sized ones after it and a smoke column, in place of EA's- ; StructureTransitionMediumExplosion; EA's StructureTransitionMediumFlare is left out, its white- ; flare and light streaks washed the fireball away- ParticleSystem- Name = ReforgedStructureFireball- Offset = X:0.0 Y:0.0 Z:15.0- End- ParticleSystem- Name = ReforgedStructureFireCore- Offset = X:0.0 Y:0.0 Z:15.0- EndParticleSystem- Name = ReforgedTankFireball- Count = 2- Radius = 15 30 UNIFORM- Height = 10 30 UNIFORM- InitialDelay = 250 750 UNIFORM+ Name = StructureTransitionMediumExplosionEnd+ ; a column of dark smoke climbing from the ruin after EA's fireballParticleSystemName = ReforgedStructureSmokeOffset = X:0.0 Y:0.0 Z:10.0End+ ; EA's StructureTransitionMediumFlare is left out: its white flare and light streaks over the+ ; fireball and its hot core turned the whole blast whiteParticleSystemName = StructureTransitionMediumShockwaveEnddiff --git a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.iniindex 0b43c9c76..9af8b3227 100644--- a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini+++ b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini@@ -6474,312 +6474,21 @@ ParticleSystem UpgradeCarpetBombExplosionFireLook = YesEnd-; Flipbook explosions, three sizes: a tank shell landing, a tank dying, a medium building dying-; (FXListReforged.ini). Each is a fireball, a small hot core and a smoke column. The fireball plays-; the 64 frames of ReforgedExplosionFire once over its life, growing, rolling and cooling to soot, so-; the card itself fades and the colour stays white. It is alpha blended and Emissive: drawn-; additively the bodies stacked into cream and white, and as plain alpha the smoke's light and the-; sun's smoke map would shade it. The core is EA's EXexplo03 card, small, brief and additive, the-; only part that blooms. The column is puffs of ReforgedExplosionSmoke, each turning over at its own-; pace from a random frame, two at a time, climbing and swelling. Both pictures come out of-; Tools/explosion_flipbook.py.--ParticleSystem ReforgedShellFireball- Priority = WEAPON_EXPLOSION- IsOneShot = No- Shader = ALPHA- Type = PARTICLE- ParticleName = ReforgedExplosionFire.tga- Emissive = Yes- FlipbookGrid = 8- AngleZ = 0.00 6.28- AngularRateZ = -0.01 0.01- AngularDamping = 0.98 0.99- VelocityDamping = 0.88 0.92- Gravity = 0.00- Lifetime = 40.00 50.00- SystemLifetime = 2- Size = 11.00 14.00- StartSizeRate = 0.00 0.00- SizeRate = 0.08 0.12- SizeRateDamping = 0.97 0.98- Alpha1 = 1.00 1.00 0- Alpha2 = 0.00 0.00 0- Alpha3 = 0.00 0.00 0- Alpha4 = 0.00 0.00 0- Alpha5 = 0.00 0.00 0- Alpha6 = 0.00 0.00 0- Alpha7 = 0.00 0.00 0- Alpha8 = 0.00 0.00 0- Color1 = R:255 G:255 B:255 0- Color2 = R:0 G:0 B:0 0- Color3 = R:0 G:0 B:0 0- Color4 = R:0 G:0 B:0 0- Color5 = R:0 G:0 B:0 0- Color6 = R:0 G:0 B:0 0- Color7 = R:0 G:0 B:0 0- Color8 = R:0 G:0 B:0 0- ColorScale = 0.00 0.00- BurstDelay = 99999.00 99999.00- BurstCount = 2.00 3.00- InitialDelay = 0.00 0.00- DriftVelocity = X:0.00 Y:0.00 Z:0.15- VelocityType = SPHERICAL- VelSpherical = 0.20 0.50- VolumeType = SPHERE- VolSphereRadius = 2.00- IsHollow = No- IsGroundAligned = No- IsEmitAboveGroundOnly = No- IsParticleUpTowardsEmitter = No- WindMotion = Unused- WindAngleChangeMin = 0.149924- WindAngleChangeMax = 0.449946- WindPingPongStartAngleMin = 0.000000- WindPingPongStartAngleMax = 0.785398- WindPingPongEndAngleMin = 5.497787- WindPingPongEndAngleMax = 6.283185-End--ParticleSystem ReforgedShellFireCore- Priority = WEAPON_EXPLOSION- IsOneShot = No- Shader = ADDITIVE- Type = PARTICLE- ParticleName = EXexplo03.tga- AngleZ = 0.00 6.28- AngularRateZ = 0.00 0.00- AngularDamping = 1.00 1.00- VelocityDamping = 1.00 1.00- Gravity = 0.00- Lifetime = 10.00 12.00- SystemLifetime = 2- Size = 5.00 6.00- StartSizeRate = 0.00 0.00- SizeRate = 0.20 0.25- SizeRateDamping = 0.95 0.95- Alpha1 = 1.00 1.00 0- Alpha2 = 0.00 0.00 0- Alpha3 = 0.00 0.00 0- Alpha4 = 0.00 0.00 0- Alpha5 = 0.00 0.00 0- Alpha6 = 0.00 0.00 0- Alpha7 = 0.00 0.00 0- Alpha8 = 0.00 0.00 0- Color1 = R:255 G:190 B:100 0- Color2 = R:190 G:80 B:15 5- Color3 = R:0 G:0 B:0 12- Color4 = R:0 G:0 B:0 0- Color5 = R:0 G:0 B:0 0- Color6 = R:0 G:0 B:0 0- Color7 = R:0 G:0 B:0 0- Color8 = R:0 G:0 B:0 0- ColorScale = 0.00 0.00- BurstDelay = 99999.00 99999.00- BurstCount = 1.00 1.00- InitialDelay = 0.00 0.00- DriftVelocity = X:0.00 Y:0.00 Z:0.00- VelocityType = ORTHO- VelOrthoX = 0.00 0.00- VelOrthoY = 0.00 0.00- VelOrthoZ = 0.00 0.00- VolumeType = POINT- IsHollow = No- IsGroundAligned = No- IsEmitAboveGroundOnly = No- IsParticleUpTowardsEmitter = No- WindMotion = Unused- WindAngleChangeMin = 0.149924- WindAngleChangeMax = 0.449946- WindPingPongStartAngleMin = 0.000000- WindPingPongStartAngleMax = 0.785398- WindPingPongEndAngleMin = 5.497787- WindPingPongEndAngleMax = 6.283185-End--ParticleSystem ReforgedShellSmoke- Priority = WEAPON_EXPLOSION- IsOneShot = No- Shader = ALPHA- Type = PARTICLE- ParticleName = ReforgedExplosionSmoke.tga- FlipbookGrid = 8- FlipbookRate = 10- FlipbookRandomStart = Yes- AngleZ = 0.00 6.28- AngularRateZ = -0.01 0.01- AngularDamping = 0.99 0.99- VelocityDamping = 0.95 0.96- Gravity = 0.00- Lifetime = 90.00 110.00- SystemLifetime = 20- Size = 8.00 11.00- StartSizeRate = 0.00 0.00- SizeRate = 0.35 0.45- SizeRateDamping = 0.985 0.99- Alpha1 = 0.00 0.00 0- Alpha2 = 0.75 0.85 8- Alpha3 = 0.50 0.60 40- Alpha4 = 0.00 0.00 90- Alpha5 = 0.00 0.00 0- Alpha6 = 0.00 0.00 0- Alpha7 = 0.00 0.00 0- Alpha8 = 0.00 0.00 0- Color1 = R:100 G:92 B:86 0- Color2 = R:150 G:142 B:134 80- Color3 = R:0 G:0 B:0 0- Color4 = R:0 G:0 B:0 0- Color5 = R:0 G:0 B:0 0- Color6 = R:0 G:0 B:0 0- Color7 = R:0 G:0 B:0 0- Color8 = R:0 G:0 B:0 0- ColorScale = 0.00 0.00- BurstDelay = 2.00 3.00- BurstCount = 2.00 2.00- InitialDelay = 3.00 3.00- DriftVelocity = X:0.04 Y:0.04 Z:0.45- VelocityType = ORTHO- VelOrthoX = -0.10 0.10- VelOrthoY = -0.10 0.10- VelOrthoZ = 0.90 1.40- VolumeType = CYLINDER- VolCylinderRadius = 2.00- VolCylinderLength = 0.00- IsHollow = No- IsGroundAligned = No- IsEmitAboveGroundOnly = No- IsParticleUpTowardsEmitter = No- WindMotion = Unused- WindAngleChangeMin = 0.149924- WindAngleChangeMax = 0.449946- WindPingPongStartAngleMin = 0.000000- WindPingPongStartAngleMax = 0.785398- WindPingPongEndAngleMin = 5.497787- WindPingPongEndAngleMax = 6.283185-End--ParticleSystem ReforgedTankFireball- Priority = DEATH_EXPLOSION- IsOneShot = No- Shader = ALPHA- Type = PARTICLE- ParticleName = ReforgedExplosionFire.tga- Emissive = Yes- FlipbookGrid = 8- AngleZ = 0.00 6.28- AngularRateZ = -0.01 0.01- AngularDamping = 0.98 0.99- VelocityDamping = 0.88 0.92- Gravity = 0.00- Lifetime = 50.00 60.00- SystemLifetime = 2- Size = 40.00 50.00- StartSizeRate = 0.00 0.00- SizeRate = 0.30 0.40- SizeRateDamping = 0.97 0.98- Alpha1 = 1.00 1.00 0- Alpha2 = 0.00 0.00 0- Alpha3 = 0.00 0.00 0- Alpha4 = 0.00 0.00 0- Alpha5 = 0.00 0.00 0- Alpha6 = 0.00 0.00 0- Alpha7 = 0.00 0.00 0- Alpha8 = 0.00 0.00 0- Color1 = R:255 G:255 B:255 0- Color2 = R:0 G:0 B:0 0- Color3 = R:0 G:0 B:0 0- Color4 = R:0 G:0 B:0 0- Color5 = R:0 G:0 B:0 0- Color6 = R:0 G:0 B:0 0- Color7 = R:0 G:0 B:0 0- Color8 = R:0 G:0 B:0 0- ColorScale = 0.00 0.00- BurstDelay = 99999.00 99999.00- BurstCount = 4.00 5.00- InitialDelay = 0.00 0.00- DriftVelocity = X:0.00 Y:0.00 Z:0.20- VelocityType = SPHERICAL- VelSpherical = 0.50 1.20- VolumeType = SPHERE- VolSphereRadius = 6.00- IsHollow = No- IsGroundAligned = No- IsEmitAboveGroundOnly = No- IsParticleUpTowardsEmitter = No- WindMotion = Unused- WindAngleChangeMin = 0.149924- WindAngleChangeMax = 0.449946- WindPingPongStartAngleMin = 0.000000- WindPingPongStartAngleMax = 0.785398- WindPingPongEndAngleMin = 5.497787- WindPingPongEndAngleMax = 6.283185-End--ParticleSystem ReforgedTankFireCore- Priority = DEATH_EXPLOSION- IsOneShot = No- Shader = ADDITIVE- Type = PARTICLE- ParticleName = EXexplo03.tga- AngleZ = 0.00 6.28- AngularRateZ = 0.00 0.00- AngularDamping = 1.00 1.00- VelocityDamping = 1.00 1.00- Gravity = 0.00- Lifetime = 14.00 16.00- SystemLifetime = 2- Size = 12.00 15.00- StartSizeRate = 0.00 0.00- SizeRate = 0.40 0.50- SizeRateDamping = 0.95 0.95- Alpha1 = 1.00 1.00 0- Alpha2 = 0.00 0.00 0- Alpha3 = 0.00 0.00 0- Alpha4 = 0.00 0.00 0- Alpha5 = 0.00 0.00 0- Alpha6 = 0.00 0.00 0- Alpha7 = 0.00 0.00 0- Alpha8 = 0.00 0.00 0- Color1 = R:255 G:190 B:100 0- Color2 = R:190 G:80 B:15 6- Color3 = R:0 G:0 B:0 16- Color4 = R:0 G:0 B:0 0- Color5 = R:0 G:0 B:0 0- Color6 = R:0 G:0 B:0 0- Color7 = R:0 G:0 B:0 0- Color8 = R:0 G:0 B:0 0- ColorScale = 0.00 0.00- BurstDelay = 99999.00 99999.00- BurstCount = 1.00 1.00- InitialDelay = 0.00 0.00- DriftVelocity = X:0.00 Y:0.00 Z:0.00- VelocityType = ORTHO- VelOrthoX = 0.00 0.00- VelOrthoY = 0.00 0.00- VelOrthoZ = 0.00 0.00- VolumeType = POINT- IsHollow = No- IsGroundAligned = No- IsEmitAboveGroundOnly = No- IsParticleUpTowardsEmitter = No- WindMotion = Unused- WindAngleChangeMin = 0.149924- WindAngleChangeMax = 0.449946- WindPingPongStartAngleMin = 0.000000- WindPingPongStartAngleMax = 0.785398- WindPingPongEndAngleMin = 5.497787- WindPingPongEndAngleMax = 6.283185-End+; The smoke column a tank's or a medium building's death leaves climbing after EA's fireball+; (FX_GenericTankDeathExplosion and FX_StructureMediumDeath in FXListReforged.ini): puffs of EA's+; dark EXSmokNew1, two at a time, rising and swelling into one plume. From v3.3.0 to v3.4.1 these+; two blasts and a shell's landing drew a raymarched flipbook fireball and smoke instead of EA's+; fireball; the fireball was one smooth, opaque, slowly swelling orange ball and each smoke puff the+; same hard-edged round blob, so a building going down looked like modelling clay and cotton wool.+; EA's photographed fireballs are back, and the column kept its shape on EA's soft smoke. EXCloud01+; was tried first: its alpha is too thin for a column, which all but vanished.ParticleSystem ReforgedTankSmokePriority = DEATH_EXPLOSIONIsOneShot = NoShader = ALPHAType = PARTICLE- ParticleName = ReforgedExplosionSmoke.tga- FlipbookGrid = 8- FlipbookRate = 10- FlipbookRandomStart = Yes+ ParticleName = EXSmokNew1.tgaAngleZ = 0.00 6.28AngularRateZ = -0.01 0.01AngularDamping = 0.99 0.99@@ -6799,8 +6508,8 @@ ParticleSystem ReforgedTankSmokeAlpha6 = 0.00 0.00 0Alpha7 = 0.00 0.00 0Alpha8 = 0.00 0.00 0- Color1 = R:90 G:82 B:76 0- Color2 = R:145 G:138 B:130 120+ Color1 = R:170 G:158 B:146 0+ Color2 = R:215 G:208 B:200 120Color3 = R:0 G:0 B:0 0Color4 = R:0 G:0 B:0 0Color5 = R:0 G:0 B:0 0@@ -6832,128 +6541,12 @@ ParticleSystem ReforgedTankSmokeWindPingPongEndAngleMax = 6.283185End-ParticleSystem ReforgedStructureFireball- Priority = DEATH_EXPLOSION- IsOneShot = No- Shader = ALPHA- Type = PARTICLE- ParticleName = ReforgedExplosionFire.tga- Emissive = Yes- FlipbookGrid = 8- AngleZ = 0.00 6.28- AngularRateZ = -0.01 0.01- AngularDamping = 0.98 0.99- VelocityDamping = 0.88 0.92- Gravity = 0.00- Lifetime = 60.00 75.00- SystemLifetime = 2- Size = 80.00 100.00- StartSizeRate = 0.00 0.00- SizeRate = 0.40 0.60- SizeRateDamping = 0.97 0.98- Alpha1 = 1.00 1.00 0- Alpha2 = 0.00 0.00 0- Alpha3 = 0.00 0.00 0- Alpha4 = 0.00 0.00 0- Alpha5 = 0.00 0.00 0- Alpha6 = 0.00 0.00 0- Alpha7 = 0.00 0.00 0- Alpha8 = 0.00 0.00 0- Color1 = R:255 G:255 B:255 0- Color2 = R:0 G:0 B:0 0- Color3 = R:0 G:0 B:0 0- Color4 = R:0 G:0 B:0 0- Color5 = R:0 G:0 B:0 0- Color6 = R:0 G:0 B:0 0- Color7 = R:0 G:0 B:0 0- Color8 = R:0 G:0 B:0 0- ColorScale = 0.00 0.00- BurstDelay = 99999.00 99999.00- BurstCount = 6.00 8.00- InitialDelay = 0.00 0.00- DriftVelocity = X:0.00 Y:0.00 Z:0.30- VelocityType = SPHERICAL- VelSpherical = 0.80 1.60- VolumeType = SPHERE- VolSphereRadius = 14.00- IsHollow = No- IsGroundAligned = No- IsEmitAboveGroundOnly = No- IsParticleUpTowardsEmitter = No- WindMotion = Unused- WindAngleChangeMin = 0.149924- WindAngleChangeMax = 0.449946- WindPingPongStartAngleMin = 0.000000- WindPingPongStartAngleMax = 0.785398- WindPingPongEndAngleMin = 5.497787- WindPingPongEndAngleMax = 6.283185-End--ParticleSystem ReforgedStructureFireCore- Priority = DEATH_EXPLOSION- IsOneShot = No- Shader = ADDITIVE- Type = PARTICLE- ParticleName = EXexplo03.tga- AngleZ = 0.00 6.28- AngularRateZ = 0.00 0.00- AngularDamping = 1.00 1.00- VelocityDamping = 1.00 1.00- Gravity = 0.00- Lifetime = 18.00 20.00- SystemLifetime = 2- Size = 25.00 30.00- StartSizeRate = 0.00 0.00- SizeRate = 0.70 0.90- SizeRateDamping = 0.95 0.95- Alpha1 = 1.00 1.00 0- Alpha2 = 0.00 0.00 0- Alpha3 = 0.00 0.00 0- Alpha4 = 0.00 0.00 0- Alpha5 = 0.00 0.00 0- Alpha6 = 0.00 0.00 0- Alpha7 = 0.00 0.00 0- Alpha8 = 0.00 0.00 0- Color1 = R:255 G:190 B:100 0- Color2 = R:190 G:80 B:15 7- Color3 = R:0 G:0 B:0 20- Color4 = R:0 G:0 B:0 0- Color5 = R:0 G:0 B:0 0- Color6 = R:0 G:0 B:0 0- Color7 = R:0 G:0 B:0 0- Color8 = R:0 G:0 B:0 0- ColorScale = 0.00 0.00- BurstDelay = 99999.00 99999.00- BurstCount = 1.00 1.00- InitialDelay = 0.00 0.00- DriftVelocity = X:0.00 Y:0.00 Z:0.00- VelocityType = ORTHO- VelOrthoX = 0.00 0.00- VelOrthoY = 0.00 0.00- VelOrthoZ = 0.00 0.00- VolumeType = POINT- IsHollow = No- IsGroundAligned = No- IsEmitAboveGroundOnly = No- IsParticleUpTowardsEmitter = No- WindMotion = Unused- WindAngleChangeMin = 0.149924- WindAngleChangeMax = 0.449946- WindPingPongStartAngleMin = 0.000000- WindPingPongStartAngleMax = 0.785398- WindPingPongEndAngleMin = 5.497787- WindPingPongEndAngleMax = 6.283185-End-ParticleSystem ReforgedStructureSmokePriority = DEATH_EXPLOSIONIsOneShot = NoShader = ALPHAType = PARTICLE- ParticleName = ReforgedExplosionSmoke.tga- FlipbookGrid = 8- FlipbookRate = 8- FlipbookRandomStart = Yes+ ParticleName = EXSmokNew1.tgaAngleZ = 0.00 6.28AngularRateZ = -0.01 0.01AngularDamping = 0.99 0.99@@ -6973,8 +6566,8 @@ ParticleSystem ReforgedStructureSmokeAlpha6 = 0.00 0.00 0Alpha7 = 0.00 0.00 0Alpha8 = 0.00 0.00 0- Color1 = R:90 G:82 B:76 0- Color2 = R:150 G:142 B:134 160+ Color1 = R:170 G:158 B:146 0+ Color2 = R:215 G:208 B:200 160Color3 = R:0 G:0 B:0 0Color4 = R:0 G:0 B:0 0Color5 = R:0 G:0 B:0 0diff --git a/GeneralsMD/Code/Data/Scenarios/explfx.txt b/GeneralsMD/Code/Data/Scenarios/explfx.txtindex 7a9d5c18e..293c09420 100644--- a/GeneralsMD/Code/Data/Scenarios/explfx.txt+++ b/GeneralsMD/Code/Data/Scenarios/explfx.txt@@ -1,5 +1,5 @@-# Footage of the flipbook explosions (ReforgedExplosionFire/Smoke in ParticleSystemReforged.ini) on-# Twilight Flame, close: tank shells bursting (WeaponFX_GenericTankShellDetonation), tanks dying+# Footage of the explosions (FXListReforged.ini; the flipbook ones of v3.3.0 to v3.4.1 against EA's+# fireballs in experiments/proofs/2026-10-25/explosions) on Twilight Flame, close: tank shells bursting (WeaponFX_GenericTankShellDetonation), tanks dying# (FX_GenericTankDeathExplosion) and medium buildings falling (FX_StructureMediumDeath). An American# base at start 0 (537,3188) on the firelook spots; Crusaders and Paladins meet Battlemasters and# Overlords east of it, while a second Overlord group shells the barracks and the War Factory.diff --git a/GeneralsMD/Code/Tools/explosion_flipbook.py b/GeneralsMD/Code/Tools/explosion_flipbook.pydeleted file mode 100644index 86e194dd3..000000000--- a/GeneralsMD/Code/Tools/explosion_flipbook.py+++ /dev/null@@ -1,392 +0,0 @@-"""The two flipbooks the Reforged explosions play (ParticleSystemReforged.ini, FlipbookGrid): a-fireball that grows, rolls and cools over its 64 frames, and a dark smoke puff that turns over once-in 64 frames, so it loops without a seam.--Both are raymarched through a noise volume. The fireball is a sphere whose surface is pushed out by-billowed noise (the sum of folded octaves, which gives round lobes with creases between them) that-rises and swells with the sphere; a temperature falls from the core outwards and with time, and runs-a ramp from yellow through saturated deep orange and red to soot. It is alpha blended (stacked-additively it went to cream and white), so its colour is the ramp itself, never past it, and the late-frames turn to dark soot as the alpha thins. The smoke is the same kind of sphere rotated rigidly-about a horizontal axis and lit from above by three density reads towards the light. Both are DXT5-with straight alpha.-- python Tools/explosion_flipbook.py- writes Data/Art/Textures/ReforgedExplosionFire.dds (8 by 8 frames of 256 pixels) and- Data/Art/Textures/ReforgedExplosionSmoke.dds (8 by 8 frames of 128 pixels).- python Tools/explosion_flipbook.py preview <folder>- also writes both atlases as PNG there, the fireball on black and the smoke on grey.- python Tools/explosion_flipbook.py selfcheck--Same bytes on every run: the noise comes from a seeded generator and nothing else varies. Nothing is-drawn past REACH of a frame's half width, a margin of 13 pixels at 128, and every mip level has the-outermost texel ring of each frame cleared to nothing. The chain runs two levels past 8-pixel frames-because DDSFileClass drops a file's two smallest levels, so the game's own chain ends there. So neither-the bilinear filter nor a small mip pulls the neighbouring frame onto a quad's edge, which drew hard-lines round the smoke in game."""-import os-import struct-import sys--import numpy as np-from scipy import ndimage--HERE = os.path.dirname(os.path.abspath(__file__))-OUT_FOLDER = os.path.join(HERE, "..", "Data", "Art", "Textures")-FIRE_NAME = "ReforgedExplosionFire.dds"-SMOKE_NAME = "ReforgedExplosionSmoke.dds"--GRID = 8 # frames a side: ParticleSystemReforged.ini's FlipbookGrid-FRAMES = GRID * GRID-FIRE_CELL = 256-SMOKE_CELL = 128-STEPS = 64 # samples along each ray through the unit cube-SEED = 1987-REACH = 0.80 # nothing is drawn past this radius, which keeps every frame's border empty-SMALLEST_CELL = 8 # the smallest mip the game loads has frames this many pixels a side-THROWAWAY_LEVELS = 2 # levels below it, which DDSFileClass drops on load (ddsfile.cpp)--NOISE_SIZE = 128 # the noise volume's side, periodic-NOISE_OCTAVES = (4, 8, 16, 32, 64) # lattice cells a side for each octave-VOXELS_PER_UNIT = 30.0 # how much noise one unit of the cube spans--# The fireball. Radii are in the cube's half width, so 1 touches the frame's edge.-FIRE_RADIUS_START = 0.25-FIRE_RADIUS_END = 0.46-FIRE_BILLOW = 0.70 # how far the billows push the surface, as a share of the radius-FIRE_LOBE_SCALE = 0.75 # below 1 makes the billows bigger-FIRE_CREASE = 0.9 # how much cooler the creases between billows burn than the lobes-FIRE_RISE = 0.9 # noise units the billows climb over the life-FIRE_SWIRL = 0.6 # radians the billows turn about the vertical over the life-FIRE_ABSORB = 16.0 # optical depth of one unit of full density-# Yellow, orange, saturated deep orange, red, soot: (temperature, linear colour). No white: the-# hottest is a yellow, so the body never reads cream however it is lit.-FIRE_RAMP = (- (0.00, (0.035, 0.025, 0.020)),- (0.20, (0.22, 0.05, 0.015)),- (0.40, (0.70, 0.17, 0.020)),- (0.60, (0.98, 0.38, 0.035)),- (0.80, (1.00, 0.60, 0.090)),- (1.00, (1.00, 0.80, 0.280)),-)--SMOKE_RADIUS = 0.48-SMOKE_BILLOW = 0.65-SMOKE_SOFT = 0.35 # the depth over which the edge thickens to full, as a share of the radius-SMOKE_ABSORB = 14.0-SMOKE_DARK = 0.04 # linear grey on the shadowed side-SMOKE_LIT = 0.62 # linear grey on the side towards the light-SMOKE_LIGHT_STEP = 0.08 # spacing of the three reads towards the light-SMOKE_LIGHT_ABSORB = 1.6 # how much those reads darken the sample---def noise_volumes():- """Two periodic noise volumes, both NOISE_SIZE a side: billowed (the shape) and plain fBm (the- temperature and the domain warp)."""- rng = np.random.default_rng(SEED)- billow = np.zeros((NOISE_SIZE,) * 3, np.float32)- smooth = np.zeros((NOISE_SIZE,) * 3, np.float32)- amplitude = 1.0- total = 0.0- for cells in NOISE_OCTAVES:- for target, fold in ((billow, True), (smooth, False)):- lattice = rng.random((cells,) * 3, dtype=np.float32)- octave = ndimage.zoom(lattice, NOISE_SIZE / cells, order=3, mode="grid-wrap", grid_mode=True)- target += amplitude * (np.abs(octave * 2.0 - 1.0) if fold else octave)- total += amplitude- amplitude *= 0.5- return billow / total, smooth / total---def sample(volume, points):- """The volume at points (n, 3) in noise units, trilinear and wrapping."""- coordinates = (points * VOXELS_PER_UNIT).T- return ndimage.map_coordinates(volume, coordinates, order=1, mode="grid-wrap", prefilter=False)---def cube_points(cell):- """Every sample of an orthographic view down -z through the cube [-1, 1]^3: (cell, cell, STEPS, 3),- row 0 at the top (y = 1), the first step nearest the eye (z = 1)."""- axis = (np.arange(cell, dtype=np.float32) + 0.5) / cell * 2.0 - 1.0- depth = 1.0 - (np.arange(STEPS, dtype=np.float32) + 0.5) / STEPS * 2.0- y, x, z = np.meshgrid(-axis, axis, depth, indexing="ij")- return np.stack((x, y, z), axis=-1)---def ramp(temperature):- keys = np.array([key for key, _ in FIRE_RAMP], np.float32)- colours = np.array([colour for _, colour in FIRE_RAMP], np.float32)- return np.stack([np.interp(temperature, keys, colours[:, c]) for c in range(3)], axis=-1)---def composite(density, emission):- """Front to back along the steps: density (h, w, s) as optical depth a step, emission (h, w, s, 3).- Returns the premultiplied colour and the alpha."""- colour = np.zeros(density.shape[:2] + (3,), np.float32)- transmit = np.ones(density.shape[:2], np.float32)- for step in range(density.shape[2]):- absorbed = 1.0 - np.exp(-density[:, :, step])- colour += (transmit * absorbed)[..., None] * emission[:, :, step]- transmit *= 1.0 - absorbed- return colour, 1.0 - transmit---def fire_frame(index, points, radius_of_point, billow, smooth):- t = index / (FRAMES - 1.0)- radius = FIRE_RADIUS_START + (FIRE_RADIUS_END - FIRE_RADIUS_START) * (1.0 - (1.0 - t) ** 2.5)- reach = min(radius * (1.0 + FIRE_BILLOW), REACH)- inside = radius_of_point < reach- p = points[inside]- # The billows swell with the sphere, climb and turn slowly about the vertical.- angle = FIRE_SWIRL * t- cos, sin = np.cos(angle), np.sin(angle)- q = p / np.float32(radius ** 0.6)- q = np.stack((q[:, 0] * cos - q[:, 2] * sin, q[:, 1] - FIRE_RISE * t, q[:, 0] * sin + q[:, 2] * cos), axis=-1)- warp = sample(smooth, q * 0.7 + 11.0) - 0.5- q = q + warp[:, None] * 0.6- shape = sample(billow, q * FIRE_LOBE_SCALE)- r = radius_of_point[inside]- surface = radius * (1.0 - FIRE_BILLOW * 0.55 + FIRE_BILLOW * shape * 1.6)- # Late in the life the cloud thins from the inside out and the last frames empty.- thin = np.clip((t - 0.55) / 0.45, 0.0, 1.0)- solid = np.clip((surface - r) / (0.06 * radius), 0.0, 1.0) * (1.0 - thin * thin)- solid *= np.clip(1.0 - thin * 1.2 + shape * 1.2 * thin, 0.0, 1.0)- # Hot in the core and early; the creases between billows run cooler than the lobes.- heat = 1.25 - 1.2 * t ** 0.8- temperature = heat * (0.45 + 0.55 * np.clip(1.0 - r / surface, 0.0, 1.0) ** 0.5)- temperature += (shape - 0.5) * FIRE_CREASE + (sample(smooth, q * 1.9 + 37.0) - 0.5) * 0.4- temperature = np.clip(temperature, 0.0, 1.0)- # The glow dies with the cloud: what is left late is soot.- temperature *= (1.0 - thin) ** 1.5-- density = np.zeros(points.shape[:3], np.float32)- emission = np.zeros(points.shape[:3] + (3,), np.float32)- density[inside] = solid * (FIRE_ABSORB * 2.0 / STEPS)- emission[inside] = ramp(temperature)- colour, alpha = composite(density, emission)- # Straight alpha, black where nothing is, so the filter darkens the edge a little and never- # brightens it; then the gamma the game's textures are painted in.- straight = np.where(alpha[..., None] > 1e-3, colour / np.maximum(alpha[..., None], 1e-3), 0.0)- straight = np.clip(straight, 0.0, 1.0) ** (1.0 / 2.2)- return np.concatenate((straight, alpha[..., None]), axis=-1)---def smoke_frame(index, points, radius_of_point, billow, smooth):- angle = 2.0 * np.pi * index / FRAMES- cos, sin = np.cos(angle), np.sin(angle)- reach = min(SMOKE_RADIUS * (1.0 + SMOKE_BILLOW), REACH)- inside = radius_of_point < reach- p = points[inside]-- def solid_at(at):- # Turned rigidly about the x axis: a whole turn in FRAMES, so frame FRAMES is frame 0.- q = np.stack((at[:, 0], at[:, 1] * cos - at[:, 2] * sin, at[:, 1] * sin + at[:, 2] * cos), axis=-1)- warp = sample(smooth, q * 0.7 + 23.0) - 0.5- shape = sample(billow, q * 1.3 + warp[:, None] * 0.5 + 5.0)- r = np.sqrt((at * at).sum(axis=-1))- surface = SMOKE_RADIUS * (1.0 - SMOKE_BILLOW * 0.55 + SMOKE_BILLOW * shape * 1.6)- return np.clip((surface - r) / (SMOKE_SOFT * SMOKE_RADIUS), 0.0, 1.0) ** 1.5-- solid = solid_at(p)- # Lit from above and a little from the front: the smoke between the sample and the light shades- # it, so the top of each billow is pale and the underside and the creases go dark.- toward = np.array([0.25, 0.9, 0.35], np.float32)- toward /= np.sqrt((toward * toward).sum())- blocked = sum(solid_at(p + toward * (SMOKE_LIGHT_STEP * k)) for k in (1, 2, 3))- light = np.exp(-SMOKE_LIGHT_ABSORB * blocked)- grey = SMOKE_DARK + (SMOKE_LIT - SMOKE_DARK) * light-- density = np.zeros(points.shape[:3], np.float32)- emission = np.zeros(points.shape[:3] + (3,), np.float32)- density[inside] = solid * (SMOKE_ABSORB * 2.0 / STEPS)- emission[inside] = np.repeat(grey[:, None], 3, axis=1)- colour, alpha = composite(density, emission)- # Straight alpha; where nothing is, the colour the edge would have, so the filter brings no fringe.- straight = np.where(alpha[..., None] > 1e-3, colour / np.maximum(alpha[..., None], 1e-3), SMOKE_DARK)- straight = np.clip(straight, 0.0, 1.0) ** (1.0 / 2.2)- return np.concatenate((straight, alpha[..., None]), axis=-1)---def atlas(render, cell, channels, billow, smooth):- points = cube_points(cell)- radius_of_point = np.sqrt((points * points).sum(axis=-1))- image = np.zeros((GRID * cell, GRID * cell, channels), np.float32)- for index in range(FRAMES):- row, column = divmod(index, GRID)- image[row * cell:(row + 1) * cell, column * cell:(column + 1) * cell] = render(index, points, radius_of_point, billow, smooth)- return image---# ----------------------------------------------------------------------------------------------# DDS, DXT5. Colour endpoints on each block's principal axis, inset by a sixteenth, indices to the-# nearest palette entry. Plain, but enough for soft fire and smoke.--def to565(rgb):- r = np.round(rgb[..., 0] * 31.0 / 255.0).astype(np.uint32)- g = np.round(rgb[..., 1] * 63.0 / 255.0).astype(np.uint32)- b = np.round(rgb[..., 2] * 31.0 / 255.0).astype(np.uint32)- return (r << 11) | (g << 5) | b---def from565(c):- r = (c >> 11) & 31- g = (c >> 5) & 63- b = c & 31- return np.stack(((r << 3) | (r >> 2), (g << 2) | (g >> 4), (b << 3) | (b >> 2)), axis=-1).astype(np.float32)---def blocks(image):- h, w, c = image.shape- return image.reshape(h // 4, 4, w // 4, 4, c).transpose(0, 2, 1, 3, 4).reshape(-1, 16, c)---def colour_blocks(rgb):- """rgb (n, 16, 3) in 0..255: n DXT colour blocks, always in four colour mode."""- # Endpoints on the block's principal axis, which the box corners miss when the channels run- # opposite ways.- mean = rgb.mean(axis=1, keepdims=True)- centred = rgb - mean- axis = np.linalg.eigh(np.einsum("nki,nkj->nij", centred, centred))[1][:, :, 2]- along = np.einsum("nki,ni->nk", centred, axis)- low = np.clip(mean[:, 0] + axis * along.min(axis=1, keepdims=True), 0.0, 255.0)- high = np.clip(mean[:, 0] + axis * along.max(axis=1, keepdims=True), 0.0, 255.0)- inset = (high - low) / 16.0- c0 = to565(high - inset)- c1 = to565(low + inset)- swap = c0 < c1- c0, c1 = np.where(swap, c1, c0), np.where(swap, c0, c1)- p0 = from565(c0)- p1 = from565(c1)- palette = np.stack((p0, p1, (2.0 * p0 + p1) / 3.0, (p0 + 2.0 * p1) / 3.0), axis=1)- distance = ((rgb[:, :, None, :] - palette[:, None, :, :]) ** 2).sum(axis=-1)- index = distance.argmin(axis=-1).astype(np.uint32)- index[c0 == c1] = 0- bits = (index << (2 * np.arange(16, dtype=np.uint32))).sum(axis=1, dtype=np.uint64).astype(np.uint32)- out = np.zeros((rgb.shape[0], 8), np.uint8)- out[:, 0:2] = c0.astype("<u2").view(np.uint8).reshape(-1, 2)- out[:, 2:4] = c1.astype("<u2").view(np.uint8).reshape(-1, 2)- out[:, 4:8] = bits.astype("<u4").view(np.uint8).reshape(-1, 4)- return out---def alpha_blocks(alpha):- """alpha (n, 16) in 0..255: n DXT5 alpha blocks, in eight value mode."""- a0 = alpha.max(axis=1).round().astype(np.uint32)- a1 = alpha.min(axis=1).round().astype(np.uint32)- weights = np.array([0, 7, 1, 2, 3, 4, 5, 6], np.float32) # palette entry i is a0 + (a1 - a0) * weight / 7- palette = a0[:, None] + (a1[:, None].astype(np.float32) - a0[:, None]) * weights / 7.0- palette = np.floor(palette + 0.5)- index = np.abs(alpha[:, :, None] - palette[:, None, :]).argmin(axis=-1).astype(np.uint64)- index[a0 == a1] = 0- bits = (index << (3 * np.arange(16, dtype=np.uint64))).sum(axis=1, dtype=np.uint64)- out = np.zeros((alpha.shape[0], 8), np.uint8)- out[:, 0] = a0- out[:, 1] = a1- out[:, 2:8] = bits.astype("<u8").view(np.uint8).reshape(-1, 8)[:, :6]- return out---def clear_cell_rings(level, cell):- """Every frame's outermost ring of texels emptied, so a quad's edge samples nothing."""- alpha = level[..., 3]- for edge in range(0, level.shape[0], cell):- alpha[edge, :] = alpha[edge + cell - 1, :] = 0.0- alpha[:, edge] = alpha[:, edge + cell - 1] = 0.0- return level---def mips(image, cell):- """The chain down to frames SMALLEST_CELL pixels a side and THROWAWAY_LEVELS more for the loader- to drop, each level the box average of the one above with the colour weighted by its alpha, and- every level's frame rings cleared."""- levels = [clear_cell_rings(image.copy(), cell)]- while cell > SMALLEST_CELL >> THROWAWAY_LEVELS:- top = levels[-1]- weighted = np.concatenate((top[..., :3] * top[..., 3:], top[..., 3:]), axis=-1)- h, w, c = weighted.shape- level = weighted.reshape(h // 2, 2, w // 2, 2, c).mean(axis=(1, 3))- alpha = level[..., 3:]- level = np.concatenate((np.where(alpha > 1e-4, level[..., :3] / np.maximum(alpha, 1e-4), 0.0), alpha), axis=-1)- cell //= 2- levels.append(clear_cell_rings(level, cell))- return levels---def dds(image, cell):- """image (h, w, 4) in 0..1, straight alpha, frames cell pixels a side, as a DXT5 DDS file's bytes- with its mips."""- levels = mips(image, cell)- payload = []- for level in levels:- if level.shape[0] < 4: # a level under one block is stored as a whole block- level = np.pad(level, ((0, 4 - level.shape[0]), (0, 4 - level.shape[1]), (0, 0)), mode="edge")- texels = blocks(np.clip(np.round(level * 255.0), 0.0, 255.0))- payload.append(np.concatenate((alpha_blocks(texels[:, :, 3]), colour_blocks(texels[:, :, :3])), axis=1).tobytes())- h, w = image.shape[:2]- flags = 0x1 | 0x2 | 0x4 | 0x1000 | 0x20000 | 0x80000 # caps, height, width, pixel format, mip count, linear size- header = b"DDS " + struct.pack("<7I", 124, flags, h, w, len(payload[0]), 0, len(levels)) + bytes(44)- header += struct.pack("<2I4s5I", 32, 0x4, b"DXT5", 0, 0, 0, 0, 0)- header += struct.pack("<5I", 0x8 | 0x1000 | 0x400000, 0, 0, 0, 0) # complex, texture, mipmap- assert len(header) == 128- return header + b"".join(payload)---def decode_colour_block(block):- c0, c1, bits = struct.unpack("<HHI", bytes(block))- p0 = from565(np.uint32(c0))- p1 = from565(np.uint32(c1))- palette = (p0, p1, (2 * p0 + p1) / 3, (p0 + 2 * p1) / 3)- return np.array([palette[(bits >> (2 * i)) & 3] for i in range(16)])---def selfcheck():- # A block on one line between two colours, the case DXT is built for, comes back close.- rng = np.random.default_rng(3)- ends = rng.random((5, 2, 3)) * 255.0- along = np.linspace(0.0, 1.0, 16)[None, :, None]- rgb = ends[:, :1] * (1.0 - along) + ends[:, 1:] * along- rgb[0] = 128.0 # a flat block takes index 0 throughout- encoded = colour_blocks(rgb)- for block, source in zip(encoded, rgb):- assert np.abs(decode_colour_block(block) - source).max() < 32.0- assert struct.unpack("<I", bytes(encoded[0][4:8]))[0] == 0- alpha = np.tile(np.linspace(0.0, 255.0, 16), (2, 1))- alpha[1] = 77.0- coded = alpha_blocks(alpha)- assert coded[0][0] == 255 and coded[0][1] == 0 and coded[1][0] == coded[1][1] == 77- assert not coded[1][2:].any()- tiny = dds(np.zeros((8, 8, 4), np.float32), 8)- assert len(tiny) == 128 + 4 * 16 + 16 + 16 and tiny[:4] == b"DDS "- # A solid atlas: the chain runs to 8-pixel frames plus two levels for the loader to drop, and- # every level it keeps has its frames' rings empty and their insides full.- levels = mips(np.ones((64, 64, 4), np.float32), 32)- assert [level.shape[0] for level in levels] == [64, 32, 16, 8, 4]- for level, cell in zip(levels[:-THROWAWAY_LEVELS], (32, 16, 8)):- assert not level[::cell, :, 3].any() and not level[cell - 1::cell, :, 3].any()- assert level[cell // 2, cell // 2, 3] > 0.0---def main():- selfcheck()- if sys.argv[1:2] == ["selfcheck"]:- return- billow, smooth = noise_volumes()- fire = atlas(fire_frame, FIRE_CELL, 4, billow, smooth)- smoke = atlas(smoke_frame, SMOKE_CELL, 4, billow, smooth)- for name, image, cell in ((FIRE_NAME, fire, FIRE_CELL), (SMOKE_NAME, smoke, SMOKE_CELL)):- path = os.path.normpath(os.path.join(OUT_FOLDER, name))- with open(path, "wb") as out:- out.write(dds(image, cell))- print(path)- if sys.argv[1:2] == ["preview"]:- from PIL import Image- folder = sys.argv[2]- # Both over a desert sand, the ground they are mostly seen against.- sand = np.array([0.62, 0.50, 0.33], np.float32)- for name, image in (("fire.png", fire), ("smoke.png", smoke)):- over = image[..., :3] * image[..., 3:] + sand * (1.0 - image[..., 3:])- Image.fromarray(np.uint8(over * 255.0 + 0.5)).save(os.path.join(folder, name))---if __name__ == "__main__":- main()