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(ww3d2): fire burns instead of fading on direct3d 11

Olcay Seygan9ff520d4616f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 439ef8157..1ff33d8fe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1601,6 +1601,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
- An explosion lights everything around it, smoothly. On the default renderer the light of a blast reaches every tank, soldier, building and patch of ground it can see, fading out with distance, where the ground used to brighten in blocky squares and a model took only four lights at once, so in a big fight half the tanks next to a burning wreck stayed dark. The 32 blasts nearest the camera light at the same time, and a wall with its back to the fire stays in shadow. The light brightens what it falls on by three quarters at most: a nuke's took the ground to white within a few frames until it was held there.
- 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.
- 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/Data/Cinema/firelook.txt b/GeneralsMD/Code/Data/Cinema/firelook.txt
new file mode 100644
index 000000000..6601e70a3
--- /dev/null
+++ b/GeneralsMD/Code/Data/Cinema/firelook.txt
@@ -0,0 +1,18 @@
+# Scenarios/firelook.txt filmed close, for the Direct3D 11 fire look against -d3d9 (command line in
+# the scenario's header, -video 420 1620). Three takes round 650,3330 on Twilight Flame: the Dragons
+# flaming the Rangers with the barracks going up behind, the Inferno firestorms over the base, and
+# the fire walls and burning wrecks after the tank fight.
+
+7.0 cut 660 3320 0.8 90 0
+7.1 zoom 0.6 6
+7.1 orbit 30 6.4
+
+13.5 cut 600 3420 0.65 160 -2
+13.6 zoom 0.55 6.8
+13.6 orbit -25 6.8
+
+20.5 cut 640 3250 0.7 60 -4
+20.6 zoom 0.58 6.4
+20.6 orbit 20 6.4
+
+27.2 end
diff --git a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini
index 58a0c41ff..6e042dd9f 100644
--- a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini
+++ b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini
@@ -1,5 +1,7 @@
; Zero Hour Reforged particle systems, loaded after ParticleSystem.ini. A name EA already defined
-; is replaced whole; a new name is added. Particle systems are not in the multiplayer checksum.
+; is edited in place, so a block that lists every field replaces it whole and one that names a
+; single field changes that field alone (the fire look list near the end); a new name is added.
+; Particle systems are not in the multiplayer checksum.
; The Superweapon General's Particle Cannon fires a pink beam and wore EA's blue ready-to-fire glow
; and blue death flare. These are EA's three systems with the pink of his beam, after the 1.04
@@ -5732,6 +5734,746 @@ ParticleSystem ReforgedShrapnelFlame
WindPingPongEndAngleMax = 6.283185
End
+; ----------------------------------------------------------------------------------------------
+; The fire look. Under Direct3D 11 the billboards of these systems run a temperature ramp over each
+; particle's life, white through yellow, orange and red to soot, burn away from their thin edges in
+; rather than only fading flat, and flicker where two noise fields bend the card's texture. -d3d9
+; and the Classic graphics setting draw them as before. A block that names a system already defined
+; edits it in place, so these name FireLook alone and every other field stays retail's, a mod's or
+; the fork's own block above. The list is every billboarded additive or alpha system drawn with
+; EA's flame and fireball textures (EXExplo, EXFire, EXFireball, EXFThrower, EXSmolderingFire),
+; less the green fires of toxin and anthrax and the Particle Cannon's, which the ramp would turn
+; orange, and less muzzle flashes, sparks and embers, gone before a ramp shows.
+; ----------------------------------------------------------------------------------------------
+
+ParticleSystem airCarrierDeckFire
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierDeckFireBig
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierDeckFireJet5
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierDeckFireJet6
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierDeckFireJet7
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierExplosion0
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierExplosion1
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierExplosion2
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierFinalExplosion
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierHotPillarArms
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierJet01Explosion
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierJetExplosion1
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierJetExplosion2
+ FireLook = Yes
+End
+
+ParticleSystem airCarrierJetExplosion3
+ FireLook = Yes
+End
+
+ParticleSystem AirF_AuroraBombExplosion
+ FireLook = Yes
+End
+
+ParticleSystem AirF_AuroraBombFlameShockwave
+ FireLook = Yes
+End
+
+ParticleSystem APSBlastFlash
+ FireLook = Yes
+End
+
+ParticleSystem AutoFireLarge01
+ FireLook = Yes
+End
+
+ParticleSystem AutoFireMedium01
+ FireLook = Yes
+End
+
+ParticleSystem AutoFireSmall01
+ FireLook = Yes
+End
+
+ParticleSystem BattleDroneExplosion
+ FireLook = Yes
+End
+
+ParticleSystem BattleMasterTransitionExplosion
+ FireLook = Yes
+End
+
+ParticleSystem BattleMasterTransitionExplosionSmall
+ FireLook = Yes
+End
+
+ParticleSystem BlackNapalm
+ FireLook = Yes
+End
+
+ParticleSystem BombTruckDefaultExplosion
+ FireLook = Yes
+End
+
+ParticleSystem BombTruckDefaultExplosionTrail
+ FireLook = Yes
+End
+
+ParticleSystem BombTruckHEExplosion
+ FireLook = Yes
+End
+
+ParticleSystem BombTruckHEExplosionTrail
+ FireLook = Yes
+End
+
+ParticleSystem boobyTrapExplosion
+ FireLook = Yes
+End
+
+ParticleSystem BuggyExplosion
+ FireLook = Yes
+End
+
+ParticleSystem BuggyExplosionAirDeathAirPart
+ FireLook = Yes
+End
+
+ParticleSystem BuggyFire
+ FireLook = Yes
+End
+
+ParticleSystem BuggyMissileExplosion
+ FireLook = Yes
+End
+
+ParticleSystem BuggyNewAirDeathExplosionAirPart
+ FireLook = Yes
+End
+
+ParticleSystem BuggyNewAirDeathExplosionFlameSlave
+ FireLook = Yes
+End
+
+ParticleSystem BuggyNewAirDeathSubExplosionFlameSlave
+ FireLook = Yes
+End
+
+ParticleSystem BuggyNewExplosionArmsFlame
+ FireLook = Yes
+End
+
+ParticleSystem BuggyNewExplosionFlameSlave
+ FireLook = Yes
+End
+
+ParticleSystem BuggyNewSubExplosionFlameSlave
+ FireLook = Yes
+End
+
+ParticleSystem BuggySubExplosion
+ FireLook = Yes
+End
+
+ParticleSystem ComancheTransitionExplosion1
+ FireLook = Yes
+End
+
+ParticleSystem DaisyExplosion
+ FireLook = Yes
+End
+
+ParticleSystem DaisyFlameShockwave
+ FireLook = Yes
+End
+
+ParticleSystem Demo_BombTruckDefaultExplosion
+ FireLook = Yes
+End
+
+ParticleSystem Demo_BombTruckDefaultExplosionTrail
+ FireLook = Yes
+End
+
+ParticleSystem Demo_BombTruckHEExplosion
+ FireLook = Yes
+End
+
+ParticleSystem Demo_BombTruckHEExplosionTrail
+ FireLook = Yes
+End
+
+ParticleSystem DemoTrapExplosion
+ FireLook = Yes
+End
+
+ParticleSystem DragonTransitionExplosion
+ FireLook = Yes
+End
+
+ParticleSystem DragonTransitionExplosion1
+ FireLook = Yes
+End
+
+ParticleSystem DragonTransitionFire
+ FireLook = Yes
+End
+
+ParticleSystem Explosion
+ FireLook = Yes
+End
+
+ParticleSystem ExplosionLarge01
+ FireLook = Yes
+End
+
+ParticleSystem FireBaseHowitzerPillarArms
+ FireLook = Yes
+End
+
+ParticleSystem FirebasePillarArmFlameSlave
+ FireLook = Yes
+End
+
+ParticleSystem FireBuildingSmall
+ FireLook = Yes
+End
+
+ParticleSystem FireBurningBarricade01
+ FireLook = Yes
+End
+
+ParticleSystem FireBurningBarricade02
+ FireLook = Yes
+End
+
+ParticleSystem FireFactionLarge
+ FireLook = Yes
+End
+
+ParticleSystem FireFactionMedium
+ FireLook = Yes
+End
+
+ParticleSystem FireFactionSmall
+ FireLook = Yes
+End
+
+ParticleSystem FireInfantrySmall
+ FireLook = Yes
+End
+
+ParticleSystem FireInfantrySmallSub1
+ FireLook = Yes
+End
+
+ParticleSystem FireInfantrySmallSub10
+ FireLook = Yes
+End
+
+ParticleSystem FireInfantrySmallSub2
+ FireLook = Yes
+End
+
+ParticleSystem FireInfantrySmallSub3
+ FireLook = Yes
+End
+
+ParticleSystem FireInfantrySmallSub4
+ FireLook = Yes
+End
+
+ParticleSystem FireInfantrySmallSub5
+ FireLook = Yes
+End
+
+ParticleSystem FireInfantrySmallSub6
+ FireLook = Yes
+End
+
+ParticleSystem FireInfantrySmallSub7
+ FireLook = Yes
+End
+
+ParticleSystem FireInfantrySmallSub8
+ FireLook = Yes
+End
+
+ParticleSystem FireInfantrySmallSub9
+ FireLook = Yes
+End
+
+ParticleSystem FireLarge01
+ FireLook = Yes
+End
+
+ParticleSystem FireSmall
+ FireLook = Yes
+End
+
+ParticleSystem FireSmallContinuous
+ FireLook = Yes
+End
+
+ParticleSystem FireStormBranch1
+ FireLook = Yes
+End
+
+ParticleSystem FireStormBranch2
+ FireLook = Yes
+End
+
+ParticleSystem FireStormBranch3
+ FireLook = Yes
+End
+
+ParticleSystem FireStormHelixMainRing
+ FireLook = Yes
+End
+
+ParticleSystem FireStormMain
+ FireLook = Yes
+End
+
+ParticleSystem FireStormMainRing
+ FireLook = Yes
+End
+
+ParticleSystem FireStormMainRingUpgraded
+ FireLook = Yes
+End
+
+ParticleSystem FireStormMainUpgraded
+ FireLook = Yes
+End
+
+ParticleSystem FirestormSmall
+ FireLook = Yes
+End
+
+ParticleSystem FireTankSmall
+ FireLook = Yes
+End
+
+ParticleSystem FireTreeSmall
+ FireLook = Yes
+End
+
+ParticleSystem FireTreeSmaller
+ FireLook = Yes
+End
+
+ParticleSystem FireWallSegmentSystem
+ FireLook = Yes
+End
+
+ParticleSystem FireWallSegmentUpgradedSystem
+ FireLook = Yes
+End
+
+ParticleSystem FlameBuildingSpray
+ FireLook = Yes
+End
+
+ParticleSystem FlameThrowerSpray
+ FireLook = Yes
+End
+
+ParticleSystem FlameThrowerSprayUpgraded
+ FireLook = Yes
+End
+
+ParticleSystem FlamethrowerTarget
+ FireLook = Yes
+End
+
+ParticleSystem FlamethrowerTargetUpgraded
+ FireLook = Yes
+End
+
+ParticleSystem FlameThrowerTrail02
+ FireLook = Yes
+End
+
+ParticleSystem FlameThrowerTrail02Upgraded
+ FireLook = Yes
+End
+
+ParticleSystem FlameThrowerTrail04
+ FireLook = Yes
+End
+
+ParticleSystem FlameThrowerTrail04Upgraded
+ FireLook = Yes
+End
+
+ParticleSystem FlameThrowerTrail06
+ FireLook = Yes
+End
+
+ParticleSystem FlameThrowerTrail06Upgraded
+ FireLook = Yes
+End
+
+ParticleSystem GLAPowerPlantDamagedExplosion
+ FireLook = Yes
+End
+
+ParticleSystem GLAPowerPlantDeathExplosion1
+ FireLook = Yes
+End
+
+ParticleSystem GLAPowerPlantDeathExplosion2
+ FireLook = Yes
+End
+
+ParticleSystem GLAPowerPlantFlame
+ FireLook = Yes
+End
+
+ParticleSystem GLATowerFlame
+ FireLook = Yes
+End
+
+ParticleSystem HotPillarArms
+ FireLook = Yes
+End
+
+ParticleSystem HumveeTransitionExplosion1
+ FireLook = Yes
+End
+
+ParticleSystem InfernoCannonFire
+ FireLook = Yes
+End
+
+ParticleSystem InfernoCannonFireUpgraded
+ FireLook = Yes
+End
+
+ParticleSystem InfernoTrail
+ FireLook = Yes
+End
+
+ParticleSystem InfernoTrailUpgraded
+ FireLook = Yes
+End
+
+ParticleSystem JetBigExplosion
+ FireLook = Yes
+End
+
+ParticleSystem JetBigExplosionInitial
+ FireLook = Yes
+End
+
+ParticleSystem JetBurning
+ FireLook = Yes
+End
+
+ParticleSystem JetExplosion
+ FireLook = Yes
+End
+
+ParticleSystem JetExplosionGround
+ FireLook = Yes
+End
+
+ParticleSystem JetFireLarge
+ FireLook = Yes
+End
+
+ParticleSystem LimoExplosion
+ FireLook = Yes
+End
+
+ParticleSystem LimoTransitionExplosion
+ FireLook = Yes
+End
+
+ParticleSystem MammothTankExplosionArmsFlame
+ FireLook = Yes
+End
+
+ParticleSystem MammothTankExplosionFlameSlave
+ FireLook = Yes
+End
+
+ParticleSystem MammothTankSubExplosionFlameSlave
+ FireLook = Yes
+End
+
+ParticleSystem MOABExplosionArms
+ FireLook = Yes
+End
+
+ParticleSystem MOABRing
+ FireLook = Yes
+End
+
+ParticleSystem MolotovFlames
+ FireLook = Yes
+End
+
+ParticleSystem NapalmExplosion
+ FireLook = Yes
+End
+
+ParticleSystem NapalmFire
+ FireLook = Yes
+End
+
+ParticleSystem NukeBaikonurMushroomExplosion
+ FireLook = Yes
+End
+
+ParticleSystem NukeBaikonurMushroomRing
+ FireLook = Yes
+End
+
+ParticleSystem NukeCannonMushroomExplosion
+ FireLook = Yes
+End
+
+ParticleSystem NukeCannonMushroomRing
+ FireLook = Yes
+End
+
+ParticleSystem NukeCannonTransitionExplosion
+ FireLook = Yes
+End
+
+ParticleSystem NukeGLAMushroomExplosion
+ FireLook = Yes
+End
+
+ParticleSystem NukeGLAMushroomRing
+ FireLook = Yes
+End
+
+ParticleSystem NukeMushroomExplosion
+ FireLook = Yes
+End
+
+ParticleSystem NukeMushroomRing
+ FireLook = Yes
+End
+
+ParticleSystem NukeMushroomRingSmall
+ FireLook = Yes
+End
+
+ParticleSystem OverlordTransitionExplosion
+ FireLook = Yes
+End
+
+ParticleSystem PatriotMissileDetonationExplosion
+ FireLook = Yes
+End
+
+ParticleSystem ReforgedAuroraFireball
+ FireLook = Yes
+End
+
+ParticleSystem ReforgedAuroraNapalm
+ FireLook = Yes
+End
+
+ParticleSystem ReforgedShrapnelFlame
+ FireLook = Yes
+End
+
+ParticleSystem ScoutDroneExplosion
+ FireLook = Yes
+End
+
+ParticleSystem ScudLauncherTransitionExplosion
+ FireLook = Yes
+End
+
+ParticleSystem ScudMissleExplosion
+ FireLook = Yes
+End
+
+ParticleSystem ScudMissleExplosionTrail
+ FireLook = Yes
+End
+
+ParticleSystem ScudMissleFire
+ FireLook = Yes
+End
+
+ParticleSystem ScudMissleLauncherExplosion
+ FireLook = Yes
+End
+
+ParticleSystem ScudMissleLauncherExplosionTrail
+ FireLook = Yes
+End
+
+ParticleSystem SmolderingFire
+ FireLook = Yes
+End
+
+ParticleSystem SmolderingFireHuge
+ FireLook = Yes
+End
+
+ParticleSystem SmolderingFireLarge
+ FireLook = Yes
+End
+
+ParticleSystem SmolderingFireTower
+ FireLook = Yes
+End
+
+ParticleSystem SmolderingFlameCore
+ FireLook = Yes
+End
+
+ParticleSystem SmolderingFlameCoreHuge
+ FireLook = Yes
+End
+
+ParticleSystem SmolderingFlameCoreLarge
+ FireLook = Yes
+End
+
+ParticleSystem spectreDeathExplosion
+ FireLook = Yes
+End
+
+ParticleSystem spectreDeathExplosionArms
+ FireLook = Yes
+End
+
+ParticleSystem SpectreGunshipExplosionLight
+ FireLook = Yes
+End
+
+ParticleSystem SpectreGunshipFireLarge
+ FireLook = Yes
+End
+
+ParticleSystem SpectreHotPillarArmFlameSlave
+ FireLook = Yes
+End
+
+ParticleSystem SpectreHotPillarArms
+ FireLook = Yes
+End
+
+ParticleSystem SpectreHowitzerExplosion
+ FireLook = Yes
+End
+
+ParticleSystem StructureCollapseBurstExplosion
+ FireLook = Yes
+End
+
+ParticleSystem StructureCollapseDelayExplosion
+ FireLook = Yes
+End
+
+ParticleSystem StructureCollapseFinalExplosion
+ FireLook = Yes
+End
+
+ParticleSystem StructureCollapseInitialExplosion
+ FireLook = Yes
+End
+
+ParticleSystem StructureToppleCrushingTopExplosion
+ FireLook = Yes
+End
+
+ParticleSystem StructureToppleSecondaryExplosion
+ FireLook = Yes
+End
+
+ParticleSystem StructureToppleStartExplosion
+ FireLook = Yes
+End
+
+ParticleSystem StructureToppleStartTopExplosion
+ FireLook = Yes
+End
+
+ParticleSystem StructureTransitionLargeExplosion
+ FireLook = Yes
+End
+
+ParticleSystem StructureTransitionMediumExplosion
+ FireLook = Yes
+End
+
+ParticleSystem StructureTransitionSmallExplosion
+ FireLook = Yes
+End
+
+ParticleSystem StructureTransitionTinyExplosion
+ FireLook = Yes
+End
+
+ParticleSystem SubExplosionFlameSlave01
+ FireLook = Yes
+End
+
+ParticleSystem TankFire
+ FireLook = Yes
+End
+
+ParticleSystem TankSmoke
+ FireLook = Yes
+End
+
+ParticleSystem TankStruckFlameSlave
+ FireLook = Yes
+End
+
+ParticleSystem TrainWreckTrailExplosion
+ FireLook = Yes
+End
+
+ParticleSystem TsingMaTrailExplosion
+ FireLook = Yes
+End
+
+ParticleSystem UpgradeCarpetBombExplosion
+ FireLook = Yes
+End
+
; The wreck pieces a vehicle's death throws as models (turrets, wheels, doors, hull plates; the
; ParticleSystem line of their CreateDebris in ObjectCreationListReforged.ini) trail the same dark
; ribbon as the shrapnel above, with a small flame on each of its points that is gone in a quarter
diff --git a/GeneralsMD/Code/Data/Scenarios/firelook.txt b/GeneralsMD/Code/Data/Scenarios/firelook.txt
new file mode 100644
index 000000000..5f8abafe3
--- /dev/null
+++ b/GeneralsMD/Code/Data/Scenarios/firelook.txt
@@ -0,0 +1,51 @@
+# Footage of the Direct3D 11 fire look (FireLook = Yes in ParticleSystemReforged.ini) on Twilight
+# Flame: a Chinese attack on the American base at start 0 (537,3188). Dragon Tanks burn Rangers and
+# buildings, Inferno Cannons shell the power plants and the War Factory, and Battlemasters and an
+# Overlord trade shells with Crusaders and Paladins in front of the base, for the shell bursts and
+# burning wrecks. Seat 0 America, seat 1 China, everyone hostile, nothing thinks but this file.
+# Filmed with Cinema/firelook.txt; the same command plus -d3d9 is the old look over the same frames.
+#
+# generals.exe -win -xres 1280 -yres 720 -msaa 0 -fps 120 -noFPSLimit -particlecap 2500
+# -quickstart -noshellmap -observer -multiInstance -map "Maps\Twilight Flame\Twilight Flame.map"
+# -autoskirmish 2 -takeover -side 0 FactionAmerica -side 1 FactionChina -seed 7
+# -scenario firelook -cinema firelook -video 120 1380 firelook -maxframes 1400
+
+# the base round the command centre (the spots drawlooks.txt builds on)
+10 spawn 0 AmericaPowerPlant 1 start0:-240:160
+10 spawn 0 AmericaPowerPlant 1 start0:300:-280
+10 spawn 0 AmericaWarFactory 1 start0:40:-340
+10 spawn 0 AmericaBarracks 1 start0:60:320
+10 spawn 0 AmericaSupplyCenter 1 start0:-260:440
+
+# defenders: Rangers and armour coming out to meet the attack
+20 spawn 0 AmericaInfantryRanger 16 start0:200:120 20
+20 spawn 0 AmericaTankCrusader 3 start0:160:-120 45
+20 spawn 0 AmericaTankPaladin 1 start0:100:-40
+40 attackmove 0 AmericaInfantryRanger start0:420:100
+40 attackmove 0 AmericaTankCrusader start0:440:-100
+40 attackmove 0 AmericaTankPaladin start0:440:-100
+
+# the attack from the east, close enough to meet the defenders inside two seconds
+20 spawn 1 ChinaTankDragon 6 start0:420:100 40
+20 spawn 1 ChinaTankBattleMaster 5 start0:440:-120 45
+20 spawn 1 ChinaTankOverlord 2 start0:520:-40 60
+20 spawn 1 ChinaVehicleInfernoCannon 6 start0:380:360 40
+40 attackmove 1 ChinaTankDragon start0:60:140
+40 attackmove 1 ChinaTankBattleMaster start0:0:-120
+40 attackmove 1 ChinaTankOverlord start0:0:-120
+40 attack 1 ChinaVehicleInfernoCannon 0 AmericaBarracks
+
+# a fire wall across the base, a second wave, and the cannons moved onto the command centre
+200 weaponat 1 ChinaTankDragon start0:120:120 secondary
+300 spawn 0 AmericaInfantryRanger 10 start0:-60:200 20
+300 spawn 1 ChinaTankDragon 3 start0:420:160 40
+315 attackmove 0 AmericaInfantryRanger start0:300:100
+315 attackmove 1 ChinaTankDragon start0:0:150
+330 attack 1 ChinaVehicleInfernoCannon 0 AmericaCommandCenter
+
+120 tally 0 *
+240 tally 0 *
+360 tally 0 *
+480 tally 0 *
+600 tally 0 *
+680 tally 1 *
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
index bb0a75a56..5c11a527b 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
@@ -619,6 +619,11 @@ public:
Bool isExplosionDebrisTrail( void ) const { return m_explosionDebrisTrail; }
void setExplosionDebrisTrail( Bool on ) { m_explosionDebrisTrail = on; }
+ /** "FireLook = Yes": a flame or explosion system, whose billboards the Direct3D 11 frame draws
+ * with a temperature ramp over their life, edges that burn away and a flicker
+ * (W3DParticleSys.cpp, FIRE_LOOK_SAMPLING in ffshader.h). Drawing only. */
+ Bool isFireLook( void ) const { return m_fireLook; }
+
// This function was made const because of update modules' module data being all const.
ParticleSystem *createSlaveSystem( Bool createSlaves = TRUE ) const ; ///< if returns non-NULL, it is a slave system for use
@@ -643,6 +648,7 @@ protected:
protected:
AsciiString m_name; ///< the name of this template
Bool m_explosionDebrisTrail; ///< switched off with the DebrisTrails option (client only)
+ Bool m_fireLook; ///< drawn with the Direct3D 11 fire look (client only)
// This has to be mutable because of the delayed initialization thing in createSlaveSystem
mutable const ParticleSystemTemplate *m_slaveTemplate; ///< if non-NULL, use this to create a slave system
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
index dcc6277a8..12328a0bc 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
@@ -3367,6 +3367,7 @@ const FieldParse ParticleSystemTemplate::m_fieldParseTable[] =
{ "SlavePosOffset", INI::parseCoord3D, NULL, offsetof( ParticleSystemTemplate, m_slavePosOffset ) },
{ "PerParticleAttachedSystem", INI::parseAsciiString, NULL, offsetof( ParticleSystemTemplate, m_attachedSystemName ) },
{ "ExplosionDebrisTrail", INI::parseBool, NULL, offsetof( ParticleSystemTemplate, m_explosionDebrisTrail ) },
+ { "FireLook", INI::parseBool, NULL, offsetof( ParticleSystemTemplate, m_fireLook ) },
{ "Lifetime", parseRetailFramesRandom, NULL, offsetof( ParticleSystemTemplate, m_lifetime ) },
{ "SystemLifetime", INI::parseRetailFramesUnsignedInt, NULL, offsetof( ParticleSystemTemplate, m_systemLifetime ) },
@@ -3540,6 +3541,7 @@ ParticleSystemTemplate::ParticleSystemTemplate( const AsciiString &name ) :
m_slaveTemplate = NULL;
//
m_explosionDebrisTrail = FALSE;
+ m_fireLook = FALSE;
}
// ------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DParticleSys.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DParticleSys.h
index abefe02bd..bd2cb3e47 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DParticleSys.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DParticleSys.h
@@ -85,6 +85,7 @@ public:
Int drawn; ///< written by the job
UnsignedInt pastLimit; ///< written by the job: on-screen particles past capacity
Bool glow; ///< written by the job: the fire's glow is in the normals, not the colour
+ Bool fire; ///< the template's FireLook: each particle's age and seed go in v2
};
/// One particle the sun's smoke map can take, as the last particle update left it.
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp
index d1a06a0ec..918cfc325 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp
@@ -463,6 +463,16 @@ static void fillBillboards( Int index, void *context )
const uint8 orientation = floatToByteAsMsvc( p->getAngle() * 255.0f / (2.0f * PI) );
PointGroupClass::Write_Billboard( quad, job->view, Vector3( pos->x, pos->y, pos->z ), psize,
orientation, packed, glow );
+ if (fill.fire)
+ {
+ // FIRE_LOOK_SAMPLING's packing: a whole seed below 256, then the age held off the whole
+ // numbers on both sides, so the interpolated value never floors to the next seed.
+ // Lifetime 0 is a particle that never dies (four retail systems), which stays young.
+ const Real age = p->m_lifetime ? 1.0f - (Real)p->getLifetimeLeft() / (Real)p->m_lifetime : 0.0f;
+ const Real fireAgeSeed = (Real)( ( p->getPersonality() * 97u ) & 255u ) + 0.01f + 0.98f * age;
+ for (Int k = 0; k < 4; ++k)
+ quad[ k ].v2 = fireAgeSeed;
+ }
quad += 4;
if (++drawn == fill.capacity)
@@ -1503,7 +1513,8 @@ void W3DParticleSystemManager::doParticles(RenderInfoClass &rinfo)
fill.drawn = 0;
fill.pastLimit = 0;
fill.glow = FALSE;
- fill.texture = W3DDisplay::m_assetManager->Get_Texture( sys->getParticleTypeName().str() );
+ fill.fire = sys->getTemplate()->isFireLook();
+ fill.texture =W3DDisplay::m_assetManager->Get_Texture( sys->getParticleTypeName().str() );
PointGroupClass::Reserve_Sorted_Billboards( fill.capacity, &fill.range );
m_billboardFills.push_back( fill );
}
@@ -1565,7 +1576,7 @@ void W3DParticleSystemManager::doParticles(RenderInfoClass &rinfo)
if (nextFill < m_billboardFills.size() && m_billboardFills[ nextFill ].system == sys)
{
BillboardFill &fill = m_billboardFills[ nextFill++ ];
- PointGroupClass::Insert_Sorted_Billboards( &fill.range, fill.drawn, fill.texture, fill.shader, fill.glow != FALSE );
+ PointGroupClass::Insert_Sorted_Billboards( &fill.range, fill.drawn, fill.texture, fill.shader, fill.glow != FALSE, fill.fire != FALSE );
fill.texture->Release_Ref(); // the draw state took its own reference
m_fieldParticleCount += fill.fieldIncrement * fill.drawn;
m_onScreenParticleCount += fill.drawn;
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
index 229c380c0..d2eb123b0 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
@@ -245,6 +245,7 @@ DX11BackendClass::DX11BackendClass()
, ShadowSkyFill(0.0f)
, ShadowReceiving(false)
, SmokeGlow(false)
+ , FireLook(false)
, AdditiveGain(1.0f)
, GlowDraw(false)
, SceneStandIn(NULL)
@@ -1035,6 +1036,37 @@ void DX11BackendClass::Set_Smoke_Glow(bool glow)
}
}
+void DX11BackendClass::Set_Fire_Look(bool fire)
+{
+ if (FireLook != fire) {
+ FireLook = fire;
+ PipelineChanged = true;
+ }
+}
+
+/** Which way a fire billboard wears its look: through the colour for a blend that adds it
+ unweighted, through the alpha otherwise. Off under Classic, whose picture is -d3d9's
+ (SoftParticlesAllowed carries that setting), and off for anything but a one-stage fixed-function
+ draw with a second coordinate set to read, and for a multiplicative blend, which a burnt-away
+ flame would darken rather than leave. */
+unsigned DX11BackendClass::Fire_Look() const
+{
+ if (!FireLook || !SoftParticlesAllowed || ShadowMapBound
+ || VertexProgram != ENGINE_SHADER_NONE || PixelProgram != ENGINE_SHADER_NONE
+ || (VertexFormat & D3DFVF_XYZRHW) != 0
+ || (VertexFormat & D3DFVF_TEXCOUNT_MASK) < D3DFVF_TEX2
+ || StageStates[1][D3DTSS_COLOROP] != D3DTOP_DISABLE
+ || RenderStates.Get_Render_State(D3DRS_ALPHABLENDENABLE) == FALSE) {
+ return FIRE_LOOK_NONE;
+ }
+ const DWORD source = RenderStates.Get_Render_State(D3DRS_SRCBLEND);
+ const DWORD destination = RenderStates.Get_Render_State(D3DRS_DESTBLEND);
+ if (source == D3DBLEND_DESTCOLOR || source == D3DBLEND_ZERO || destination == D3DBLEND_SRCCOLOR) {
+ return FIRE_LOOK_NONE;
+ }
+ return (source == D3DBLEND_ONE) ? FIRE_LOOK_COLOUR : FIRE_LOOK_ALPHA;
+}
+
void DX11BackendClass::Set_Additive_Gain(float gain)
{
if (AdditiveGain != gain) {
@@ -2144,6 +2176,7 @@ bool DX11BackendClass::Build_Combiner_Description(CombinerDescription & descript
description.SmokeGlow = Smoke_Glow();
description.SoftParticle = Soft_Particle();
description.DrawEffect = Draw_Effect();
+ description.FireLook = Fire_Look();
return description.StageCount > 0;
}
@@ -2230,6 +2263,7 @@ bool DX11BackendClass::Build_Vertex_Description(VertexPipelineDescription & desc
description.FogVertexMode = RenderStates.Get_Render_State(D3DRS_FOGVERTEXMODE);
description.SmokeGlow = Smoke_Glow();
description.SoftParticle = Soft_Particle() != SOFT_PARTICLE_NONE;
+ description.FireLook = Fire_Look() != FIRE_LOOK_NONE;
return true;
}
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h
index dd0d0bbc0..a08f1ae03 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h
@@ -234,6 +234,11 @@ public:
// the smoke billboards' runs. An unlit draw with a normal takes it; any other ignores it.
void Set_Smoke_Glow(bool glow);
+ // The draws that follow are billboards of a fire or explosion system, carrying each particle's
+ // age and seed in the second coordinate set (ffshader.h, FIRE_LOOK_SAMPLING). Only the sorting
+ // pool sets it, around those systems' runs. A draw it does not suit takes none (Fire_Look).
+ void Set_Fire_Look(bool fire);
+
// The look the draws that follow are dressed in (a DRAW_EFFECT_* value, ffshader.h) and its
// four numbers: wall clock seconds, strength, a per-object seed and the object's opacity. The
// mesh renderer sets it around one object's draws and puts DRAW_EFFECT_NONE back after them.
@@ -549,6 +554,9 @@ private:
bool Camera_Space_Draw() const;
bool SmokeGlow;
bool Smoke_Glow() const;
+ // Set_Fire_Look, and which way the current draw wears it (a FIRE_LOOK_* value).
+ bool FireLook;
+ unsigned Fire_Look() const;
// Set_Draw_Effect's look and numbers, and the look the current draw takes after the checks.
unsigned DrawEffect;
float DrawEffectNumbers[4];
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp
index cb0d929b6..c9fedef44 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp
@@ -622,6 +622,13 @@ void Direct3D11_Set_Smoke_Glow(bool glow)
}
}
+void Direct3D11_Set_Fire_Look(bool fire)
+{
+ if (Active) {
+ Backend.Set_Fire_Look(fire);
+ }
+}
+
static bool DrawEffectsAllowed = true;
void Direct3D11_Set_Draw_Effect(unsigned effect, const float parameters[4])
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h
index 813bacee0..37ed5157a 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h
@@ -171,6 +171,10 @@ void Direct3D11_Set_Scene_View(const float view[16]);
// (DX11BackendClass::Set_Smoke_Glow). The sorting pool sets it around the smoke billboards' runs.
void Direct3D11_Set_Smoke_Glow(bool glow);
+// The draws that follow are a fire or explosion system's billboards, with each particle's age and
+// seed in the second coordinate set (DX11BackendClass::Set_Fire_Look). The sorting pool sets it.
+void Direct3D11_Set_Fire_Look(bool fire);
+
// The look one object's draws are dressed in (DRAW_EFFECT_* in ffshader.h) and its four numbers
// (DX11BackendClass::Set_Draw_Effect). The mesh renderer sets it around a mesh's draws and puts
// zero back after them. -d3d9, -headless and the SDL3 port draw the object as they always did.
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp
index ee2261d72..1b5cb0c20 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp
@@ -75,6 +75,7 @@ void Direct3D11_Clear_Shadow_Parameters() {}
bool Direct3D11_Fill_Smoke_Map(const float *, unsigned, float) { return false; }
void Direct3D11_Set_Scene_View(const float [16]) {}
void Direct3D11_Set_Smoke_Glow(bool) {}
+void Direct3D11_Set_Fire_Look(bool) {}
void Direct3D11_Set_Draw_Effect(unsigned, const float [4]) {}
bool Direct3D11_Draw_Effects() { return false; }
void Direct3D11_Allow_Draw_Effects(bool) {}
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp
index 06a2b552e..de79ad6f7 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp
@@ -258,6 +258,8 @@ static bool generate_combiners(const CombinerDescription & description,
// The per-object looks likewise: nothing past SoftParticleDepth reaches the SDL3 programs.
const unsigned effect = (volumetric && description.DrawEffect < DRAW_EFFECT_COUNT)
? description.DrawEffect : DRAW_EFFECT_NONE;
+ // The fire look reads no constant, but the vertex half that feeds it is the D3D11 one's.
+ const unsigned fire = volumetric ? description.FireLook : FIRE_LOOK_NONE;
volumetric = volumetric && description.ShadowReceiving;
if (description.StageCount == 0 || description.StageCount > MAXIMUM_COMBINER_STAGES) {
return false;
@@ -403,6 +405,9 @@ static bool generate_combiners(const CombinerDescription & description,
if (effect != DRAW_EFFECT_NONE) {
hlsl += DRAW_EFFECT_SAMPLING;
}
+ if (fire != FIRE_LOOK_NONE) {
+ hlsl += FIRE_LOOK_SAMPLING;
+ }
}
else {
for (unsigned stage = 0; stage < MAXIMUM_COMBINER_STAGES; ++stage) {
@@ -449,7 +454,18 @@ static bool generate_combiners(const CombinerDescription & description,
"{\n"
" float4 texel;\n";
hlsl += " float4 current = input.Diffuse;\n";
+ if (fire != FIRE_LOOK_NONE) {
+ hlsl += FIRE_LOOK_BEND;
+ }
hlsl += body;
+ // Before the shade and the fog, as the art's own colour would be.
+ if (fire != FIRE_LOOK_NONE) {
+ hlsl += (fire == FIRE_LOOK_COLOUR)
+ ? " float fire_shape = " FIRE_LOOK_BURN_SHAPE_COLOUR ";\n" FIRE_LOOK_BURN
+ " current *= fire_keep;\n"
+ : " float fire_shape = " FIRE_LOOK_BURN_SHAPE_ALPHA ";\n" FIRE_LOOK_BURN
+ " current.a *= fire_keep;\n";
+ }
if (description.SpecularAdd && !description.SmokeGlow) {
// Before the fog and the alpha test, as D3D9 orders them; the alpha is the stages'.
hlsl += " current.rgb = saturate(current.rgb + input.Specular.rgb);\n";
@@ -572,5 +588,9 @@ std::string CombinerShader_Key(const CombinerDescription & description)
snprintf(field, sizeof(field), ":X%u", description.DrawEffect);
key += field;
}
+ if (description.FireLook != FIRE_LOOK_NONE) {
+ snprintf(field, sizeof(field), ":B%u", description.FireLook);
+ key += field;
+ }
return key;
}
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h
index 4c3a40a71..c0f52fcdf 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h
@@ -117,6 +117,19 @@ struct CombinerDescription
// fog and the alpha test (DRAW_EFFECT_SAMPLING). RTS3DScene::renderOneObject picks it and
// the mesh renderer hands it to the backend around each of the object's draws.
unsigned DrawEffect = 0;
+
+ // D3D11 only: a sorted billboard of a fire or explosion system (FIRE_LOOK_*, FIRE_LOOK_SAMPLING).
+ // FIRE_LOOK_ALPHA wears the flame away through the alpha, for a SRCALPHA blend; FIRE_LOOK_COLOUR
+ // through the colour, for an additive one. Initialised here for a caller that fills the rest
+ // field by field.
+ unsigned FireLook = 0;
+};
+
+enum
+{
+ FIRE_LOOK_NONE = 0,
+ FIRE_LOOK_ALPHA = 1,
+ FIRE_LOOK_COLOUR = 2
};
enum
@@ -451,6 +464,63 @@ const unsigned NORMAL_MAPPED_LIGHTS = 4;
"}\n" \
"\n"
+// A fire or explosion billboard on Direct3D 11 (CombinerDescription::FireLook). Nothing in the
+// constant block: the particle's age and a seed ride in the second coordinate set's v, packed as
+// seed + 0.01 + 0.98 * age with the seed a whole number below 256 (W3DParticleSys.cpp,
+// fillBillboards), and the vertex half hands the set on (VertexPipelineDescription::FireLook). The
+// margins keep the interpolated value off a whole number, where floor would flip the seed.
+//
+// Three things, all driven by the age, so the noise runs on the game's clock and stops with it.
+// FIRE_LOOK_BEND, before the stages, pushes the card's texture coordinates through two scrolling
+// noise fields, more as the flame ages, so a static card flickers and licks. After the stages the
+// flame's own shape in its texture (the alpha, or for an additive card its brightest channel) and
+// the age give a heat that runs a temperature ramp, white through yellow, orange and red to soot, and
+// the ramp takes most of the colour the keyframes left while keeping their brightness, so the INI's
+// fade still times the flame. Then the flame burns away from its thin edges in: a threshold that
+// rises with the age against the shape broken up by finer noise, instead of only the flat fade.
+#define FIRE_LOOK_SAMPLING \
+ "float fire_hash(float2 p)\n" \
+ "{\n" \
+ " return frac(sin(dot(p, float2(12.9898, 78.233))) * 43758.5453);\n" \
+ "}\n" \
+ "\n" \
+ "float fire_noise(float2 p)\n" \
+ "{\n" \
+ " float2 i = floor(p);\n" \
+ " float2 f = frac(p);\n" \
+ " f = f * f * (3.0 - 2.0 * f);\n" \
+ " return lerp(lerp(fire_hash(i), fire_hash(i + float2(1.0, 0.0)), f.x),\n" \
+ " lerp(fire_hash(i + float2(0.0, 1.0)), fire_hash(i + float2(1.0, 1.0)), f.x), f.y);\n" \
+ "}\n" \
+ "\n" \
+ "float3 fire_ramp(float heat)\n" \
+ "{\n" \
+ " float3 c = lerp(float3(0.12, 0.08, 0.06), float3(0.80, 0.14, 0.03), saturate(heat * 4.0));\n" \
+ " c = lerp(c, float3(1.00, 0.46, 0.08), saturate(heat * 4.0 - 1.0));\n" \
+ " c = lerp(c, float3(1.00, 0.80, 0.32), saturate(heat * 4.0 - 2.0));\n" \
+ " return lerp(c, float3(1.00, 0.97, 0.90), saturate(heat * 4.0 - 3.0));\n" \
+ "}\n" \
+ "\n"
+
+#define FIRE_LOOK_BEND \
+ " float fire_age = saturate((frac(input.TexCoord1.y) - 0.01) / 0.98);\n" \
+ " float2 fire_at = input.TexCoord0 * 3.0 + floor(input.TexCoord1.y) * float2(0.37, 0.61);\n" \
+ " float2 fire_bend = float2(fire_noise(fire_at + float2(0.0, fire_age * 5.0)),\n" \
+ " fire_noise(fire_at * 1.7 + float2(4.1, fire_age * 7.0))) - 0.5;\n" \
+ " input.TexCoord0 = saturate(input.TexCoord0 + fire_bend * (0.06 + 0.06 * fire_age));\n"
+
+// After the stages, with the shape read from the last stage's texel into fire_shape, by one of the
+// two expressions below; the caller applies fire_keep to the alpha or to the whole colour.
+#define FIRE_LOOK_BURN_SHAPE_ALPHA "texel.a"
+#define FIRE_LOOK_BURN_SHAPE_COLOUR "max(texel.r, max(texel.g, texel.b))"
+#define FIRE_LOOK_BURN \
+ " float fire_grain = fire_noise(fire_at * 2.3 + float2(fire_age * 3.0, -fire_age * 6.0));\n" \
+ " float fire_heat = saturate((1.0 - fire_age) * 0.85 + fire_shape * 0.35 - 0.1);\n" \
+ " float fire_level = max(current.r, max(current.g, current.b));\n" \
+ " current.rgb = lerp(current.rgb, fire_ramp(fire_heat) * fire_level, 0.65);\n" \
+ " float fire_edge = fire_age * fire_age * 0.9 - 0.1;\n" \
+ " float fire_keep = smoothstep(fire_edge, fire_edge + 0.2, fire_shape * (0.5 + 0.5 * fire_grain));\n"
+
// The constant block's fields for it, declared after SkyUp: DX11BackendClass::PixelConstantBlock.
// The soft particles' field closes it, so a program that fades declares the whole block.
#define VOLUMETRIC_CONSTANTS \
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.cpp
index 26bffa97d..b803515d3 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.cpp
@@ -514,6 +514,11 @@ bool VertexShader_Generate(const VertexPipelineDescription & description,
&& (texture_coordinate_set_count(description.FVF) < 2 || is_pretransformed(description.FVF))) {
return false;
}
+ if (description.FireLook
+ && (texture_coordinate_set_count(description.FVF) < 2 || is_pretransformed(description.FVF)
+ || description.StageCount > 1)) {
+ return false;
+ }
// A pre-transformed vertex has been through the transform, the lighting and the coordinate
// generation already: its position is in pixels, its colour is in the vertex, and D3D9 reads
@@ -708,6 +713,10 @@ bool VertexShader_Generate(const VertexPipelineDescription & description,
snprintf(line, sizeof(line), " output.TexCoord%u = float2(0.0, 0.0);\n", stage);
hlsl += line;
}
+ // The fire look's age and seed, in the output the missing second stage left empty.
+ if (description.FireLook) {
+ hlsl += " output.TexCoord1 = input.TexCoord1;\n";
+ }
hlsl +=
" output.Position = mul(model_position, WorldViewProjection);\n"
@@ -764,5 +773,8 @@ std::string VertexShader_Key(const VertexPipelineDescription & description)
if (description.SoftParticle) {
key += ":Z";
}
+ if (description.FireLook) {
+ key += ":B";
+ }
return key;
}
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.h
index 8104fa3dd..95e845af8 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.h
@@ -143,6 +143,12 @@ struct VertexPipelineDescription
// Copy_Batch_Vertices), and the program hands it on in the specular colour's alpha, which the
// pixel half's fade reads (SOFT_PARTICLE_SAMPLING). Refused on a format with one set or none.
bool SoftParticle = false;
+
+ // A fire or explosion billboard (CombinerDescription::FireLook): the second coordinate set
+ // carries the particle's age and seed in v, and the program hands the whole set on in
+ // TexCoord1, which a one-stage draw leaves empty. Refused on a format with one set or none, a
+ // pretransformed one, or a draw with a second stage, whose coordinates that output is.
+ bool FireLook = false;
};
// Which profile the generated text is for. The two differ in the output semantic and in how the
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.cpp
index 27c70356b..b392143c0 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.cpp
@@ -1071,7 +1071,7 @@ void PointGroupClass::Reserve_Sorted_Billboards(int quads, SortingBillboardRange
* the same Insert_Quads, from a range the jobs have already written. *
*========================================================================*/
void PointGroupClass::Insert_Sorted_Billboards(SortingBillboardRange *range, int quads,
- TextureClass *texture, const ShaderClass &shader, bool glow)
+ TextureClass *texture, const ShaderClass &shader, bool glow, bool fire)
{
if (quads > 0)
{
@@ -1095,7 +1095,7 @@ void PointGroupClass::Insert_Sorted_Billboards(SortingBillboardRange *range, int
const unsigned short vertices=(unsigned short)(quads*4);
DX8Wrapper::Set_Index_Buffer(SortingQuads, 0);
DX8Wrapper::Set_Sorting_Vertex_Range(range->Array, range->Offset, vertices);
- SortingRendererClass::Insert_Quads((unsigned short)quads, 0, vertices, glow);
+ SortingRendererClass::Insert_Quads((unsigned short)quads, 0, vertices, glow, fire);
DX8Wrapper::Set_Transform(D3DTS_VIEW,view);
}
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.h
index 950e25db9..44bb82f9d 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.h
@@ -235,10 +235,12 @@ public:
/// Bind a reserved range holding quads written by Write_Billboard and put it into the sorting
/// pool, with the state Render gives a billboarded QUADS group; then release the range. The
/// shader has to be one Would_Sort_Billboards accepts. glow: the quads' normals hold the glow
- /// Write_Billboard was given, for the Direct3D 11 backend to add after the shade. Render thread
- /// only.
+ /// Write_Billboard was given, for the Direct3D 11 backend to add after the shade. fire: the
+ /// caller wrote each particle's age and seed into v2 for the fire look (ffshader.h,
+ /// FIRE_LOOK_SAMPLING). Render thread only.
static void Insert_Sorted_Billboards(SortingBillboardRange *range, int quads,
- TextureClass *texture, const ShaderClass &shader, bool glow = false);
+ TextureClass *texture, const ShaderClass &shader, bool glow = false,
+ bool fire = false);
/// One billboard's four vertices: the transform, corner table and single-frame UVs Render uses
/// for a billboarded QUADS group with per-point sizes, orientations and colours, written the
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp
index f603d219b..bb9f9d176 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp
@@ -149,6 +149,7 @@ public:
unsigned short vertex_count; // Number of vertices used in vb
bool quads; // four vertices a quad, in order from min_vertex_index; the ib is not read
bool glow; // the normals hold a fire's glow (Insert_Quads)
+ bool fire; // a fire system's quads, age and seed in v2 (Insert_Quads)
// The object's Direct3D 11 look (RTS3DScene::renderOneObject) as the mesh renderer had it set
// when a sorted mesh queued its triangles; its draws come later, after the look is put back.
unsigned draw_effect;
@@ -252,6 +253,7 @@ void SortingRendererClass::Insert_Triangles(
state->vertex_count=vertex_count;
state->quads=false;
state->glow=false;
+ state->fire=false;
state->draw_effect=Direct3D11_Requested_Draw_Effect(state->draw_effect_parameters);
SortingVertexBufferClass* vertex_buffer=static_cast<SortingVertexBufferClass*>(state->sorting_state.vertex_buffers[0]);
@@ -339,7 +341,8 @@ void SortingRendererClass::Insert_Quads(
unsigned short quad_count,
unsigned short min_vertex_index,
unsigned short vertex_count,
- bool glow)
+ bool glow,
+ bool fire)
{
const unsigned short polygon_count=quad_count*2;
if (!WW3D::Is_Sorting_Enabled()) {
@@ -364,6 +367,7 @@ void SortingRendererClass::Insert_Quads(
state->vertex_count=vertex_count;
state->quads=true;
state->glow=glow;
+ state->fire=fire;
No_Draw_Effect(state);
state->transformed_center=Vector3(0.0f,0.0f,0.0f);
unsorted_list.Add_Tail(state);
@@ -736,10 +740,11 @@ static void Flush_Sorting_Batch(const TempIndexStruct* entries,unsigned entry_co
SortingNodeStruct* next=overlapping_nodes[entry_node];
// A run of billboards fades into the depth behind it and a run of meshes does not, so the
// two never share a draw even in one state.
- if (state->glow!=next->glow || state->quads!=next->quads || !Same_Draw_Effect(state,next) ||
+ if (state->glow!=next->glow || state->fire!=next->fire || state->quads!=next->quads || !Same_Draw_Effect(state,next) ||
!Same_Draw_State(state->sorting_state,next->sorting_state)) {
Apply_Render_State(state->sorting_state);
Direct3D11_Set_Smoke_Glow(state->glow);
+ Direct3D11_Set_Fire_Look(state->fire);
Direct3D11_Set_Soft_Particles(state->quads);
Direct3D11_Set_Draw_Effect(state->draw_effect,state->draw_effect_parameters);
DX8Wrapper::Draw_Triangles(run_first_index,run_triangles,run_first_vertex,vertex_cursor-run_first_vertex);
@@ -756,10 +761,12 @@ static void Flush_Sorting_Batch(const TempIndexStruct* entries,unsigned entry_co
Apply_Render_State(overlapping_nodes[node_id]->sorting_state);
Direct3D11_Set_Smoke_Glow(overlapping_nodes[node_id]->glow);
+ Direct3D11_Set_Fire_Look(overlapping_nodes[node_id]->fire);
Direct3D11_Set_Soft_Particles(overlapping_nodes[node_id]->quads);
Direct3D11_Set_Draw_Effect(overlapping_nodes[node_id]->draw_effect,overlapping_nodes[node_id]->draw_effect_parameters);
DX8Wrapper::Draw_Triangles(run_first_index,run_triangles,run_first_vertex,vertex_cursor-run_first_vertex);
Direct3D11_Set_Smoke_Glow(false);
+ Direct3D11_Set_Fire_Look(false);
Direct3D11_Set_Soft_Particles(false);
static const float no_effect[4]={0.0f,0.0f,0.0f,0.0f};
Direct3D11_Set_Draw_Effect(0,no_effect);
@@ -1082,6 +1089,7 @@ void SortingRendererClass::Insert_VolumeParticle(
state->vertex_count=vertex_count * layerCount;//THIS IS VOLUME_PARTICLE SPECIFIC
state->quads=false;
state->glow=false;
+ state->fire=false;
No_Draw_Effect(state);
SortingVertexBufferClass* vertex_buffer=static_cast<SortingVertexBufferClass*>(state->sorting_state.vertex_buffers[0]);
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.h
index 8bab0f718..bd214740d 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.h
@@ -53,12 +53,14 @@ public:
/// Quads laid out four vertices each, in order, from min_vertex_index; the pool sorts one entry
/// a quad and does not read the index buffer. glow: the quads' normals hold a fire's glow, which
- /// the Direct3D 11 backend adds after the shade (Direct3D11_Set_Smoke_Glow).
+ /// the Direct3D 11 backend adds after the shade (Direct3D11_Set_Smoke_Glow). fire: a fire or
+ /// explosion system's quads, each particle's age and seed in v2 (Direct3D11_Set_Fire_Look).
static void Insert_Quads(
unsigned short quad_count,
unsigned short min_vertex_index,
unsigned short vertex_count,
- bool glow = false);
+ bool glow = false,
+ bool fire = false);
static void Insert_VolumeParticle(
const SphereClass& bounding_sphere,
diff --git a/GeneralsMD/Code/Tests/test_ffshadercompile.cpp b/GeneralsMD/Code/Tests/test_ffshadercompile.cpp
index a13c94421..34fd8d26b 100644
--- a/GeneralsMD/Code/Tests/test_ffshadercompile.cpp
+++ b/GeneralsMD/Code/Tests/test_ffshadercompile.cpp
@@ -380,3 +380,53 @@ TEST(ffshadercompile_each_draw_effect_compiles_on_d3d11_only)
printf(" d3dcompiler_47.dll not present, skipping the compile\n");
}
}
+
+// A fire billboard bends its coordinates before the stages sample and burns after them, before the
+// fog and the soft fade; an additive one wears away through the colour, a blended one through the
+// alpha. It declares no constant of its own, so an additive flame with no fade keeps the short
+// block. SDL3 and D3D9 get none of it.
+TEST(ffshadercompile_a_fire_billboard_burns_on_d3d11_only)
+{
+ CombinerDescription description;
+ memset(&description, 0, sizeof(description));
+ description.StageCount = 1;
+ description.Stages[0] = one_stage(D3DTOP_MODULATE, D3DTA_TEXTURE, D3DTA_DIFFUSE,
+ D3DTOP_MODULATE, D3DTA_TEXTURE, D3DTA_DIFFUSE, 0, true);
+ description.PixelPipeline.FogEnabled = true;
+ const std::string plain_key = CombinerShader_Key(description);
+
+ description.FireLook = FIRE_LOOK_COLOUR;
+ CHECK(CombinerShader_Key(description) == plain_key + ":B2");
+ std::string flame;
+ CHECK(CombinerShader_Generate(description, COMBINER_SHADER_TARGET_D3D11, flame));
+ const size_t bend = flame.find("input.TexCoord0 = saturate(");
+ const size_t sample = flame.find("Texture0.Sample(");
+ const size_t burn = flame.find("current *= fire_keep;");
+ const size_t fog = flame.find("FogColour.rgb, current.rgb");
+ CHECK(bend != std::string::npos && sample != std::string::npos);
+ CHECK(burn != std::string::npos && fog != std::string::npos);
+ CHECK(bend < sample && sample < burn && burn < fog);
+ CHECK(flame.find("VolumeParameters") == std::string::npos);
+
+ description.FireLook = FIRE_LOOK_ALPHA;
+ description.SoftParticle = SOFT_PARTICLE_ALPHA;
+ description.ShadowReceiving = true;
+ std::string fireball;
+ CHECK(CombinerShader_Generate(description, COMBINER_SHADER_TARGET_D3D11, fireball));
+ CHECK(fireball.find("current.a *= fire_keep;") < fireball.find("soft_particle_fade(input.Position"));
+
+ std::string sdl;
+ std::string nine;
+ CHECK(CombinerShader_Generate(description, COMBINER_SHADER_TARGET_SDL3_GPU, sdl));
+ CHECK(CombinerShader_Generate(description, COMBINER_SHADER_TARGET_D3D9, nine));
+ CHECK(sdl.find("fire_") == std::string::npos);
+ CHECK(nine.find("fire_") == std::string::npos);
+
+ D3DCompileFunction compile = load_compiler();
+ if (compile == NULL) {
+ printf(" d3dcompiler_47.dll not present, skipping the compile\n");
+ return;
+ }
+ CHECK(compiles(compile, flame, D3D11_PROFILE));
+ CHECK(compiles(compile, fireball, D3D11_PROFILE));
+}
diff --git a/GeneralsMD/Code/Tests/test_ffvertexcompile.cpp b/GeneralsMD/Code/Tests/test_ffvertexcompile.cpp
index 00b56f4b7..36ac9c5df 100644
--- a/GeneralsMD/Code/Tests/test_ffvertexcompile.cpp
+++ b/GeneralsMD/Code/Tests/test_ffvertexcompile.cpp
@@ -274,3 +274,39 @@ TEST(ffvertexcompile_a_soft_billboard_hands_its_half_width_on)
CHECK(VertexShader_Generate(soft, VERTEX_SHADER_TARGET_D3D11, hlsl));
CHECK(compiles(compile, hlsl, D3D11_PROFILE));
}
+
+// A fire billboard's age and seed ride the second coordinate set through to TexCoord1, written after
+// the empty stages are zeroed so the zero does not win. Keyed apart; refused with one set or a
+// second stage.
+TEST(ffvertexcompile_a_fire_billboard_hands_its_age_on)
+{
+ VertexPipelineDescription soft = plain_description();
+ soft.SoftParticle = true;
+ VertexPipelineDescription fire = soft;
+ fire.FireLook = true;
+
+ std::string hlsl;
+ CHECK(VertexShader_Generate(fire, VERTEX_SHADER_TARGET_D3D11, hlsl));
+ const size_t zero = hlsl.find("output.TexCoord1 = float2(0.0, 0.0);");
+ const size_t pass = hlsl.find("output.TexCoord1 = input.TexCoord1;");
+ CHECK(zero != std::string::npos);
+ CHECK(pass != std::string::npos);
+ CHECK(zero < pass);
+ CHECK(VertexShader_Key(fire) == VertexShader_Key(soft) + ":B");
+
+ VertexPipelineDescription one_set = fire;
+ one_set.FVF = D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1|D3DFVF_DIFFUSE;
+ CHECK(!VertexShader_Generate(one_set, VERTEX_SHADER_TARGET_D3D11, hlsl));
+ VertexPipelineDescription two_stages = fire;
+ two_stages.StageCount = 2;
+ two_stages.Stages[1] = two_stages.Stages[0];
+ CHECK(!VertexShader_Generate(two_stages, VERTEX_SHADER_TARGET_D3D11, hlsl));
+
+ D3DCompileFunction compile = load_compiler();
+ if (compile == NULL) {
+ printf(" d3dcompiler_47.dll not present, skipping the compile\n");
+ return;
+ }
+ CHECK(VertexShader_Generate(fire, VERTEX_SHADER_TARGET_D3D11, hlsl));
+ CHECK(compiles(compile, hlsl, D3D11_PROFILE));
+}