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(w3ddevice): warm light, team glow and water foam options on direct3d 11

Olcay Seyganddfab24b52aa
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f6a8a1029..0ba212452 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -712,6 +712,7 @@ found and fixed — EA's own, not port damage.**
theirs, which they have to: a shadow crawling across fogged ground is the position of a unit you
are not meant to see. Ground you have never set foot on is still dark and still empty.
- Woodland stops vanishing when you look at too much of it at once. Every tree on screen was written into one buffer that held about 730 of them, and the ones that did not fit were simply not drawn, so scrolling into a dense corner made whole stands of trees blink out and come back when you left. There are four of those buffers now.
+- Three optional looks for the Direct3D 11 picture, each a box in Options, off until you tick it. Water Foam, on the Effects page after Soft Shorelines, puts foam flecks and a pale band along the shore, softens where water meets land and lets the sun's shadow fall on the water. Warm Light and Haze, on the Graphics page after Heat Haze, swings the sun low and warm and lays a light haze over the map; a jet leaves a soft V parting the haze behind it and a helicopter clears a turbulent patch under its rotors. Team Color Glow, next to it, lets the bright house-colour parts of a unit, the flag and the stripe, glow in their own hue without bleaching to white. Picture only: replays and network games play the same with any of them on, and the haze cost 0.4 ms a frame in our measurement.
## Every replay, not just the last one
diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifest
index d5fc1e7ea..c00e18b0f 100644
--- a/GeneralsMD/Code/BuildFingerprint.manifest
+++ b/GeneralsMD/Code/BuildFingerprint.manifest
@@ -62,6 +62,7 @@ Data/Cinema/geproto_alpine.txt
Data/Cinema/geproto_glow.txt
Data/Cinema/geproto_hazemove.txt
Data/Cinema/geproto_oasis.txt
+Data/Cinema/geproto_wake.txt
Data/Cinema/gunfx.txt
Data/Cinema/headlights.txt
Data/Cinema/hero_loop.txt
@@ -229,6 +230,7 @@ Data/Scenarios/blastcheck.txt
Data/Scenarios/bridgecross.txt
Data/Scenarios/bridgelong.txt
Data/Scenarios/broadcastend.txt
+Data/Scenarios/cargocrash.txt
Data/Scenarios/chokeprobe.txt
Data/Scenarios/comanchehill.txt
Data/Scenarios/comanchepods.txt
@@ -257,6 +259,7 @@ Data/Scenarios/geproto_glow.txt
Data/Scenarios/geproto_hazefog.txt
Data/Scenarios/geproto_hazemove.txt
Data/Scenarios/geproto_oasis.txt
+Data/Scenarios/geproto_wake.txt
Data/Scenarios/givemoney.txt
Data/Scenarios/glowbase.txt
Data/Scenarios/glowfight.txt
diff --git a/GeneralsMD/Code/Data/Cinema/geproto_wake.txt b/GeneralsMD/Code/Data/Cinema/geproto_wake.txt
new file mode 100644
index 000000000..d0fce1fc1
--- /dev/null
+++ b/GeneralsMD/Code/Data/Cinema/geproto_wake.txt
@@ -0,0 +1,5 @@
+# Fixed frames over Scenarios/geproto_wake.txt so the wake's ground position can be judged.
+0 hud off
+3 cut 2966 742 1.2 -45 0 # the Comanche between the dry bank and the outcrop
+30 cut 2940 840 1.5 -45 0 # wider and still: the Raptor's turns over the bank
+52 end
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index 79322d790..6b1164a2b 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -1290,6 +1290,30 @@ TOOLTIP:DebrisTrails
"Blasts throw fragments that trail smoke, and wrecks shed burning shrapnel. Off keeps the original explosions. Applies when you press Accept."
END
+GUI:MapLight
+"Warm Light and Haze"
+END
+
+TOOLTIP:MapLight
+"A low afternoon sun that lights the map warmer and casts longer shadows, and a light haze lying over low ground that aircraft part as they fly through it. Direct3D 11 only. Applies from the next map."
+END
+
+GUI:TeamGlow
+"Team Color Glow"
+END
+
+TOOLTIP:TeamGlow
+"The bright patches of each side's color on units and buildings glow in that color. Direct3D 11 only. Applies from the next map."
+END
+
+GUI:WaterFoam
+"Water Foam"
+END
+
+TOOLTIP:WaterFoam
+"Rivers and lakes carry flecks of foam and a band of it along the shore, and the sun's shadows fall on the water. The sea's waves are unchanged. Direct3D 11 only, and off under Classic Graphics. Applies when you press Accept."
+END
+
GUI:FormationDrag
"Drag Out A Formation"
END
diff --git a/GeneralsMD/Code/Data/Scenarios/geproto_fogedge.txt b/GeneralsMD/Code/Data/Scenarios/geproto_fogedge.txt
index 01eab9e84..7bbc4247d 100644
--- a/GeneralsMD/Code/Data/Scenarios/geproto_fogedge.txt
+++ b/GeneralsMD/Code/Data/Scenarios/geproto_fogedge.txt
@@ -6,7 +6,8 @@
# generals.exe -win -borderless -quickstart -noshellmap -multiInstance -fps 120 -noFPSLimit
# -particlecap 2500 -map "Maps\Golden Oasis\Golden Oasis.map" -autoskirmish 2 -takeover
# -side 0 FactionAmerica -side 1 FactionChina -seed 1 -scenario geproto_fogedge
-# -camera 2000 3537 -screenshot 600 -maxframes 640 [-protoMapLight]
+# -camera 2000 3537 -screenshot 600 -maxframes 640
+# with MapLight = yes in the Options.ini of a ZH_USER_DATA_DIR folder for the haze
#
# At -camera 2250 the whole frame is inside the Humvee's sight; at 2000 the left third is fogged.
diff --git a/GeneralsMD/Code/Data/Scenarios/geproto_glow.txt b/GeneralsMD/Code/Data/Scenarios/geproto_glow.txt
index 408be217d..6201fff59 100644
--- a/GeneralsMD/Code/Data/Scenarios/geproto_glow.txt
+++ b/GeneralsMD/Code/Data/Scenarios/geproto_glow.txt
@@ -5,7 +5,8 @@
# generals.exe -win -borderless -quickstart -noshellmap -multiInstance -fps 120 -noFPSLimit
# -particlecap 2500 -map "Maps\Golden Oasis\Golden Oasis.map" -autoskirmish 2 -takeover
# -observer -side 0 FactionAmerica -side 1 FactionChina -seed 1 -scenario geproto_glow
-# -cinema geproto_glow -video 180 1560 geproto -maxframes 1620 [-protoTeamGlow]
+# -cinema geproto_glow -video 180 1560 geproto -maxframes 1620
+# with TeamGlow = yes in the Options.ini of a ZH_USER_DATA_DIR folder for the glow
# the American base
30 spawn 0 AmericaPowerPlant 1 1950 3380
diff --git a/GeneralsMD/Code/Data/Scenarios/geproto_hazefog.txt b/GeneralsMD/Code/Data/Scenarios/geproto_hazefog.txt
index b3a971212..cc47eed44 100644
--- a/GeneralsMD/Code/Data/Scenarios/geproto_hazefog.txt
+++ b/GeneralsMD/Code/Data/Scenarios/geproto_hazefog.txt
@@ -1,4 +1,4 @@
-# The -protoMapLight haze under the fog of war on Golden Oasis, seen from seat 0 (no -observer, so
+# The Warm Light haze under the fog of war on Golden Oasis, seen from seat 0 (no -observer, so
# the shroud is drawn). A Humvee crosses the oasis bank and leaves, so its track is fogged
# (explored, not seen); a Crusader shuttles on the east bank and keeps that patch in sight; the
# rest of the frame has never been seen. Frames here count 30 a second.
@@ -6,7 +6,8 @@
# generals.exe -win -borderless -quickstart -noshellmap -multiInstance -fps 120 -noFPSLimit
# -particlecap 2500 -map "Maps\Golden Oasis\Golden Oasis.map" -autoskirmish 2 -takeover
# -side 0 FactionAmerica -side 1 FactionChina -seed 1 -scenario geproto_hazefog
-# -camera 3040 900 -screenshot 600 -video 300 660 hazefog -maxframes 700 [-protoMapLight]
+# -camera 3040 900 -screenshot 600 -video 300 660 hazefog -maxframes 700
+# with MapLight = yes in the Options.ini of a ZH_USER_DATA_DIR folder for the haze
30 spawn 0 AmericaVehicleHumvee 1 3040 950
45 move 0 AmericaVehicleHumvee 2400 600
diff --git a/GeneralsMD/Code/Data/Scenarios/geproto_hazemove.txt b/GeneralsMD/Code/Data/Scenarios/geproto_hazemove.txt
index 30455b9a3..8c85cd74a 100644
--- a/GeneralsMD/Code/Data/Scenarios/geproto_hazemove.txt
+++ b/GeneralsMD/Code/Data/Scenarios/geproto_hazemove.txt
@@ -1,4 +1,4 @@
-# The -protoMapLight haze reacting to movers, on the low bank of the oasis on Golden Oasis
+# The Warm Light haze reacting to movers, on the low bank of the oasis on Golden Oasis
# (Cinema/geproto_hazemove.txt): a Comanche flies in low and hovers, four Crusaders drive across,
# then a Raptor passes over at cruise height. Nothing is in the frame for the first 10 s, so the
# wide view shows the patches drifting on their own. Frames here count 30 a second.
@@ -6,7 +6,8 @@
# generals.exe -win -borderless -quickstart -noshellmap -multiInstance -fps 120 -noFPSLimit
# -particlecap 2500 -map "Maps\Golden Oasis\Golden Oasis.map" -autoskirmish 2 -takeover
# -observer -side 0 FactionAmerica -side 1 FactionChina -seed 1 -scenario geproto_hazemove
-# -cinema geproto_hazemove -video 180 3480 hazemove -maxframes 3540 [-protoMapLight]
+# -cinema geproto_hazemove -video 180 3480 hazemove -maxframes 3540
+# with MapLight = yes in the Options.ini of a ZH_USER_DATA_DIR folder for the haze
# the helicopter: in low from the south-west at 10 s, hovers over the bank, leaves at 28 s
300 spawn 0 AmericaVehicleComanche 1 2500 650
diff --git a/GeneralsMD/Code/Data/Scenarios/geproto_wake.txt b/GeneralsMD/Code/Data/Scenarios/geproto_wake.txt
new file mode 100644
index 000000000..dc63df683
--- /dev/null
+++ b/GeneralsMD/Code/Data/Scenarios/geproto_wake.txt
@@ -0,0 +1,17 @@
+# Aircraft wake held in the world: a Comanche going back and forth between the dry near bank and
+# the rock outcrop (climbing onto it, dropping off it), then a Raptor sent onto the bank and turned
+# twice in frame. Golden Oasis, fixed cameras (Cinema/geproto_wake.txt). 30 a second.
+
+# heli: in from the south-west, then dry bank -> outcrop -> dry bank -> outcrop
+300 spawn 0 AmericaVehicleComanche 1 2500 650
+301 move 0 AmericaVehicleComanche 2766 980
+420 move 0 AmericaVehicleComanche 3165 505
+600 move 0 AmericaVehicleComanche 2700 900
+780 move 0 AmericaVehicleComanche 3165 505
+
+# jet: in from screen left onto the bank, a turn toward screen right, a hard turn back, and out
+900 spawn 0 AmericaJetRaptor 1 2214 1786
+901 move 0 AmericaJetRaptor 2915 817
+1080 move 0 AmericaJetRaptor 3190 402
+1200 move 0 AmericaJetRaptor 2600 1100
+1320 move 0 AmericaJetRaptor 3700 300
diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.str
index 89166dd7a..90ad3dea3 100644
--- a/GeneralsMD/Code/Data/Turkish/Generals.str
+++ b/GeneralsMD/Code/Data/Turkish/Generals.str
@@ -15705,6 +15705,30 @@ TOOLTIP:DebrisTrails
"Patlamalar arkasında duman bırakan parçalar savurur, enkazdan yanan şarapnel saçılır. Kapalıyken patlamalar orijinal haliyle kalır. Kabul Et'e basınca uygulanır."
END
+GUI:MapLight
+"Sıcak Işık ve Pus"
+END
+
+TOOLTIP:MapLight
+"Haritayı daha sıcak aydınlatıp daha uzun gölgeler düşüren alçak bir ikindi güneşi ve alçak zeminin üstünde duran, içinden geçen uçakların araladığı hafif bir pus. Yalnızca Direct3D 11. Bir sonraki haritada uygulanır."
+END
+
+GUI:TeamGlow
+"Takım Rengi Parlaması"
+END
+
+TOOLTIP:TeamGlow
+"Birimlerin ve binaların üstündeki parlak takım rengi bölgeleri kendi renginde parlar. Yalnızca Direct3D 11. Bir sonraki haritada uygulanır."
+END
+
+GUI:WaterFoam
+"Su Köpüğü"
+END
+
+TOOLTIP:WaterFoam
+"Nehirlerde ve göllerde köpük benekleri ve kıyı boyunca bir köpük şeridi belirir, güneşin gölgeleri suya düşer. Denizin dalgaları değişmez. Yalnızca Direct3D 11, Klasik Grafikler açıkken kapalıdır. Kabul Et'e basınca uygulanır."
+END
+
GUI:FormationDrag
"Sürükleyerek Düzen Kur"
END
diff --git a/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd b/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd
index cb3cab3d0..68508228d 100644
--- a/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd
+++ b/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd
@@ -5199,6 +5199,100 @@ WINDOW
IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
END
CHILD
+ WINDOW
+ WINDOWTYPE = CHECKBOX;
+ SCREENRECT = UPPERLEFT: 536 350, BOTTOMRIGHT: 760 374, CREATIONRESOLUTION: 800 600;
+ NAME = "OptionsMenu.wnd:CheckMapLight";
+ STATUS = ENABLED+IMAGE+BORDER;
+ STYLE = CHECKBOX+MOUSETRACK;
+ SYSTEMCALLBACK = "[None]";
+ INPUTCALLBACK = "[None]";
+ TOOLTIPCALLBACK = "[None]";
+ DRAWCALLBACK = "[None]";
+ FONT = NAME: "Arial", SIZE: 14, BOLD: 0;
+ HEADERTEMPLATE = "MinorTitle";
+ TOOLTIPTEXT = "TOOLTIP:MapLight";
+ TOOLTIPDELAY = -1;
+ TEXT = "GUI:MapLight";
+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,
+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,
+ HILITE: 186 255 12 255, HILITEBORDER: 0 0 0 255;
+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,
+ IMAGE: Active-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 0 0 255 255, BORDERCOLOR: 128 128 255 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Checked, COLOR: 64 64 64 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 255, BORDERCOLOR: 128 255 128 255,
+ IMAGE: Active-HiLighted, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ END
+ CHILD
+ WINDOW
+ WINDOWTYPE = CHECKBOX;
+ SCREENRECT = UPPERLEFT: 536 378, BOTTOMRIGHT: 760 402, CREATIONRESOLUTION: 800 600;
+ NAME = "OptionsMenu.wnd:CheckTeamGlow";
+ STATUS = ENABLED+IMAGE+BORDER;
+ STYLE = CHECKBOX+MOUSETRACK;
+ SYSTEMCALLBACK = "[None]";
+ INPUTCALLBACK = "[None]";
+ TOOLTIPCALLBACK = "[None]";
+ DRAWCALLBACK = "[None]";
+ FONT = NAME: "Arial", SIZE: 14, BOLD: 0;
+ HEADERTEMPLATE = "MinorTitle";
+ TOOLTIPTEXT = "TOOLTIP:TeamGlow";
+ TOOLTIPDELAY = -1;
+ TEXT = "GUI:TeamGlow";
+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,
+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,
+ HILITE: 186 255 12 255, HILITEBORDER: 0 0 0 255;
+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,
+ IMAGE: Active-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 0 0 255 255, BORDERCOLOR: 128 128 255 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Checked, COLOR: 64 64 64 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 255, BORDERCOLOR: 128 255 128 255,
+ IMAGE: Active-HiLighted, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ END
+ CHILD
WINDOW
WINDOWTYPE = CHECKBOX;
SCREENRECT = UPPERLEFT: 40 350, BOTTOMRIGHT: 264 374, CREATIONRESOLUTION: 800 600;
@@ -6143,6 +6237,53 @@ WINDOW
WINDOW
WINDOWTYPE = CHECKBOX;
SCREENRECT = UPPERLEFT: 288 238, BOTTOMRIGHT: 512 262, CREATIONRESOLUTION: 800 600;
+ NAME = "OptionsMenu.wnd:CheckWaterFoam";
+ STATUS = ENABLED+IMAGE+BORDER;
+ STYLE = CHECKBOX+MOUSETRACK;
+ SYSTEMCALLBACK = "[None]";
+ INPUTCALLBACK = "[None]";
+ TOOLTIPCALLBACK = "[None]";
+ DRAWCALLBACK = "[None]";
+ FONT = NAME: "Arial", SIZE: 14, BOLD: 0;
+ HEADERTEMPLATE = "MinorTitle";
+ TOOLTIPTEXT = "TOOLTIP:WaterFoam";
+ TOOLTIPDELAY = -1;
+ TEXT = "GUI:WaterFoam";
+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,
+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,
+ HILITE: 186 255 12 255, HILITEBORDER: 0 0 0 255;
+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,
+ IMAGE: Active-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 0 0 255 255, BORDERCOLOR: 128 128 255 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Checked, COLOR: 64 64 64 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 255, BORDERCOLOR: 128 255 128 255,
+ IMAGE: Active-HiLighted, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ END
+ CHILD
+ WINDOW
+ WINDOWTYPE = CHECKBOX;
+ SCREENRECT = UPPERLEFT: 288 266, BOTTOMRIGHT: 512 290, CREATIONRESOLUTION: 800 600;
NAME = "OptionsMenu.wnd:CheckExtraAnimations";
STATUS = ENABLED+IMAGE+BORDER;
STYLE = CHECKBOX+MOUSETRACK;
@@ -6189,7 +6330,7 @@ WINDOW
CHILD
WINDOW
WINDOWTYPE = CHECKBOX;
- SCREENRECT = UPPERLEFT: 288 266, BOTTOMRIGHT: 512 290, CREATIONRESOLUTION: 800 600;
+ SCREENRECT = UPPERLEFT: 288 294, BOTTOMRIGHT: 512 318, CREATIONRESOLUTION: 800 600;
NAME = "OptionsMenu.wnd:CheckTreeSway";
STATUS = ENABLED+IMAGE+BORDER;
STYLE = CHECKBOX+MOUSETRACK;
@@ -6236,7 +6377,7 @@ WINDOW
CHILD
WINDOW
WINDOWTYPE = CHECKBOX;
- SCREENRECT = UPPERLEFT: 288 294, BOTTOMRIGHT: 512 318, CREATIONRESOLUTION: 800 600;
+ SCREENRECT = UPPERLEFT: 288 322, BOTTOMRIGHT: 512 346, CREATIONRESOLUTION: 800 600;
NAME = "OptionsMenu.wnd:CheckBehindBuilding";
STATUS = ENABLED+IMAGE+BORDER;
STYLE = CHECKBOX+MOUSETRACK;
diff --git a/GeneralsMD/Code/Data/dx11shaders.shipped b/GeneralsMD/Code/Data/dx11shaders.shipped
index afcc4a3eb..bf646875a 100644
Binary files a/GeneralsMD/Code/Data/dx11shaders.shipped and b/GeneralsMD/Code/Data/dx11shaders.shipped differ
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
index 75b72c8b4..e99120009 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
@@ -641,6 +641,9 @@ public:
Bool m_skirmishLobbyOnStart; ///< -skirmishlobby: open the skirmish staging room instead of stopping at the main menu
Bool m_optionsMenuOnStart; ///< -optionsmenu: open the options screen over the main menu at startup
Bool m_randomMapsInMenus; ///< -randommaps: offer the generated maps in the map lists (off until the generator is finished)
+ Bool m_mapLight; ///< "MapLight": warm low sun, ground haze and aircraft wakes (Direct3D 11, client only)
+ Bool m_teamGlow; ///< "TeamGlow": bright house colour glows (Direct3D 11, client only)
+ Bool m_waterFoam; ///< "WaterFoam": foam, shore band and the sun's shadow on water (Direct3D 11, client only)
Int m_maxParticleCount; ///< maximum number of particles that can exist
Int m_maxFieldParticleCount; ///< maximum number of field-type particles that can exist (roughly)
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
index 17de244b2..2e90e5c62 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
@@ -1059,6 +1059,9 @@ GlobalData::GlobalData()
m_skirmishLobbyOnStart = FALSE;
m_optionsMenuOnStart = FALSE;
m_randomMapsInMenus = FALSE;
+ m_mapLight = FALSE;
+ m_teamGlow = FALSE;
+ m_waterFoam = FALSE;
m_horizontalScrollSpeedFactor = 1.0;
m_verticalScrollSpeedFactor = 1.0;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
index ff06cb47e..4f9f024fd 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
@@ -125,6 +125,9 @@ OPTION_BOOL_ACCESSORS( m_volumetricSmokeShadows )
OPTION_BOOL_ACCESSORS( m_useCloudMap )
OPTION_BOOL_ACCESSORS( m_smokeFireLighting )
OPTION_BOOL_ACCESSORS( m_explosionDebrisTrails )
+OPTION_BOOL_ACCESSORS( m_mapLight )
+OPTION_BOOL_ACCESSORS( m_teamGlow )
+OPTION_BOOL_ACCESSORS( m_waterFoam )
OPTION_INT_ACCESSORS( m_shadowQuality )
//-----------------------------------------------------------------------------
@@ -529,6 +532,25 @@ const OptionDef TheOptionCatalog[] =
OPTION_BOOL, APPLY_LIVE, 0, 1,
get_m_explosionDebrisTrails, set_m_explosionDebrisTrails },
+ // Three Direct3D 11 looks, all off by default; the menu greys them under -d3d9. Warm light is a
+ // low late afternoon sun put into each map's lights as the map loads (WorldHeightMap), so it waits
+ // for the next map, and a light haze over low ground that aircraft part, pushed every frame
+ // (W3DShaderManager). Team glow marks a house colour mesh as it is recoloured for its side,
+ // which happens as a map's models are made. On Options > Graphics.
+ { "MapLight", OPT_WND( "CheckMapLight" ), "GUI:MapLight",
+ OPTION_BOOL, APPLY_NEXT_MAP, 0, 1,
+ get_m_mapLight, set_m_mapLight },
+
+ { "TeamGlow", OPT_WND( "CheckTeamGlow" ), "GUI:TeamGlow",
+ OPTION_BOOL, APPLY_NEXT_MAP, 0, 1,
+ get_m_teamGlow, set_m_teamGlow },
+
+ // Foam, a shore band and the sun's shadow on rivers and lakes; the water asks every frame. Off
+ // under Classic graphics too. On Options > Effects beside Soft Shorelines.
+ { "WaterFoam", OPT_WND( "CheckWaterFoam" ), "GUI:WaterFoam",
+ OPTION_BOOL, APPLY_LIVE, 0, 1,
+ get_m_waterFoam, set_m_waterFoam },
+
// The size of the sun's depth map. The shadow pass asks for it every frame and the backend makes
// the map again when the size changes, so a new level shows on the next frame. On Options >
// Effects. Classic graphics and -d3d9 draw no map at all.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
index a266a705b..c57f75181 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
@@ -2799,6 +2799,14 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
// checkAudioHardware->winEnable(FALSE);
}
+ // three looks only the Direct3D 11 picture draws; under -d3d9 their boxes keep the saved value, greyed
+ if( !TheGlobalData->m_direct3D11 )
+ {
+ static const char *const direct3D11Only[] = { "MapLight", "TeamGlow", "WaterFoam" };
+ for( Int i = 0; i < (Int)( sizeof( direct3D11Only ) / sizeof( direct3D11Only[ 0 ] ) ); ++i )
+ findOptionWidget( *findOptionDef( direct3D11Only[ i ] ) )->winEnable( FALSE );
+ }
+
// borderless owns the resolution; the list is grey while it is picked
updateResolutionEnabled();
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h
index 3507a8fbf..fed163042 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h
@@ -114,6 +114,9 @@ public:
static Bool filterPreRender(FilterTypes filter, Bool &skipRender, CustomScenePassModes &scenePassMode); ///< Set up at start of render. Only applies to screen filter shaders.
static Bool filterPostRender(FilterTypes filter, enum FilterModes mode, Coord2D &scrollDelta, Bool &doExtraRender); ///< Called after render. Only applies to screen filter shaders.
static Bool filterSetup(FilterTypes filter, enum FilterModes mode);
+ /// The Warm Light haze for this frame (levels, shroud, field step, wakes), once a frame from
+ /// W3DDisplay::draw before the views render, whatever screen filter is running.
+ static void pushProtoHaze(void);
// Support routines for filter methods.
static Bool canRenderToTexture(void) { return (m_oldRenderSurface && m_newRenderSurface);}
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DWater.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DWater.h
index 9778db941..28eda35c6 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DWater.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DWater.h
@@ -198,6 +198,8 @@ protected:
IDirect3DPixelShader9 * m_riverWaterPixelShader; ///<D3D pixel shader.
IDirect3DPixelShader9 * m_trapezoidWaterPixelShader; ///<D3D pixel shader
IDirect3DPixelShader9 * m_reflectionPixelShader; ///<darkens water where the reflection texture holds something
+ IDirect3DPixelShader9 * m_riverWaterFoamPixelShader; ///<the river's bytecode again, named for the D3D11 foam program (WaterFoam)
+ IDirect3DPixelShader9 * m_trapezoidWaterFoamPixelShader; ///<the trapezoid's bytecode again, named for the D3D11 foam program
TextureClass *m_waterSparklesTexture;
Real m_riverXOffset;
Real m_riverYOffset;
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp
index bd1f8c6b4..8f831642f 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp
@@ -974,6 +974,10 @@ int W3DAssetManager::Recolor_Mesh(RenderObjClass *robj, const int color)
strncasecmp(meshName,"HOUSECOLOR", 10) == 0)
{ for (i=0; i<material->Vertex_Material_Count(); i++)
Recolor_Vertex_Material(material->Peek_Vertex_Material(i),color);
+ // The whole mesh is the side's colour, so the whole mesh glows (Direct3D 11 only). The model
+ // is this recoloured prototype's own: Make_Mesh_Unique cloned it.
+ if (TheGlobalData->m_teamGlow)
+ model->Set_Flag(MeshGeometryClass::TEAM_GLOW, true);
didRecolor=1;
}
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
index 441284435..e0d1e6014 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
@@ -2667,6 +2667,10 @@ AGAIN:
if (primaryW3DView && primaryW3DView->get3DCamera())
W3DModelDraw::lightHeadlights(primaryW3DView->get3DCamera()->Get_Position());
+ // Once a frame and before any view draws, so a script's blur or black and white filter
+ // does not freeze the haze the way pushing it from the default filter did.
+ W3DShaderManager::pushProtoHaze();
+
if (TheWaterRenderObj)
TheWaterRenderObj->updateRenderTargetTextures(primaryW3DView->get3DCamera()); //do a render into each texture
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp
index ea83b7a6c..02ce5683a 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp
@@ -110,6 +110,9 @@ void W3DPropBuffer::cull(CameraClass * camera)
W3DPropBuffer::~W3DPropBuffer(void)
{
Int i;
+ for (i=0; i<m_numProps; i++) {
+ REF_PTR_RELEASE(m_props[i].m_robj);
+ }
for (i=0; i<MAX_TYPES; i++) {
REF_PTR_RELEASE(m_propTypes[i].m_robj);
}
@@ -127,6 +130,7 @@ W3DPropBuffer::W3DPropBuffer(void)
{
memset(this, sizeof(W3DPropBuffer), 0);
m_initialized = false;
+ m_numProps = 0;
clearAllProps();
m_light = NEW_REF( LightClass, (LightClass::DIRECTIONAL) );
m_propShroudMaterialPass = NEW_REF(W3DShroudMaterialPassClass,());
@@ -144,8 +148,11 @@ W3DPropBuffer::W3DPropBuffer(void)
//=============================================================================
void W3DPropBuffer::clearAllProps(void)
{
- m_numProps=0;
Int i;
+ for (i=0; i<m_numProps; i++) {
+ REF_PTR_RELEASE(m_props[i].m_robj);
+ }
+ m_numProps=0;
for (i=0; i<MAX_TYPES; i++) {
REF_PTR_RELEASE(m_propTypes[i].m_robj);
m_propTypes[i].m_robjName.clear();
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp
index 61101d71d..547732a8f 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp
@@ -72,6 +72,7 @@
#include "GameClient/Water.h"
#include "GameClient/UiAnimClock.h"
#include "GameLogic/GameLogic.h"
+#include "GameLogic/PolygonTrigger.h"
#include "Common/GlobalData.h"
#include "Common/GameLOD.h"
#include "d3dx9runtime.h"
@@ -83,6 +84,13 @@
#include "dx8caps.h"
#include "Common/GameLOD.h"
#include "benchmark.h"
+#include "Common/GameEngine.h"
+#include "GameClient/Drawable.h"
+#include "GameClient/GameClient.h"
+#include <algorithm>
+#include <map>
+#include <math.h>
+#include <vector>
#include <string.h> // memset, strcpy, strlen
#ifdef _INTERNAL
@@ -260,6 +268,729 @@ static GlowTuning glowTuning(void)
return tuning;
}
+#if defined(_WIN32)
+/* The Warm Light option's ground haze (MapLight, DX11Post_Set_Haze). It lies in the ground below the level most
+ of the map stands on: full at the lowest ground, thinning to nothing PROTO_HAZE_ABOVE_MIDDLE over
+ the median height of the playable cells, never thinner than PROTO_HAZE_MIN_RISE. The median and
+ not the highest ground, because the border walls make every map's highest the same 159: on
+ Alpine Assault half the playable ground is one valley floor at 19, and a haze reaching 0.4 of
+ the way up the relief lay over the whole of it as a milky wash, where on Golden Oasis (median 57)
+ it fills the low plateau and the oasis only. A map whose lowest ground is little below its
+ middle gets a lighter haze, since there it would lie over everything alike. Nothing under the
+ surface of the highest water inside the haze takes any (the water writes no depth, so the haze
+ saw the bed). The colour is a pale warm grey dimmed with the map's own light, so a night map
+ gets a dark one. */
+static const Real PROTO_HAZE_ABOVE_MIDDLE = 4.0f; // how far over the median height the haze reaches
+static const Real PROTO_HAZE_MIN_RISE = 12.0f; // its least depth, in world units
+static const Real PROTO_HAZE_STRENGTH = 0.38f; // most of the haze colour the lowest ground takes
+static const Real PROTO_HAZE_RELIEF = 60.0f; // depth at which the haze is at full strength
+static const Real PROTO_HAZE_REACH = 700.0f; // eye distance at which it stops thickening
+static const Real PROTO_HAZE_COLOUR[3] = { 0.88f, 0.84f, 0.76f };
+
+/** The median height of the playable cells, every second cell each way, in world units. */
+static Real protoHazeMiddle(WorldHeightMap *map)
+{
+ const Int border = map->getBorderSize();
+ const Int width = map->getXExtent();
+ const Int height = map->getYExtent();
+ const UnsignedByte *data = map->getDataPtr();
+ Int counts[256];
+ memset(counts, 0, sizeof(counts));
+ Int total = 0;
+ for (Int y = border; y < height - border; y += 2)
+ {
+ for (Int x = border; x < width - border; x += 2)
+ {
+ ++counts[data[x + y * width]];
+ ++total;
+ }
+ }
+ Int seen = 0;
+ for (Int value = 0; value < 256; ++value)
+ {
+ seen += counts[value];
+ if (seen * 2 >= total)
+ return value * MAP_HEIGHT_SCALE;
+ }
+ return 0.0f;
+}
+
+/* The haze moves. Its patches drift on a fixed wind (the shader's noise, PROTO_HAZE_WIND and
+ PROTO_HAZE_PATCH), and what goes through it leaves a mark: a field of PROTO_FIELD squared cells
+ over PROTO_FIELD_SPAN world units round the camera's look point (six units a cell, fine enough
+ for a tank's track to read), stepped PROTO_FIELD_RATE times a second, that fades over
+ PROTO_FIELD_LIFE seconds, spreads a little each step and is carried by the same wind. The field
+ follows the camera a whole cell at a time, so what is on screen keeps its marks and what scrolls
+ out is dropped. Vehicles on the ground rub a strip along their track. Aircraft over the haze
+ and within PROTO_STIR_AIR_BAND above its top (a jet at cruise height over a valley too, a licence
+ taken for the look) leave wakes instead, below: the haze opens behind them as a wave. Only what the
+ local player can see stamps: a unit under the shroud, hidden or stealthed out of sight leaves
+ nothing, or the haze would give it away. Read from the drawables only (where they are drawn,
+ what kind of thing they are), never from the logic, and it costs the logic nothing. Everything
+ runs on the game's clock (the picture clock under -video), so a pause stops the wind and the
+ marks with the units. */
+static const Int PROTO_FIELD = (Int)DX11_POST_HAZE_FIELD_SIZE;
+static const Real PROTO_FIELD_SPAN = 1536.0f; // world units the field covers each way
+static const Real PROTO_HAZE_WIND[2] = { 11.0f, 4.0f }; // world units a second
+static const Real PROTO_HAZE_PATCH = 1.0f / 320.0f; // one over a patch's size
+static const Real PROTO_HAZE_STIR = 0.85f; // share of the haze a full mark takes away
+static const Real PROTO_HAZE_SUN_WARMTH = 1.0f; // how much warmer it looks toward the sun
+static const Real PROTO_FIELD_RATE = 30.0f; // field steps a second
+static const Real PROTO_FIELD_LIFE = 1.6f; // seconds for a mark to fall to a third (a disc left behind is gone in about three)
+static const Real PROTO_FIELD_SPREAD = 0.10f; // share of a cell's neighbours it takes each step
+static const Real PROTO_STIR_VEHICLE_RADIUS = 16.0f;
+static const Real PROTO_STIR_VEHICLE_RATE = 6.0f; // field a second, at full speed
+static const Real PROTO_STIR_VEHICLE_SPEED = 30.0f; // full speed, world units a second
+static const Real PROTO_STIR_VEHICLE_HEIGHT = 20.0f; // higher off the ground than this stirs nothing
+static const Real PROTO_STIR_AIR_BAND = 400.0f; // an aircraft this far over the haze's top stirs nothing
+
+static Real s_hazeField[2][PROTO_FIELD * PROTO_FIELD];
+static Int s_hazeFieldCurrent = 0;
+static unsigned char s_hazeFieldBytes[PROTO_FIELD * PROTO_FIELD];
+static WorldHeightMap *s_hazeFieldMap = NULL;
+static Int s_hazeFieldCellX = 0; // the field's origin, in whole cells of the world
+static Int s_hazeFieldCellY = 0;
+/* Aircraft wakes. Each aircraft over the haze keeps a trail of where it was, a point every
+ PROTO_TRAIL_EVERY seconds for the last PROTO_WAKE_LIFE, and every frame the shader gets the path
+ from the aircraft (moved on from the last step by its speed) back along that trail as segments.
+ Behind it the haze parts in a narrow V, PROTO_WAKE_ANGLE_SLOW degrees each side of the path for
+ a slow flyer down to PROTO_WAKE_ANGLE_FAST at PROTO_WAKE_FAST world units a second, a vortex
+ PROTO_WAKE_VORTEX across rolling along each arm, as long as the path it flew in PROTO_WAKE_LIFE.
+ One whose trail took it less than PROTO_WAKE_HOVER_SPEED a second over the last
+ PROTO_WAKE_HOVER_SPAN or more hovers: its rotor wash pushes two rings of turbulence out from it,
+ PROTO_RIPPLE_REACH far every PROTO_RIPPLE_PERIOD seconds, half a period apart.
+ The wake comes out straight under the aircraft, the haze being on the ground. Its height over the
+ haze's top sets it: skimming the haze the wake is narrow, sharp and strong; climbing, the V and the
+ rings open wider (PROTO_WAKE_HIGH_WIDEN more at the band's top, in a straight line), the shader
+ softens it and the strength falls on a smoothstep to nothing at PROTO_STIR_AIR_BAND. */
+static const Int PROTO_TRAIL_POINTS = 14;
+static const Real PROTO_TRAIL_EVERY = 0.2f;
+static const Real PROTO_WAKE_LIFE = 2.8f;
+static const Real PROTO_WAKE_ANGLE_SLOW = 18.0f;
+static const Real PROTO_WAKE_ANGLE_FAST = 10.0f;
+static const Real PROTO_WAKE_FAST = 250.0f;
+static const Real PROTO_WAKE_VORTEX = 7.0f;
+static const Real PROTO_WAKE_OPEN_SOFT = 12.0f;
+static const Real PROTO_WAKE_HOVER_SPEED = 15.0f;
+static const Real PROTO_WAKE_HOVER_SPAN = 0.6f;
+static const Real PROTO_WAKE_LANDED_HEIGHT = 10.0f; // lower over the ground than this is landed, no wake
+static const Real PROTO_WAKE_HIGH_WIDEN = 2.0f; // how much wider than a skimming wake one at the band's top is
+static const Real PROTO_RIPPLE_REACH = 70.0f;
+static const Real PROTO_RIPPLE_PERIOD = 1.4f;
+
+/** A trail point: where the aircraft was (the wake lies straight under it), the clock it was there
+ at, and the wake's strength and width for its height then. Fixed once laid, so a turn, a climb or
+ the camera moving after it moves only the newest end. */
+enum { PROTO_POINT_X, PROTO_POINT_Y, PROTO_POINT_AT, PROTO_POINT_STRENGTH, PROTO_POINT_WIDTH, PROTO_POINT_FIELDS };
+
+/** Where a stirring drawable was at the last step, its speed then, and for an aircraft the wake it
+ is laying now (strength, 0 for none, and width) and its trail, newest first. Kept from step to
+ step in place, so a step allocates only for a drawable it has not seen before; step says which
+ step last saw it. An aircraft that stops laying (out of the haze's band, landed, fogged, hidden,
+ gone) keeps its entry while the trail it laid lives, and the trail fades out where it lies. */
+struct ProtoHazeSeen
+{
+ Coord3D pos;
+ Real velX;
+ Real velY;
+ Real seenAt;
+ Real wake;
+ Real wakeWidth;
+ Real trail[PROTO_TRAIL_POINTS][PROTO_POINT_FIELDS];
+ Int trailCount;
+ Int step;
+};
+
+/** The wake an aircraft this far over the haze's top lays: full strength and its narrowest at the
+ top or under it, nothing at PROTO_STIR_AIR_BAND. */
+static Real protoWakeStrength(Real over)
+{
+ const Real high = min(max(over / PROTO_STIR_AIR_BAND, 0.0f), 1.0f);
+ return 1.0f - high * high * (3.0f - 2.0f * high);
+}
+
+static Real protoWakeWidth(Real over)
+{
+ return 1.0f + PROTO_WAKE_HIGH_WIDEN * min(max(over / PROTO_STIR_AIR_BAND, 0.0f), 1.0f);
+}
+
+static std::map<DrawableID, ProtoHazeSeen> s_hazeLastSeen;
+static Int s_hazeStepNumber = 0;
+static Real s_hazeLastClock = -1.0f;
+static Real s_hazeSeconds = 0.0f;
+static Real s_hazeStepDue = 0.0f;
+
+/** The points of a trail still inside the wake's life, moved to start at kept; the new count. The
+ two may be one trail, kept no further on than the point read. */
+static Int keepProtoTrail(const Real (*from)[PROTO_POINT_FIELDS], Int count, Real (*to)[PROTO_POINT_FIELDS], Int kept)
+{
+ for (Int index = 0; index < count && kept < PROTO_TRAIL_POINTS; ++index)
+ {
+ const Real age = s_hazeSeconds - from[index][PROTO_POINT_AT];
+ if (age < 0.0f || age > PROTO_WAKE_LIFE)
+ break;
+ memmove(to[kept], from[index], sizeof(to[kept]));
+ ++kept;
+ }
+ return kept;
+}
+
+/** A new newest point for an aircraft at x, y laying a wake of this strength and width. */
+static void pushProtoTrail(ProtoHazeSeen &entry, Real x, Real y, Real strength, Real width)
+{
+ Real older[PROTO_TRAIL_POINTS][PROTO_POINT_FIELDS];
+ memcpy(older, entry.trail, sizeof(older));
+ entry.trailCount = keepProtoTrail(older, entry.trailCount, entry.trail, 1);
+ entry.trail[0][PROTO_POINT_X] = x;
+ entry.trail[0][PROTO_POINT_Y] = y;
+ entry.trail[0][PROTO_POINT_AT] = s_hazeSeconds;
+ entry.trail[0][PROTO_POINT_STRENGTH] = strength;
+ entry.trail[0][PROTO_POINT_WIDTH] = width;
+}
+
+/** The game's time in seconds as the picture shows it: the logic frame and how far into the next
+ one the blend is, or the picture's own time while -video records. */
+static Real protoHazeClock(void)
+{
+ if (GameEngine_isVideoFrame())
+ return (Real)GameEngine_pictureMilliseconds() * 0.001f;
+ return ((Real)TheGameClient->getFrame() + GameEngine_logicTickFraction()) / (Real)LOGICFRAMES_PER_SECOND;
+}
+
+/** A rectangle of field cells, both ends inside; empty when x1 < x0. */
+struct ProtoFieldRect
+{
+ Int x0, y0, x1, y1;
+ Bool isEmpty(void) const { return x1 < x0 || y1 < y0; }
+ void clear(void) { x0 = y0 = PROTO_FIELD; x1 = y1 = -1; }
+ void add(Int ax0, Int ay0, Int ax1, Int ay1)
+ {
+ x0 = min(x0, ax0); y0 = min(y0, ay0); x1 = max(x1, ax1); y1 = max(y1, ay1);
+ }
+};
+
+/** Adds amount to the field in a soft disc of the given world radius about a world point, and
+ grows marked to cover it. */
+static void stampProtoHaze(Real *field, ProtoFieldRect &marked, Real cellsPerUnitX, Real cellsPerUnitY,
+ Real originX, Real originY, Real x, Real y, Real radius, Real amount)
+{
+ const Real cx = (x - originX) * cellsPerUnitX;
+ const Real cy = (y - originY) * cellsPerUnitY;
+ const Real rx = radius * cellsPerUnitX;
+ const Real ry = radius * cellsPerUnitY;
+ // off the field's outer ring of cells, which stepProtoHaze's loop reads as clear neighbours only
+ const Int x0 = max((Int)(cx - rx), 1);
+ const Int x1 = min((Int)(cx + rx) + 1, PROTO_FIELD - 2);
+ const Int y0 = max((Int)(cy - ry), 1);
+ const Int y1 = min((Int)(cy + ry) + 1, PROTO_FIELD - 2);
+ for (Int j = y0; j <= y1; ++j)
+ {
+ for (Int i = x0; i <= x1; ++i)
+ {
+ const Real dx = ((Real)i + 0.5f - cx) / rx;
+ const Real dy = ((Real)j + 0.5f - cy) / ry;
+ const Real fall = 1.0f - (dx * dx + dy * dy);
+ if (fall <= 0.0f)
+ continue;
+ Real &cell = field[i + j * PROTO_FIELD];
+ cell = min(cell + amount * fall, 1.0f);
+ }
+ }
+ if (x0 <= x1 && y0 <= y1)
+ marked.add(x0, y0, x1, y1);
+}
+
+// The cells holding a mark, and the cells whose byte may not be zero. A step works over the first
+// and one cell round it only (the spread and the drift reach no further), so a quiet field costs
+// nothing and a battle costs its own corner of it. The buffer a step writes into is clear all over
+// before it starts: each step clears the cells it read once it is done with them.
+static ProtoFieldRect s_hazeActive = { PROTO_FIELD, PROTO_FIELD, -1, -1 };
+static ProtoFieldRect s_hazeWritten = { PROTO_FIELD, PROTO_FIELD, -1, -1 };
+
+/** Moves the marks by whole cells as the field follows the camera: the cell (x, y) takes what was at
+ (x + moveX, y + moveY), and what had no cell to come from starts clear. */
+static void shiftProtoHaze(Int moveX, Int moveY)
+{
+ if (s_hazeActive.isEmpty())
+ return;
+ Real *field = s_hazeField[s_hazeFieldCurrent];
+ Real *spare = s_hazeField[1 - s_hazeFieldCurrent];
+ const ProtoFieldRect old = s_hazeActive;
+ s_hazeActive.x0 = max(old.x0 - moveX, 1);
+ s_hazeActive.x1 = min(old.x1 - moveX, PROTO_FIELD - 2);
+ s_hazeActive.y0 = max(old.y0 - moveY, 1);
+ s_hazeActive.y1 = min(old.y1 - moveY, PROTO_FIELD - 2);
+ if (!s_hazeActive.isEmpty())
+ {
+ for (Int y = s_hazeActive.y0; y <= s_hazeActive.y1; ++y)
+ memcpy(spare + s_hazeActive.x0 + y * PROTO_FIELD, field + (s_hazeActive.x0 + moveX) + (y + moveY) * PROTO_FIELD,
+ (s_hazeActive.x1 - s_hazeActive.x0 + 1) * sizeof(Real));
+ }
+ else
+ {
+ s_hazeActive.clear();
+ }
+ for (Int y = old.y0; y <= old.y1; ++y)
+ memset(field + old.x0 + y * PROTO_FIELD, 0, (old.x1 - old.x0 + 1) * sizeof(Real));
+ s_hazeFieldCurrent = 1 - s_hazeFieldCurrent;
+}
+
+/** One field step: follow the camera, fade, drift on the wind and spread, then what moved since the
+ last step. */
+static void stepProtoHaze(Real top, Real dt)
+{
+ WorldHeightMap *map = TheTerrainRenderObject->getMap();
+ if (map != s_hazeFieldMap)
+ {
+ s_hazeFieldMap = map;
+ memset(s_hazeField, 0, sizeof(s_hazeField));
+ memset(s_hazeFieldBytes, 0, sizeof(s_hazeFieldBytes));
+ s_hazeActive.clear();
+ s_hazeWritten.clear();
+ s_hazeLastSeen.clear();
+ DX11Post_Set_Haze_Field(s_hazeFieldBytes);
+ }
+ const Real cellSize = PROTO_FIELD_SPAN / (Real)PROTO_FIELD;
+ const Real cellsPerUnitX = 1.0f / cellSize;
+ const Real cellsPerUnitY = cellsPerUnitX;
+ Coord3D look;
+ TheTacticalView->getPosition(&look);
+ const Int cellX = (Int)floor(look.x / cellSize) - PROTO_FIELD / 2;
+ const Int cellY = (Int)floor(look.y / cellSize) - PROTO_FIELD / 2;
+ const Int moveCellsX = cellX - s_hazeFieldCellX;
+ const Int moveCellsY = cellY - s_hazeFieldCellY;
+ s_hazeFieldCellX = cellX;
+ s_hazeFieldCellY = cellY;
+ if (moveCellsX != 0 || moveCellsY != 0)
+ shiftProtoHaze(moveCellsX, moveCellsY);
+ const Real originX = (Real)cellX * cellSize;
+ const Real originY = (Real)cellY * cellSize;
+
+ const Real *from = s_hazeField[s_hazeFieldCurrent];
+ Real *to = s_hazeField[1 - s_hazeFieldCurrent];
+ const Real keep = (Real)exp(-dt / PROTO_FIELD_LIFE);
+ // the wind moves a mark well under a cell a step, so a bilinear read that far upwind is the drift
+ const Real shiftX = PROTO_HAZE_WIND[0] * dt * cellsPerUnitX;
+ const Real shiftY = PROTO_HAZE_WIND[1] * dt * cellsPerUnitY;
+ const Int stepX = (shiftX >= 0.0f) ? -1 : 1;
+ const Int stepY = (shiftY >= 0.0f) ? -1 : 1;
+ const Real fx = (Real)fabs(shiftX);
+ const Real fy = (Real)fabs(shiftY);
+ const Real w00 = keep * (1.0f - PROTO_FIELD_SPREAD) * (1.0f - fx) * (1.0f - fy);
+ const Real w10 = keep * (1.0f - PROTO_FIELD_SPREAD) * fx * (1.0f - fy);
+ const Real w01 = keep * (1.0f - PROTO_FIELD_SPREAD) * (1.0f - fx) * fy;
+ const Real w11 = keep * (1.0f - PROTO_FIELD_SPREAD) * fx * fy;
+ const Real wAround = keep * PROTO_FIELD_SPREAD * 0.25f;
+
+ // the marks, one cell wider; everything outside is clear in both buffers
+ ProtoFieldRect work;
+ work.clear();
+ if (!s_hazeActive.isEmpty())
+ work.add(max(s_hazeActive.x0 - 1, 1), max(s_hazeActive.y0 - 1, 1),
+ min(s_hazeActive.x1 + 1, PROTO_FIELD - 2), min(s_hazeActive.y1 + 1, PROTO_FIELD - 2));
+ ProtoFieldRect live;
+ live.clear();
+ // No mark ever lies on the field's outer ring of cells (the stamps and the shift keep off it), so
+ // every cell worked on has its four neighbours inside and the loop needs no clamping.
+ for (Int j = work.y0; j <= work.y1; ++j)
+ {
+ const Real *row = from + j * PROTO_FIELD;
+ const Real *rowUp = row - PROTO_FIELD;
+ const Real *rowDown = row + PROTO_FIELD;
+ const Real *rowWind = row + stepY * PROTO_FIELD;
+ Real *out = to + j * PROTO_FIELD;
+ Int rowLow = PROTO_FIELD;
+ Int rowHigh = -1;
+ for (Int i = work.x0; i <= work.x1; ++i)
+ {
+ Real value = w00 * row[i] + w10 * row[i + stepX] + w01 * rowWind[i] + w11 * rowWind[i + stepX]
+ + wAround * (row[i - 1] + row[i + 1] + rowUp[i] + rowDown[i]);
+ // a mark faded under a byte's half step is gone, so the field goes quiet again
+ if (value < 0.002f)
+ {
+ value = 0.0f;
+ }
+ else
+ {
+ if (i < rowLow)
+ rowLow = i;
+ rowHigh = i;
+ }
+ out[i] = value;
+ }
+ if (rowHigh >= 0)
+ live.add(rowLow, j, rowHigh, j);
+ }
+ // the buffer read is the next step's to write into, so it goes back to clear
+ if (!s_hazeActive.isEmpty())
+ {
+ for (Int j = s_hazeActive.y0; j <= s_hazeActive.y1; ++j)
+ memset((Real *)from + s_hazeActive.x0 + j * PROTO_FIELD, 0, (s_hazeActive.x1 - s_hazeActive.x0 + 1) * sizeof(Real));
+ }
+ s_hazeFieldCurrent = 1 - s_hazeFieldCurrent;
+
+ ++s_hazeStepNumber;
+ for (Drawable *draw = TheGameClient->firstDrawable(); draw != NULL; draw = draw->getNextDrawable())
+ {
+ const Bool air = draw->isKindOf(KINDOF_AIRCRAFT);
+ if (!air && !draw->isKindOf(KINDOF_VEHICLE))
+ continue;
+ if (draw->getFullyObscuredByShroud() || draw->isDrawableEffectivelyHidden()
+ || draw->getStealthLook() == STEALTHLOOK_INVISIBLE)
+ continue;
+ const Coord3D pos = *draw->getPosition();
+ std::map<DrawableID, ProtoHazeSeen>::iterator found = s_hazeLastSeen.find(draw->getID());
+ const Bool fresh = found == s_hazeLastSeen.end();
+ ProtoHazeSeen &now = fresh ? s_hazeLastSeen[draw->getID()] : found->second;
+ // what the last step saw, before this one writes over it
+ const ProtoHazeSeen before = now;
+ now.pos = pos;
+ now.velX = 0.0f;
+ now.velY = 0.0f;
+ now.seenAt = s_hazeSeconds;
+ now.wake = 0.0f;
+ now.trailCount = fresh ? 0 : keepProtoTrail(before.trail, before.trailCount, now.trail, 0);
+ now.step = s_hazeStepNumber;
+ // one the last step did not see (new, or back from the fog) starts its motion over; a trail
+ // it laid before going keeps fading where it lies
+ if (fresh || before.step != s_hazeStepNumber - 1)
+ continue;
+ const Real moveX = pos.x - before.pos.x;
+ const Real moveY = pos.y - before.pos.y;
+ const Real moved = (Real)sqrt(moveX * moveX + moveY * moveY);
+ const Real speed = moved / dt;
+
+ if (air)
+ {
+ now.velX = moveX / dt;
+ now.velY = moveY / dt;
+ const Real ground = TheTerrainRenderObject->getHeightMapHeight(pos.x, pos.y, NULL);
+ const Real over = pos.z - top;
+ // one parked on a runway or a pad is no wake; a base's planes took every slot
+ if (ground <= top && over < PROTO_STIR_AIR_BAND && pos.z - ground >= PROTO_WAKE_LANDED_HEIGHT)
+ {
+ now.wake = protoWakeStrength(over);
+ now.wakeWidth = protoWakeWidth(over);
+ }
+ // the trail: the last one's points still inside the wake's life, and this one in front
+ // once the newest is old enough, while it lays a wake; one that just stopped lays a last
+ // point where it stopped, so the end that was following it stays there
+ if (now.wake > 0.0f)
+ {
+ if (now.trailCount == 0 || s_hazeSeconds - now.trail[0][PROTO_POINT_AT] >= PROTO_TRAIL_EVERY
+ || s_hazeSeconds < now.trail[0][PROTO_POINT_AT])
+ pushProtoTrail(now, pos.x, pos.y, now.wake, now.wakeWidth);
+ }
+ else if (before.wake > 0.0f)
+ {
+ pushProtoTrail(now, pos.x, pos.y, before.wake, before.wakeWidth);
+ }
+ continue;
+ }
+ const Real ground = TheTerrainRenderObject->getHeightMapHeight(pos.x, pos.y, NULL);
+ if (ground > top)
+ continue;
+ if (pos.z - ground >= PROTO_STIR_VEHICLE_HEIGHT)
+ continue;
+ const Real radius = PROTO_STIR_VEHICLE_RADIUS;
+ const Real rate = PROTO_STIR_VEHICLE_RATE * min(speed / PROTO_STIR_VEHICLE_SPEED, 1.0f);
+ if (rate <= 0.0f)
+ continue;
+ // along the stretch moved since the last step, so a quick one leaves a strip and not beads
+ const Int dabs = min(max((Int)(moved / (radius * 0.5f)) + 1, 1), 8);
+ for (Int dab = 0; dab < dabs; ++dab)
+ {
+ const Real along = ((Real)dab + 1.0f) / (Real)dabs;
+ stampProtoHaze(to, live, cellsPerUnitX, cellsPerUnitY, originX, originY,
+ before.pos.x + moveX * along, before.pos.y + moveY * along, radius, rate * dt / (Real)dabs);
+ }
+ }
+ // what this step did not see (fogged, hidden, gone) lays nothing, and is forgotten once the wake
+ // it laid has faded
+ for (std::map<DrawableID, ProtoHazeSeen>::iterator it = s_hazeLastSeen.begin(); it != s_hazeLastSeen.end(); )
+ {
+ ProtoHazeSeen &gone = it->second;
+ if (gone.step != s_hazeStepNumber)
+ {
+ // the last place it was laying from, as for one that stopped in sight
+ if (gone.wake > 0.0f)
+ pushProtoTrail(gone, gone.pos.x, gone.pos.y, gone.wake, gone.wakeWidth);
+ gone.wake = 0.0f;
+ gone.velX = 0.0f;
+ gone.velY = 0.0f;
+ gone.trailCount = keepProtoTrail(gone.trail, gone.trailCount, gone.trail, 0);
+ if (gone.trailCount == 0)
+ {
+ s_hazeLastSeen.erase(it++);
+ continue;
+ }
+ }
+ ++it;
+ }
+
+ // the bytes that were not zero and the ones that may not be now; nothing to send when both are
+ // empty, which is a field with nothing going on
+ ProtoFieldRect bytes = s_hazeWritten;
+ if (!live.isEmpty())
+ bytes.add(live.x0, live.y0, live.x1, live.y1);
+ if (!bytes.isEmpty())
+ {
+ for (Int j = bytes.y0; j <= bytes.y1; ++j)
+ {
+ const Real *in = to + j * PROTO_FIELD;
+ unsigned char *out = s_hazeFieldBytes + j * PROTO_FIELD;
+ for (Int i = bytes.x0; i <= bytes.x1; ++i)
+ out[i] = (unsigned char)(in[i] * 255.0f + 0.5f);
+ }
+ DX11Post_Set_Haze_Field(s_hazeFieldBytes);
+ }
+ s_hazeActive = live;
+ s_hazeWritten = live;
+}
+
+/** The haze's motion for this frame, and a field step when one is due. */
+static void stirProtoHaze(Real top)
+{
+ const Real now = protoHazeClock();
+ Real elapsed = now - s_hazeLastClock;
+ s_hazeLastClock = now;
+ // the first frame, a new match (the clock starts again) or a long hitch moves nothing; a pause
+ // is no time at all
+ if (elapsed < 0.0f || elapsed > 0.25f)
+ elapsed = 0.0f;
+ s_hazeSeconds += elapsed;
+ // the drift wraps well before the noise's hash runs out of float precision
+ if (s_hazeSeconds > 4000.0f)
+ s_hazeSeconds -= 4000.0f;
+ s_hazeStepDue += elapsed;
+ if (s_hazeStepDue >= 1.0f / PROTO_FIELD_RATE)
+ {
+ stepProtoHaze(top, s_hazeStepDue);
+ s_hazeStepDue = 0.0f;
+ }
+
+ const Real cellSize = PROTO_FIELD_SPAN / (Real)PROTO_FIELD;
+ const float rect[4] = { (Real)s_hazeFieldCellX * cellSize, (Real)s_hazeFieldCellY * cellSize,
+ 1.0f / PROTO_FIELD_SPAN, 1.0f / PROTO_FIELD_SPAN };
+
+ const GlobalData::TerrainLighting &sun = TheGlobalData->m_terrainObjectsLighting[TheGlobalData->m_timeOfDay][0];
+ const Real length = (Real)sqrt(sun.lightPos.x * sun.lightPos.x + sun.lightPos.y * sun.lightPos.y
+ + sun.lightPos.z * sun.lightPos.z);
+ const float towardSun[3] = { -sun.lightPos.x / length, -sun.lightPos.y / length, -sun.lightPos.z / length };
+ const Real daylight = (0.299f * sun.diffuse.red + 0.587f * sun.diffuse.green + 0.114f * sun.diffuse.blue - 0.25f) / 0.5f;
+ const Real warmth = PROTO_HAZE_SUN_WARMTH * max(min(daylight, 1.0f), 0.0f);
+
+ DX11Post_Set_Haze_Motion(rect, PROTO_HAZE_WIND[0] * s_hazeSeconds, PROTO_HAZE_WIND[1] * s_hazeSeconds,
+ PROTO_HAZE_PATCH, PROTO_HAZE_STIR, towardSun, warmth);
+
+ // each aircraft's wake: from where it is now (the last step's place moved on by its speed) back
+ // along its trail, or two rings round it while it hovers; nearest the camera first, so the
+ // segments run out on the aircraft furthest away
+ float wakes[DX11_POST_HAZE_WAKE_LIMIT][8];
+ unsigned wakeCount = 0;
+ Coord3D look;
+ TheTacticalView->getPosition(&look);
+ // kept between frames, so a frame allocates nothing once it has held the most flyers
+ static std::vector<std::pair<Real, const ProtoHazeSeen *> > flyers;
+ flyers.clear();
+ for (std::map<DrawableID, ProtoHazeSeen>::const_iterator it = s_hazeLastSeen.begin(); it != s_hazeLastSeen.end(); ++it)
+ {
+ if (it->second.trailCount == 0)
+ continue;
+ const Real offX = it->second.pos.x - look.x;
+ const Real offY = it->second.pos.y - look.y;
+ flyers.push_back(std::make_pair(offX * offX + offY * offY, &it->second));
+ }
+ std::sort(flyers.begin(), flyers.end());
+ for (size_t order = 0; order < flyers.size() && wakeCount < DX11_POST_HAZE_WAKE_LIMIT; ++order)
+ {
+ const ProtoHazeSeen &flyer = *flyers[order].second;
+ // Laying a wake now, the newest end is the aircraft itself; stopped (out of the band, landed,
+ // fogged, gone), the wake keeps its last point as its newest end and fades out from there by
+ // the time since that point was laid, wherever the aircraft went.
+ const Bool laying = flyer.wake > 0.0f;
+ const Real *newest = flyer.trail[0];
+ const Real newestAge = max(s_hazeSeconds - newest[PROTO_POINT_AT], 0.0f);
+ const Real strength = laying ? flyer.wake : newest[PROTO_POINT_STRENGTH];
+ const Real width = laying ? flyer.wakeWidth : newest[PROTO_POINT_WIDTH];
+ const Real since = min(max(s_hazeSeconds - flyer.seenAt, 0.0f), 0.1f);
+ // straight under the aircraft (the last step's place moved on by its speed), the haze being
+ // on the ground; every trail point keeps the place it was laid at, so the wake stays where it
+ // was left and the aircraft moves on
+ const Real tipX = laying ? flyer.pos.x + flyer.velX * since : newest[PROTO_POINT_X];
+ const Real tipY = laying ? flyer.pos.y + flyer.velY * since : newest[PROTO_POINT_Y];
+ const Real speed = (Real)sqrt(flyer.velX * flyer.velX + flyer.velY * flyer.velY);
+ // Hovering goes by how far it got over the whole trail, not by the last step: a hovering
+ // helicopter sways and slides, and stepped it reads faster than the hover speed while going
+ // nowhere, which drew a wedge folded up under itself and no rings.
+ Real travel = speed;
+ if (flyer.trailCount > 0)
+ {
+ const Real *oldest = flyer.trail[flyer.trailCount - 1];
+ const Real age = s_hazeSeconds - oldest[PROTO_POINT_AT];
+ const Real awayX = flyer.pos.x - oldest[PROTO_POINT_X];
+ const Real awayY = flyer.pos.y - oldest[PROTO_POINT_Y];
+ if (age >= PROTO_WAKE_HOVER_SPAN)
+ travel = (Real)sqrt(awayX * awayX + awayY * awayY) / age;
+ }
+ if (travel < PROTO_WAKE_HOVER_SPEED)
+ {
+ // left behind, the rings die down over the wake's life where it hovered last
+ const Real left = laying ? 1.0f : max(1.0f - newestAge / PROTO_WAKE_LIFE, 0.0f);
+ for (Int ripple = 0; ripple < 2 && wakeCount < DX11_POST_HAZE_WAKE_LIMIT && left > 0.0f; ++ripple)
+ {
+ Real phase = s_hazeSeconds / PROTO_RIPPLE_PERIOD + 0.5f * (Real)ripple;
+ phase -= (Real)floor(phase);
+ float *wake = wakes[wakeCount++];
+ wake[0] = wake[2] = tipX;
+ wake[1] = wake[3] = tipY;
+ wake[4] = phase * PROTO_RIPPLE_REACH * width;
+ wake[5] = -1.0f;
+ wake[6] = strength * left;
+ wake[7] = phase;
+ }
+ continue;
+ }
+ // a narrow V, narrower the faster it flies
+ const Real quick = min(max((speed - PROTO_WAKE_HOVER_SPEED) / (PROTO_WAKE_FAST - PROTO_WAKE_HOVER_SPEED), 0.0f), 1.0f);
+ const Real tangent = (Real)tan((PROTO_WAKE_ANGLE_SLOW + (PROTO_WAKE_ANGLE_FAST - PROTO_WAKE_ANGLE_SLOW) * quick) * PI / 180.0f);
+ // the trail's travel can call it flying on a step it stood still
+ Real perLength = 1.0f / (max(speed, PROTO_WAKE_HOVER_SPEED) * PROTO_WAKE_LIFE);
+ Real nearX = tipX;
+ Real nearY = tipY;
+ // Left behind, the newest end is already as old as its point: the shader's age runs on the
+ // distance behind the newest end, so the time since then goes in as a distance in front.
+ const Real lead = laying ? 0.0f : newestAge / (PROTO_WAKE_LIFE * perLength);
+ Real behind = lead;
+ const unsigned firstWake = wakeCount;
+ for (Int index = laying ? 0 : 1; index < flyer.trailCount && wakeCount < DX11_POST_HAZE_WAKE_LIMIT; ++index)
+ {
+ const Real farX = flyer.trail[index][PROTO_POINT_X];
+ const Real farY = flyer.trail[index][PROTO_POINT_Y];
+ const Real length = (Real)sqrt((farX - nearX) * (farX - nearX) + (farY - nearY) * (farY - nearY));
+ if (length < 1.0f)
+ continue;
+ float *wake = wakes[wakeCount++];
+ wake[0] = farX;
+ wake[1] = farY;
+ wake[2] = nearX;
+ wake[3] = nearY;
+ wake[4] = behind;
+ // as wide and as strong as the height it was laid at
+ wake[5] = tangent * flyer.trail[index][PROTO_POINT_WIDTH];
+ wake[6] = flyer.trail[index][PROTO_POINT_STRENGTH];
+ wake[7] = perLength;
+ behind += length;
+ nearX = farX;
+ nearY = farY;
+ }
+ // The wake has faded out by the trail's last point, however short the trail is against the
+ // speed (one speeding up, one cut off by the segment limit): ending at full strength, the last
+ // segment's square end drew a straight edge across the strip. Left behind, the trail's own
+ // length still measures from the newest end, so the lead keeps growing with the clock.
+ const Real span = behind - lead;
+ if (span > 1.0f)
+ {
+ const Real least = 1.0f / span;
+ if (perLength < least)
+ {
+ for (unsigned index = firstWake; index < wakeCount; ++index)
+ {
+ wakes[index][4] = (wakes[index][4] - lead) + lead * perLength / least;
+ wakes[index][7] = least;
+ }
+ }
+ }
+ }
+ DX11Post_Set_Haze_Wakes(wakes, wakeCount, PROTO_WAKE_VORTEX, PROTO_WAKE_OPEN_SOFT, s_hazeSeconds);
+}
+
+// The haze's levels hold for the whole match (the ground and the water areas do not move), so they
+// are worked out once a map: the median walks a quarter of the height map's cells. The shell map
+// and the match's are made one after the other and may land at the same address, so the key is the
+// map, its samples and its size together.
+// ponytail: a new map with the old one's address, sample buffer and size all at once keeps the old
+// levels; key on a map load counter if that ever shows.
+static WorldHeightMap *s_hazeLevelsMap = NULL;
+static const UnsignedByte *s_hazeLevelsData = NULL;
+static Int s_hazeLevelsWidth = 0;
+static Int s_hazeLevelsHeight = 0;
+static Real s_hazeLevelTop = 0.0f;
+static Real s_hazeLevelRise = PROTO_HAZE_MIN_RISE;
+static Real s_hazeLevelWater = -1.0e6f;
+
+static void pushProtoHazeFrame(void)
+{
+ Real strength = 0.0f;
+ Real top = 0.0f;
+ Real rise = PROTO_HAZE_MIN_RISE;
+ Real water = -1.0e6f;
+ float colour[3] = { PROTO_HAZE_COLOUR[0], PROTO_HAZE_COLOUR[1], PROTO_HAZE_COLOUR[2] };
+ if (TheTerrainRenderObject != NULL && TheTerrainRenderObject->getMap() != NULL)
+ {
+ WorldHeightMap *map = TheTerrainRenderObject->getMap();
+ if (map != s_hazeLevelsMap || map->getDataPtr() != s_hazeLevelsData
+ || map->getXExtent() != s_hazeLevelsWidth || map->getYExtent() != s_hazeLevelsHeight)
+ {
+ s_hazeLevelsMap = map;
+ s_hazeLevelsData = map->getDataPtr();
+ s_hazeLevelsWidth = map->getXExtent();
+ s_hazeLevelsHeight = map->getYExtent();
+ const Real low = TheTerrainRenderObject->getMinHeight();
+ s_hazeLevelRise = max(protoHazeMiddle(map) + PROTO_HAZE_ABOVE_MIDDLE - low, PROTO_HAZE_MIN_RISE);
+ s_hazeLevelTop = low + s_hazeLevelRise;
+ s_hazeLevelWater = -1.0e6f;
+ for (const PolygonTrigger *area = PolygonTrigger::getFirstPolygonTrigger(); area; area = area->getNext())
+ {
+ if (!area->isWaterArea() || area->getNumPoints() < 3)
+ continue;
+ const Real surface = (Real)area->getPoint(0)->z;
+ if (surface < s_hazeLevelTop && surface > s_hazeLevelWater)
+ s_hazeLevelWater = surface;
+ }
+ }
+ rise = s_hazeLevelRise;
+ top = s_hazeLevelTop;
+ water = s_hazeLevelWater;
+ strength = PROTO_HAZE_STRENGTH * (0.35f + 0.65f * min(rise / PROTO_HAZE_RELIEF, 1.0f));
+
+ const GlobalData::TerrainLighting &sun = TheGlobalData->m_terrainLighting[TheGlobalData->m_timeOfDay][0];
+ const Real light = 0.299f * (sun.ambient.red + sun.diffuse.red) + 0.587f * (sun.ambient.green + sun.diffuse.green)
+ + 0.114f * (sun.ambient.blue + sun.diffuse.blue);
+ const Real dim = max(min(light, 1.0f), 0.3f);
+ colour[0] *= dim;
+ colour[1] *= dim;
+ colour[2] *= dim;
+ }
+ DX11Post_Set_Haze(colour, top, rise, strength, PROTO_HAZE_REACH, water);
+
+ // The fog the terrain draws, through the terrain's own mapping (ShroudTextureShader::set): the
+ // texture starts a cell before the draw origin, a texel to a cell.
+ W3DShroud *shroud = (TheTerrainRenderObject != NULL) ? TheTerrainRenderObject->getShroud() : NULL;
+ if (shroud != NULL && shroud->getShroudTexture() != NULL)
+ {
+ const float shroudRect[4] = { shroud->getDrawOriginX() - shroud->getCellWidth(), shroud->getDrawOriginY() - shroud->getCellHeight(),
+ 1.0f / (shroud->getCellWidth() * shroud->getTextureWidth()), 1.0f / (shroud->getCellHeight() * shroud->getTextureHeight()) };
+ Direct3D11_Set_Haze_Shroud(shroud->getShroudTexture()->Peek_D3D_Base_Texture(), shroudRect);
+ }
+ else
+ {
+ const float wholeRect[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
+ Direct3D11_Set_Haze_Shroud(NULL, wholeRect);
+ }
+ if (strength > 0.0f)
+ stirProtoHaze(top);
+}
+#endif
+
+void W3DShaderManager::pushProtoHaze(void)
+{
+#if defined(_WIN32)
+ if (TheGlobalData->m_mapLight && Direct3D11_Is_Active())
+ pushProtoHazeFrame();
+#endif
+}
+
/** The fixed-function bloom's strength, which is zero on Direct3D 11: there the post chain's own
bloom in dx11post.cpp follows the option instead, and running this one too would stack two
glows. Everywhere else it is the option. */
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp
index 420f8bc2f..6260de1d3 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp
@@ -215,11 +215,37 @@ void doSkyBoxSet(Bool startDraw)
#define AMP_SCALE2 (10.0f/120.0f)
#define NOISE_FREQ (2.0f*PI/WAVE_FREQ)
-#define NOISE_REPEAT_FACTOR ((float)(1.0f/(16.0f)))
+#define NOISE_REPEAT_FACTOR ((float)(1.0f/(16.0f))) //the foam programs undo this (TexCoord2 * 16) to find the world
static Bool wireframeForDebug = 0;
+//
+// The Water Foam option (WaterFoam): whitecap flecks, a foam band and a soft blend where the
+// water gets shallow, and the sun's shadow on the surface. It is the D3D11 water program under a
+// second name (engineshader.cpp, "water foam"); the D3D9 bytecode is the same, so -d3d9 and the
+// Classic setting, which has no sun's map to take the pixel back to the world through, keep the
+// plain water and its destination alpha feather.
+//
+#define WATER_FOAM_CYCLE 10.0f //swell cycles per unit of m_riverVOrigin: about eight seconds a cycle
+
+static Bool waterFoam(void)
+{
+ return TheGlobalData->m_waterFoam && !TheGlobalData->m_classicGraphics
+ && Direct3D11_Present_Is_Enabled();
+}
+
+// What the foam programs read out of the texture factor: green is the swell's phase, alpha the
+// opacity deep water reaches and red the depth that reaches it over 32. Alpha zero keeps the
+// water's own alpha, which is every water body that is not feathered.
+static UnsignedInt waterFoamFactor(Real riverVOrigin, Real opaqueDepth, Real deepOpacity)
+{
+ const Real phase = fmodf(riverVOrigin * WATER_FOAM_CYCLE, 1.0f);
+ const Int depth = REAL_TO_INT(WWMath::Clamp(opaqueDepth / 32.0f, 0.0f, 1.0f) * 255.0f);
+ const Int opacity = REAL_TO_INT(WWMath::Clamp(deepOpacity, 0.0f, 1.0f) * 255.0f);
+ return ((UnsignedInt)opacity << 24) | ((UnsignedInt)depth << 16) | ((UnsignedInt)REAL_TO_INT(phase * 255.0f) << 8);
+}
+
//
// The river used to get its shroud from a second pass that redrew the whole quad through
// ST_SHROUD_TEXTURE. That pass multiplies the frame buffer by the shroud and knows nothing about
@@ -327,6 +353,10 @@ void WaterRenderObjClass::setupJbaWaterShader(void)
if (m_riverWaterPixelShader){
DX8Wrapper::_Get_D3D_Device()->SetPixelShaderConstantF(0, D3DXVECTOR4(REFLECTION_FACTOR, REFLECTION_FACTOR, REFLECTION_FACTOR, 1.0f), 1);
DX8Wrapper::Set_Pixel_Shader(m_riverWaterPixelShader);
+ if (waterFoam()) {
+ DX8Wrapper::Set_DX8_Render_State(D3DRS_TEXTUREFACTOR, waterFoamFactor(m_riverVOrigin, 0.0f, 0.0f));
+ DX8Wrapper::Set_Pixel_Shader(m_riverWaterFoamPixelShader);
+ }
}
}
@@ -427,6 +457,8 @@ WaterRenderObjClass::WaterRenderObjClass(void)
m_riverWaterPixelShader=0; ///<D3D handle to pixel shader.
m_trapezoidWaterPixelShader=0; ///<D3D handle to pixel shader.
m_reflectionPixelShader=0;
+ m_riverWaterFoamPixelShader=0;
+ m_trapezoidWaterFoamPixelShader=0;
m_waterSparklesTexture=0;
m_riverXOffset=0;
m_riverYOffset=0;
@@ -916,12 +948,20 @@ void WaterRenderObjClass::ReleaseResources(void)
if (m_riverWaterPixelShader)
m_riverWaterPixelShader->Release();
+ if (m_riverWaterFoamPixelShader)
+ m_riverWaterFoamPixelShader->Release();
+
+ if (m_trapezoidWaterFoamPixelShader)
+ m_trapezoidWaterFoamPixelShader->Release();
+
m_dwWavePixelShader=0;
m_dwWaveVertexShader=0;
m_waterPixelShader = 0;
m_trapezoidWaterPixelShader=0;
m_reflectionPixelShader=0;
m_riverWaterPixelShader=0;
+ m_riverWaterFoamPixelShader=0;
+ m_trapezoidWaterFoamPixelShader=0;
}
//-------------------------------------------------------------------------------------------------
@@ -1021,8 +1061,11 @@ void WaterRenderObjClass::ReAcquireResources(void)
hr = D3DXAssembleShader( shader, (UINT)strlen(shader), NULL, NULL, 0, &compiledShader, NULL);
if (hr==0) {
hr = DX8Wrapper::_Get_D3D_Device()->CreatePixelShader((RenderUInt32*)compiledShader->GetBufferPointer(), &m_riverWaterPixelShader);
+ // the same bytecode under a second name, which the D3D11 backend draws with foam (WaterFoam)
+ DX8Wrapper::_Get_D3D_Device()->CreatePixelShader((RenderUInt32*)compiledShader->GetBufferPointer(), &m_riverWaterFoamPixelShader);
compiledShader->Release();
Direct3D11_Register_Engine_Shader(m_riverWaterPixelShader, "river water ps.1.1");
+ Direct3D11_Register_Engine_Shader(m_riverWaterFoamPixelShader, "river water foam ps.1.1");
}
shader =
"ps.1.1\n \
@@ -1051,8 +1094,10 @@ void WaterRenderObjClass::ReAcquireResources(void)
hr = D3DXAssembleShader( shader, (UINT)strlen(shader), NULL, NULL, 0, &compiledShader, NULL);
if (hr==0) {
hr = DX8Wrapper::_Get_D3D_Device()->CreatePixelShader((RenderUInt32*)compiledShader->GetBufferPointer(), &m_trapezoidWaterPixelShader);
+ DX8Wrapper::_Get_D3D_Device()->CreatePixelShader((RenderUInt32*)compiledShader->GetBufferPointer(), &m_trapezoidWaterFoamPixelShader);
compiledShader->Release();
Direct3D11_Register_Engine_Shader(m_trapezoidWaterPixelShader, "trapezoid water ps.1.1");
+ Direct3D11_Register_Engine_Shader(m_trapezoidWaterFoamPixelShader, "trapezoid water foam ps.1.1");
}
shader =
"ps.1.1\n \
@@ -1747,6 +1792,11 @@ void WaterRenderObjClass::Render(RenderInfoClass & rinfo)
return;
}
+ // The foam reads how deep the water is out of the scene's depth, which the ground and every
+ // opaque object have written by now: a copy, taken once here, before the water writes any.
+ if (waterFoam())
+ Direct3D11_Take_Scene_Depth();
+
switch(m_waterType)
{
case WATER_TYPE_0_TRANSLUCENT:
@@ -2574,6 +2624,7 @@ void WaterRenderObjClass::renderWaterMesh(void)
m_shaderClass.Set_Cull_Mode(ShaderClass::CULL_MODE_ENABLE); //water should be visible from both sides
DX8Wrapper::Set_Shader(m_shaderClass);
+ const unsigned oldTextureFactor = DX8Wrapper::Get_DX8_Render_State(D3DRS_TEXTUREFACTOR); //the foam borrows it
#if 1
setupFlatWaterShader();
#else
@@ -2640,6 +2691,8 @@ void WaterRenderObjClass::renderWaterMesh(void)
// DX8Wrapper::Set_DX8_Render_State(D3DRS_FILLMODE,D3DFILL_SOLID);
if (m_trapezoidWaterPixelShader) DX8Wrapper::Set_Pixel_Shader(NULL);
+ if (waterFoam())
+ DX8Wrapper::Set_DX8_Render_State(D3DRS_TEXTUREFACTOR, oldTextureFactor);
m_vertexBufferD3DOffset += mx*my; //advance past vertices already in buffer
@@ -2896,6 +2949,7 @@ void WaterRenderObjClass::drawRiverWater(PolygonTrigger *pTrig)
DX8Wrapper::Set_Vertex_Buffer(vb_access);
DX8Wrapper::Set_Texture(0,m_riverTexture); //set to blue
+ const unsigned oldTextureFactor = DX8Wrapper::Get_DX8_Render_State(D3DRS_TEXTUREFACTOR); //the foam borrows it
setupJbaWaterShader();
//In additive blending we need to use the alpha at the edges of river to darken
@@ -2903,7 +2957,7 @@ void WaterRenderObjClass::drawRiverWater(PolygonTrigger *pTrig)
if (TheWaterTransparency->m_additiveBlend)
DX8Wrapper::Set_DX8_Render_State(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
- if (m_riverWaterPixelShader) DX8Wrapper::Set_Pixel_Shader(m_riverWaterPixelShader);
+ if (m_riverWaterPixelShader) DX8Wrapper::Set_Pixel_Shader(waterFoam() ? m_riverWaterFoamPixelShader : m_riverWaterPixelShader);
RenderUInt32 cull;
DX8Wrapper::_Get_D3D_Device()->GetRenderState(D3DRS_CULLMODE, &cull);
DX8Wrapper::Set_DX8_Render_State(D3DRS_CULLMODE, D3DCULL_NONE);
@@ -2919,6 +2973,8 @@ void WaterRenderObjClass::drawRiverWater(PolygonTrigger *pTrig)
}
if (m_riverWaterPixelShader) DX8Wrapper::Set_Pixel_Shader(NULL);
+ if (waterFoam())
+ DX8Wrapper::Set_DX8_Render_State(D3DRS_TEXTUREFACTOR, oldTextureFactor);
//restore blend mode to what W3D expects.
if (TheWaterTransparency->m_additiveBlend)
@@ -3088,6 +3144,11 @@ void WaterRenderObjClass::setupFlatWaterShader(void)
if (m_trapezoidWaterPixelShader){
DX8Wrapper::_Get_D3D_Device()->SetPixelShaderConstantF(0, D3DXVECTOR4(REFLECTION_FACTOR, REFLECTION_FACTOR, REFLECTION_FACTOR, 1.0f), 1);
DX8Wrapper::Set_Pixel_Shader(m_trapezoidWaterPixelShader);
+ if (waterFoam()) {
+ // unfeathered unless drawTrapezoidWater hands over the depth curve
+ DX8Wrapper::Set_DX8_Render_State(D3DRS_TEXTUREFACTOR, waterFoamFactor(m_riverVOrigin, 0.0f, 0.0f));
+ DX8Wrapper::Set_Pixel_Shader(m_trapezoidWaterFoamPixelShader);
+ }
}
}
@@ -3326,10 +3387,21 @@ void WaterRenderObjClass::drawTrapezoidWater(Vector3 points[4])
DX8Wrapper::Set_Index_Buffer(ib_access,0);
DX8Wrapper::Set_Vertex_Buffer(vb_access);
+ const unsigned oldTextureFactor = DX8Wrapper::Get_DX8_Render_State(D3DRS_TEXTUREFACTOR); //the foam borrows it
setupFlatWaterShader();// lorenzen sez use the alpha shader
//If video card supports it and it's enabled, feather the water edge using destination alpha
- if (DX8Wrapper::getBackBufferFormat() == WW3D_FORMAT_A8R8G8B8 && TheGlobalData->m_showSoftWaterEdge && TheWaterTransparency->m_transparentWaterDepth !=0)
+ if (DX8Wrapper::getBackBufferFormat() == WW3D_FORMAT_A8R8G8B8 && TheGlobalData->m_showSoftWaterEdge && TheWaterTransparency->m_transparentWaterDepth !=0
+ && waterFoam() && !TheWaterTransparency->m_additiveBlend)
+ { // The foam program feathers per pixel instead, by the same curve the shoreline tiles write into
+ // the frame's alpha (BaseHeightMapRenderObjClass::updateShorelineTile): the depth over
+ // TransparentWaterDepth * TransparentWaterMinOpacity, held at TransparentWaterMinOpacity.
+ // The source alpha has to stay the blend factor, or the shallow foam would fade out with it.
+ DX8Wrapper::Set_DX8_Render_State(D3DRS_TEXTUREFACTOR, waterFoamFactor(m_riverVOrigin,
+ TheWaterTransparency->m_transparentWaterDepth * TheWaterTransparency->m_minWaterOpacity,
+ TheWaterTransparency->m_minWaterOpacity));
+ }
+ else if (DX8Wrapper::getBackBufferFormat() == WW3D_FORMAT_A8R8G8B8 && TheGlobalData->m_showSoftWaterEdge && TheWaterTransparency->m_transparentWaterDepth !=0)
{ DX8Wrapper::Set_DX8_Render_State(D3DRS_SRCBLEND, D3DBLEND_DESTALPHA );
if (!TheWaterTransparency->m_additiveBlend)
DX8Wrapper::Set_DX8_Render_State(D3DRS_DESTBLEND, D3DBLEND_INVDESTALPHA );
@@ -3375,6 +3447,8 @@ void WaterRenderObjClass::drawTrapezoidWater(Vector3 points[4])
}
if (m_riverWaterPixelShader) DX8Wrapper::Set_Pixel_Shader(NULL);
+ if (waterFoam())
+ DX8Wrapper::Set_DX8_Render_State(D3DRS_TEXTUREFACTOR, oldTextureFactor);
//Restore alpha blend to default values since we may have changed them to feather edges.
if (!TheWaterTransparency->m_additiveBlend)
{ DX8Wrapper::Set_DX8_Render_State(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
index 94426d697..2fe794e70 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
@@ -381,6 +381,61 @@ Real WorldHeightMap::getBilinearSampleSeismicZVelocity( Int x, Int y)
* Input: DataChunkInput
*
*/
+/* The Warm Light option's sun (MapLight): late afternoon light. A sun higher than PROTO_SUN_SINE (the sine of its
+ height over the horizon, about 26 degrees, where a shadow runs twice as long as its caster is
+ tall) is brought down to it on the same bearing, a straight-down sun takes a bearing of its own,
+ and the sun is brightened by what the flatter angle took off level ground, at most
+ PROTO_SUN_MOST. Then the sun goes gold and the ambient a little toward blue, by how much
+ daylight there is and with the brightness of each kept, so a moonlit map keeps its cast. The
+ sun alone: the two fill lights stay. Client only, the logic never reads these tables. */
+static const Real PROTO_SUN_SINE = 0.44f;
+static const Real PROTO_SUN_MOST = 1.3f;
+
+static void protoTint( RGBColor &c, Real r, Real g, Real b )
+{
+ const Real before = 0.299f * c.red + 0.587f * c.green + 0.114f * c.blue;
+ c.red *= r;
+ c.green *= g;
+ c.blue *= b;
+ const Real after = 0.299f * c.red + 0.587f * c.green + 0.114f * c.blue;
+ if (after > 0.0001f) {
+ c.red *= before / after;
+ c.green *= before / after;
+ c.blue *= before / after;
+ }
+}
+
+static void mapLightSun( GlobalData::TerrainLighting &sun )
+{
+ const Real daylight = (0.299f * sun.diffuse.red + 0.587f * sun.diffuse.green + 0.114f * sun.diffuse.blue - 0.25f) / 0.5f;
+ const Real warmth = (daylight < 0.0f) ? 0.0f : (daylight > 1.0f) ? 1.0f : daylight;
+
+ Coord3D &ray = sun.lightPos;
+ const Real length = (Real)sqrt(ray.x * ray.x + ray.y * ray.y + ray.z * ray.z);
+ const Real sine = -ray.z / length;
+ if (sine > PROTO_SUN_SINE) {
+ Real flat = (Real)sqrt(ray.x * ray.x + ray.y * ray.y);
+ if (flat < 0.0001f) {
+ ray.x = 0.7071f;
+ ray.y = -0.7071f;
+ flat = 1.0f;
+ }
+ const Real cosine = (Real)sqrt(1.0f - PROTO_SUN_SINE * PROTO_SUN_SINE);
+ ray.x = ray.x / flat * cosine * length;
+ ray.y = ray.y / flat * cosine * length;
+ ray.z = -PROTO_SUN_SINE * length;
+ Real gain = sine / PROTO_SUN_SINE;
+ if (gain > PROTO_SUN_MOST)
+ gain = PROTO_SUN_MOST;
+ sun.diffuse.red *= gain;
+ sun.diffuse.green *= gain;
+ sun.diffuse.blue *= gain;
+ }
+
+ protoTint(sun.diffuse, 1.0f + 0.16f * warmth, 1.0f + 0.02f * warmth, 1.0f - 0.26f * warmth);
+ protoTint(sun.ambient, 1.0f - 0.05f * warmth, 1.0f, 1.0f + 0.10f * warmth);
+}
+
Bool WorldHeightMap::ParseLightingDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData)
{
TheWritableGlobalData->m_timeOfDay = (TimeOfDay)file.readInt();
@@ -468,6 +523,13 @@ Bool WorldHeightMap::ParseLightingDataChunk(DataChunkInput &file, DataChunkInfo
before.diffuse.red, before.diffuse.green, before.diffuse.blue,
after.diffuse.red, after.diffuse.green, after.diffuse.blue));
}
+ // a Direct3D 11 look like the haze that goes with it, so -d3d9 keeps the map's own sun
+ if (TheGlobalData->m_mapLight && TheGlobalData->m_direct3D11) {
+ for (i=TIME_OF_DAY_FIRST; i<TIME_OF_DAY_COUNT; i++) {
+ mapLightSun(TheWritableGlobalData->m_terrainLighting[i][0]);
+ mapLightSun(TheWritableGlobalData->m_terrainObjectsLighting[i][0]);
+ }
+ }
DEBUG_ASSERTCRASH(file.atEndOfChunk(), ("Unexpected data left over."));
return true;
}
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
index 8ba375c93..14a928d5b 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
@@ -247,6 +247,7 @@ DX11BackendClass::DX11BackendClass()
, SmokeGlow(false)
, FireLook(false)
, Emissive(false)
+ , TeamGlow(false)
, AdditiveGain(1.0f)
, GlowDraw(false)
, SceneStandIn(NULL)
@@ -299,7 +300,9 @@ DX11BackendClass::DX11BackendClass()
set_identity(View);
set_identity(Projection);
set_identity(SceneView);
+ set_identity(SceneProjection);
SceneViewKnown = false;
+ SceneViewThisFrame = false;
SmokeMapSurface = NULL;
SmokeMapTarget = NULL;
SmokeMapTexture = NULL;
@@ -1027,6 +1030,13 @@ void DX11BackendClass::Set_Scene_View(const float view[16])
SceneViewKnown = true;
ConstantsChanged = true;
}
+ memcpy(SceneProjection, Projection, sizeof(SceneProjection));
+ SceneViewThisFrame = true;
+}
+
+void DX11BackendClass::Open_Frame()
+{
+ SceneViewThisFrame = false;
}
void DX11BackendClass::Set_Smoke_Glow(bool glow)
@@ -1053,6 +1063,28 @@ void DX11BackendClass::Set_Emissive(bool emissive)
}
}
+void DX11BackendClass::Set_Team_Glow(bool glow)
+{
+ if (TeamGlow != glow) {
+ TeamGlow = glow;
+ PipelineChanged = true;
+ }
+}
+
+/** An opaque fixed-function draw into the scene's own target, under no other look: blended, the
+ stripe would add light behind a fading or cloaked body, and a mirror, a portrait or the sun's
+ map has no bloom to feed. Like Additive_Glow it wants the half float scene (a gain off one)
+ and not Classic, whose picture is -d3d9's (SoftParticlesAllowed carries that setting). */
+bool DX11BackendClass::Team_Glow() const
+{
+ return TeamGlow && AdditiveGain != 1.0f && SoftParticlesAllowed
+ && !ShadowMapBound && CurrentTarget == NULL
+ && VertexProgram == ENGINE_SHADER_NONE && PixelProgram == ENGINE_SHADER_NONE
+ && (VertexFormat & D3DFVF_XYZRHW) == 0
+ && RenderStates.Get_Render_State(D3DRS_ALPHABLENDENABLE) == FALSE
+ && Draw_Effect() == DRAW_EFFECT_NONE;
+}
+
/** 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
@@ -1083,6 +1115,9 @@ void DX11BackendClass::Set_Additive_Gain(float gain)
// The factor goes with the blend state when it is bound, so the next draw binds again.
StateObjectsChanged = true;
Bound.Blend = NULL;
+ if (TeamGlow) {
+ PipelineChanged = true; // Team_Glow reads it
+ }
}
}
@@ -1489,6 +1524,22 @@ static bool invert(const float in[16], float out[16])
return true;
}
+bool DX11BackendClass::Scene_World_From_Clip(float world_from_clip[16]) const
+{
+ // The scene camera the shadow pass handed over at the top of the frame, not whatever the last
+ // draw left: a camera space particle run leaves an identity view, the interface an orthographic
+ // projection. Every perspective draw of the scene shares the camera's projection.
+ // Its projection too, not the one the last draw left: the haze goes on after the water and the
+ // translucent meshes, and depth read back through any other projection lands the pixel at
+ // another distance along its own ray.
+ if (!SceneViewThisFrame || SceneProjection[11] == 0.0f) {
+ return false;
+ }
+ float scene_clip[16];
+ multiply(SceneView, SceneProjection, scene_clip);
+ return invert(scene_clip, world_from_clip);
+}
+
/** What is in the map, read back once. A caster pass that drew nothing leaves every texel at the
clear value, which no draw count tells apart from a pass that drew the whole world. */
std::string DX11BackendClass::Shadow_Map_Report()
@@ -1949,6 +2000,12 @@ bool DX11BackendClass::Compile_Program(const std::string & source, const char *
return true;
}
+bool DX11BackendClass::Compile_Pixel_Program(const std::string & source, const char * name,
+ std::vector<unsigned char> & bytecode)
+{
+ return Compile_Program(source, name, PIXEL_PROFILE, bytecode);
+}
+
// The key has characters a file name cannot carry, so it becomes the file's first line and the
// name is a number. Both programs of one pipeline go in one file, in the order they run.
void DX11BackendClass::Dump_Program(const std::string & key, const std::string & vertex_hlsl,
@@ -2186,6 +2243,7 @@ bool DX11BackendClass::Build_Combiner_Description(CombinerDescription & descript
description.SoftParticle = Soft_Particle();
description.DrawEffect = Draw_Effect();
description.FireLook = Fire_Look();
+ description.TeamGlow = Team_Glow();
return description.StageCount > 0;
}
@@ -2656,9 +2714,11 @@ void DX11BackendClass::Upload_Pixel_Constants()
const bool camera_space = Camera_Space_Draw();
const float * const world_to_camera = (camera_space && SceneViewKnown) ? SceneView : View;
- // A look takes its pixel back to the world the same way, with or without a sun's map.
+ // A look takes its pixel back to the world the same way, with or without a sun's map, and so
+ // does a program that reads the scene's depth (the foam water).
const unsigned effect = Draw_Effect();
- if (ShadowReceiving || effect != DRAW_EFFECT_NONE) {
+ const bool reads_depth = EngineShader_Reads_Scene_Depth(PixelProgram);
+ if (ShadowReceiving || effect != DRAW_EFFECT_NONE || reads_depth) {
if (!ShadowFromClipValid
|| memcmp(ShadowFromClipView, world_to_camera, sizeof(View)) != 0
|| memcmp(ShadowFromClipProjection, Projection, sizeof(Projection)) != 0) {
@@ -2674,7 +2734,7 @@ void DX11BackendClass::Upload_Pixel_Constants()
}
}
}
- if (effect != DRAW_EFFECT_NONE) {
+ if (effect != DRAW_EFFECT_NONE || reads_depth) {
pixel_block.ShadowViewport[0] = (ViewportWidth > 0)
? 1.0f / static_cast<float>(ViewportWidth) : 0.0f;
pixel_block.ShadowViewport[1] = (ViewportHeight > 0)
@@ -3008,6 +3068,17 @@ void DX11BackendClass::Bind_State_Objects()
Bound.SceneDepth = depth;
}
}
+ // The foam water reads the same copy, which W3DWater takes before it draws. Into another
+ // target's depth it reads none, and a null view reads zero, which the program takes as deep.
+ if (EngineShader_Reads_Scene_Depth(PixelProgram)) {
+ ID3D11ShaderResourceView * const depth =
+ (CurrentTarget == NULL || CurrentDepth == Device->Get_Depth_Stencil_View())
+ ? SceneDepthCopyView : NULL;
+ if (!known || depth != Bound.SceneDepth) {
+ context->PSSetShaderResources(DX11_BACKEND_TEXTURE_STAGES + 3, 1, &depth);
+ Bound.SceneDepth = depth;
+ }
+ }
// The scene's colour at t8 for the cloak, read with Load. Set_Draw_Effect took the copy.
if (Draw_Effect() == DRAW_EFFECT_CLOAK) {
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h
index 82003ef3b..195b525ad 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h
@@ -178,6 +178,10 @@ public:
// is killed, keeps what it compiled.
void Save_Shader_Cache_If_Due();
unsigned Compiled_Program_Count() const { return static_cast<unsigned>(CompiledPrograms.size()); }
+ // A pixel program from outside the backend (the post chain's haze) through the same cache, so
+ // only the first run that meets it compiles it. False when the compiler refused it.
+ bool Compile_Pixel_Program(const std::string & source, const char * name,
+ std::vector<unsigned char> & bytecode);
// Binds the swap chain's back buffer and depth buffer and sets the viewport over the whole of
// it. D3D11 keeps no default target: without this every draw is complete, legal, and lands
@@ -244,6 +248,11 @@ public:
// sorting pool sets it, around those systems' runs.
void Set_Emissive(bool emissive);
+ // The draws that follow are a house colour mesh under the Team Glow option: its hue is added again
+ // after the shade, past white, for the bloom (ffshader.h, TeamGlow). The mesh renderer sets it
+ // around such a mesh's draws. A draw it does not suit takes none (Team_Glow).
+ void Set_Team_Glow(bool glow);
+
// 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.
@@ -267,6 +276,14 @@ public:
// its own on the context mid-scene (the post chain's occlusion).
void Resume_Scene();
+ // The scene camera's clip space back into the world, out of Set_Scene_View's view and the
+ // projection held with it, for a pass over the world that reads its depth (the prototype map
+ // haze). False when Set_Scene_View has not run since Open_Frame, when that projection is not a
+ // perspective one or the matrix has no inverse.
+ bool Scene_World_From_Clip(float world_from_clip[16]) const;
+ // The top of a frame, before any scene of it: Scene_World_From_Clip waits for this frame's view.
+ void Open_Frame();
+
// What an additive draw (ONE, ONE) into the scene is worth, for the Glow option: the blend
// takes the draw's colour times this through the blend factor, so fire, muzzle flashes and
// laser cores pass white in the half float scene and the bloom's bright pass finds them, where
@@ -553,9 +570,14 @@ private:
float ShadowFromClipProjection[16];
bool ShadowFromClipValid;
- // Set_Scene_View's matrix, and whether it has been set.
+ // Set_Scene_View's matrix, and whether it has been set; and the projection held when it was,
+ // which is the scene camera's own (Set_Scene_View follows the camera's Apply).
float SceneView[16];
+ float SceneProjection[16];
bool SceneViewKnown;
+ // Set_Scene_View ran since the last Open_Frame: the haze reprojects with this frame's camera or
+ // not at all (the shadow pass returns before handing the view over on a frame it skips).
+ bool SceneViewThisFrame;
bool Camera_Space_Draw() const;
bool SmokeGlow;
bool Smoke_Glow() const;
@@ -564,6 +586,9 @@ private:
unsigned Fire_Look() const;
// Set_Emissive: the current draws take no shadow and no smoke shade (Shadow_Receiving).
bool Emissive;
+ // Set_Team_Glow, and whether the current draw takes it.
+ bool TeamGlow;
+ bool Team_Glow() 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/dx11post.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.cpp
index 2437d4762..4e117c045 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.cpp
@@ -120,6 +120,107 @@ void DX11Post_Set_Grade(float amount)
GradeAmount = (amount < 0.0f) ? 0.0f : (amount > 1.0f) ? 1.0f : amount;
}
+static float HazeColour[3] = { 0.0f, 0.0f, 0.0f };
+static float HazeTop = 0.0f;
+static float HazeThickness = 1.0f;
+static float HazeStrength = 0.0f;
+static float HazeReach = 1.0f;
+static float HazeWater = -1.0e6f;
+
+void DX11Post_Set_Haze(const float colour[3], float top, float thickness, float strength, float reach,
+ float water)
+{
+ HazeWater = water;
+ HazeColour[0] = colour[0];
+ HazeColour[1] = colour[1];
+ HazeColour[2] = colour[2];
+ HazeTop = top;
+ HazeThickness = thickness;
+ HazeStrength = strength;
+ HazeReach = reach;
+}
+
+static float HazeFieldRect[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
+static float HazeMotion[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
+static float HazeSun[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
+static unsigned char HazeFieldTexels[DX11_POST_HAZE_FIELD_SIZE * DX11_POST_HAZE_FIELD_SIZE];
+static bool HazeFieldDirty = false;
+
+void DX11Post_Set_Haze_Motion(const float field_rect[4], float drift_x, float drift_y,
+ float noise_scale, float stir, const float toward_sun[3], float warmth)
+{
+ memcpy(HazeFieldRect, field_rect, sizeof(HazeFieldRect));
+ HazeMotion[0] = drift_x;
+ HazeMotion[1] = drift_y;
+ HazeMotion[2] = noise_scale;
+ HazeMotion[3] = stir;
+ HazeSun[0] = toward_sun[0];
+ HazeSun[1] = toward_sun[1];
+ HazeSun[2] = toward_sun[2];
+ HazeSun[3] = warmth;
+}
+
+void DX11Post_Set_Haze_Field(const unsigned char * texels)
+{
+ memcpy(HazeFieldTexels, texels, sizeof(HazeFieldTexels));
+ HazeFieldDirty = true;
+}
+
+static float HazeWakeInfo[4] = { 0.0f, 1.0f, 1.0f, 0.0f };
+static float HazeWakeEnds[DX11_POST_HAZE_WAKE_LIMIT][4];
+static float HazeWakeShape[DX11_POST_HAZE_WAKE_LIMIT][4];
+static float HazeClock[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
+
+void DX11Post_Set_Haze_Wakes(const float (*segments)[8], unsigned count, float arm_width, float open_soft,
+ float seconds)
+{
+ HazeClock[0] = seconds;
+ if (count > DX11_POST_HAZE_WAKE_LIMIT) {
+ count = DX11_POST_HAZE_WAKE_LIMIT;
+ }
+ for (unsigned index = 0; index < count; ++index) {
+ memcpy(HazeWakeEnds[index], &segments[index][0], sizeof(HazeWakeEnds[0]));
+ memcpy(HazeWakeShape[index], &segments[index][4], sizeof(HazeWakeShape[0]));
+ }
+ HazeWakeInfo[0] = static_cast<float>(count);
+ HazeWakeInfo[1] = arm_width;
+ HazeWakeInfo[2] = open_soft;
+}
+
+static ID3D11ShaderResourceView * HazeShroudSource = NULL;
+static float HazeShroudRect[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
+
+void DX11Post_Set_Haze_Shroud(ID3D11ShaderResourceView * view, const float rect[4])
+{
+ HazeShroudSource = view;
+ memcpy(HazeShroudRect, rect, sizeof(HazeShroudRect));
+}
+
+/** A single channel eight bit texture of size by size for the haze, made on first use; false
+ when the device refused it. */
+static bool make_haze_texture(ID3D11Device * device, unsigned size, ID3D11Texture2D ** texture,
+ ID3D11ShaderResourceView ** view)
+{
+ if (*texture != NULL) {
+ return true;
+ }
+ D3D11_TEXTURE2D_DESC description;
+ ZeroMemory(&description, sizeof(description));
+ description.Width = size;
+ description.Height = size;
+ description.MipLevels = 1;
+ description.ArraySize = 1;
+ description.Format = DXGI_FORMAT_R8_UNORM;
+ description.SampleDesc.Count = 1;
+ description.Usage = D3D11_USAGE_DEFAULT;
+ description.BindFlags = D3D11_BIND_SHADER_RESOURCE;
+ if (FAILED(device->CreateTexture2D(&description, NULL, texture))) {
+ return false;
+ }
+ device->CreateShaderResourceView(*texture, NULL, view);
+ return true;
+}
+
static DX11PostWarp Warps[DX11_POST_WARP_LIMIT];
static unsigned WarpCount = 0;
@@ -158,6 +259,28 @@ struct PostConstantBlock
// The grade's amount, contrast, saturation and warm/cool split.
float Grade[4];
+
+ // The ground haze: its top, thickness, strength and reach, its colour, and the matrix taking
+ // the frame's clip space back to the world. Only the haze program declares them (at c13, in a
+ // cbuffer of its own over the same buffer), so every other pass compiles from the text it
+ // always did.
+ float Haze[4];
+ float HazeColour[4];
+ float WorldFromClip[16];
+ // Then the disturbance field's world rectangle (origin, one over size), the wind's drift so far,
+ // the noise scale and the field's strength, and the way toward the sun with its warmth.
+ float HazeField[4];
+ float HazeMotion[4];
+ float HazeSun[4];
+ // The shroud light's world rectangle (origin, one over size).
+ float HazeShroudRect[4];
+ // The aircraft wakes: their count, arm width and opening ease, then each segment's ends and
+ // its shape.
+ float HazeWakeInfo[4];
+ float HazeWakeEnds[DX11_POST_HAZE_WAKE_LIMIT][4];
+ float HazeWakeShape[DX11_POST_HAZE_WAKE_LIMIT][4];
+ // The picture's clock in seconds, in x.
+ float HazeClock[4];
};
// A triangle big enough to cover the screen, made out of nothing. No vertex buffer and no input
@@ -413,6 +536,257 @@ static const char * const AO_SCENE_SHADER_BODY =
" return float4((1.0 - occlusion * AO_STRENGTH).xxx, 1.0);\n"
"}\n";
+// The prototype ground haze, blended over the scene target by its alpha mid-scene, at the moment
+// the occlusion goes on. The pixel's depth goes back to the world the way the headlights take it
+// (HEADLIGHT_SAMPLING in ffshader.h); how far it lies below the haze's top decides how much of the
+// haze it takes, eased in so the layer has no edge, and a pixel further from the eye takes up to
+// half again more, which is what keeps the near hill sides clear of a flat wash. Nothing drawn
+// (depth still at the clear) takes none, and neither does anything under the water's surface
+// (HazeColour.w): water writes no depth, so what the pass sees there is the bed, and hazed by its
+// depth the water went flat grey. The haze eases out smoothly from three units above the water to
+// two below it. Cut off within two units above, the pale hazed sand met the dark water as a hard
+// line; ending eight units above, the maps' dark wet sand feather just over the water stayed
+// clear and stood out as a band against the hazed sand. So it reaches onto the wet strip and the
+// shallowest bed, and the bed under any real depth of water stays clear.
+//
+// The layer is never thicker than HAZE_LOW_CAP of the full amount, a little under what Golden
+// Oasis's low plateau takes: the bank under it went milky at the full amount, and still a little
+// at 0.62.
+//
+// The layer is not even. Four points along the last stretch of the eye's ray inside the layer
+// read two octaves of value noise drifting with the wind, each at its own height so the patches
+// part with parallax as the camera moves. Their mean, eased so the patches have soft edges and
+// clear gaps, scales the amount between 0.65 and 1.35 of the even layer (one on average, so a
+// map's average haze is what it was; 0.3 to 1.7 went to a flat milky plate on the low bank), and
+// the dense patches come out a touch paler, which keeps them apart from the map's darker cloud
+// shadows. The disturbance field (t2, DX11Post_Set_Haze_Field) clears the haze where something
+// went through, read at the same four points along the ray: looking down that is the ground under
+// the pixel, and across a far bank the ray passes through the lane only partly, so a lane there
+// thins instead of standing up as a wall with a doorway in it. The clearing eases in over a wide
+// band and takes less with distance; its slope pushes the noise outward by up to HAZE_SWIRL world
+// units and piles a faint extra on the rim (a bright rim read as a crater's edge).
+//
+// Aircraft disturb the haze in a wedge, the Mach cone or a boat's wake seen from above: its point
+// at the aircraft, two arms spreading back along its recent path (DX11Post_Set_Haze_Wakes, a few
+// segments, so a turn bends the wedge). Nothing is drawn on top: the wedge is a mask that moves
+// the haze already there. A pixel's distance behind the aircraft along the path and its distance
+// off the path decide it. Along each arm, where the second is the first times the half-angle's
+// tangent plus a drift outward with age (HAZE_WAKE_DRIFT), sits a wingtip vortex: it pushes the
+// haze outward (HAZE_WAKE_PUSH world units) and rolls it along the arm, the two sides turning
+// opposite ways on the picture's clock (HAZE_WAKE_ROLL, HAZE_WAKE_SPIN), smearing wider as it ages
+// (HAZE_WAKE_SMEAR). Curl noise breaks the push up (HAZE_WAKE_TURB), and inside the wake a finer
+// grain of haze rides the same displacement (HAZE_WAKE_GRAIN), so what shows is haze texture
+// bending and parting. Inside the arms the lane tears open (HAZE_WAKE_TATTER_SCALE noise, eased
+// so the torn holes clear right down to the ground and the rest keeps HAZE_WAKE_TATTER_KEEP of the
+// clearing) and fills back in from the sides after HAZE_WAKE_FILL_FROM of the wake's life. The
+// haze the vortices push out piles on them (HAZE_WAKE_PILE, up to twice the haze there), and they
+// lift a little more out of the layer below (HAZE_WAKE_LIFT of the full layer, in clumps of the
+// fine grain), which is what still shows over a bank where the haze is too thin for a clearing in
+// it to read. A pixel whose foot on a segment falls past either end belongs to the next segment
+// and is skipped. A hovering helicopter's segments are rings instead: the same vortex pushed radially outward and
+// rolling round the ring, the disc inside cleared, travelling out as the ring ages. A weaker
+// segment (an aircraft higher over the haze) spreads its vortices wider, up to HAZE_WAKE_HIGH_SOFT
+// more at nothing, so a high pass reads soft and a low one sharp.
+//
+// The shroud has already darkened the ground under the haze by its light (t3, the very texture the
+// terrain multiplies by, through the terrain's own mapping, so the two cannot disagree; a copy read
+// through W3DShroud::getShroudLevel did, by cells and by a stair-step edge), so the haze takes
+// that light too, its colour once and its amount three times over: in the fog
+// (about half light) the haze keeps an eighth of itself at half its brightness, so it can never
+// come out paler than the fogged ground it lies on, shrouded ground stays black, and water and its
+// bank in the fog match. Only the colour taking it, the haze's own paleness still lifted the
+// fogged ground the way it lifts ground in sight, and the fog read as bright patches.
+// Looking toward the sun the colour goes a little warmer, away from it a little cooler.
+static const char * const HAZE_SHADER_BODY =
+ "cbuffer HazeConstants : register(b1)\n"
+ "{\n"
+ " float4 Haze : packoffset(c13);\n"
+ " float4 HazeColour : packoffset(c14);\n"
+ " row_major float4x4 WorldFromClip : packoffset(c15);\n"
+ " float4 HazeField : packoffset(c19);\n"
+ " float4 HazeMotion : packoffset(c20);\n"
+ " float4 HazeSun : packoffset(c21);\n"
+ " float4 HazeShroudRect : packoffset(c22);\n"
+ " float4 HazeWakeInfo : packoffset(c23);\n"
+ " float4 HazeWakeEnds[" DX11_POST_HAZE_WAKE_LIMIT_TEXT "] : packoffset(c24);\n"
+ " float4 HazeWakeShape[" DX11_POST_HAZE_WAKE_LIMIT_TEXT "] : packoffset(" DX11_POST_HAZE_WAKE_SHAPE_REGISTER_TEXT ");\n"
+ " float4 HazeClock : packoffset(" DX11_POST_HAZE_CLOCK_REGISTER_TEXT ");\n"
+ "};\n"
+ "Texture2D HazeStir : register(t2);\n"
+ "Texture2D HazeShroud : register(t3);\n"
+ "static const float HAZE_FIELD_TEXEL = 1.0 / " DX11_POST_HAZE_FIELD_SIZE_TEXT ".0;\n"
+ "static const float HAZE_SWIRL = 140.0;\n"
+ "static const float HAZE_RIM_GAIN = 1.5;\n"
+ "static const float HAZE_LOW_CAP = 0.5;\n"
+ "static const float HAZE_WAKE_PILE = 1.0;\n"
+ "static const float HAZE_WAKE_LIFT = 0.8;\n"
+ "static const float HAZE_WAKE_TATTER_KEEP = 0.45;\n"
+ "static const float HAZE_WAKE_HOLD = 0.55;\n"
+ "static const float HAZE_WAKE_GONE = 0.85;\n"
+ "static const float HAZE_WAKE_END_SCALE = 1.0 / 20.0;\n"
+ "static const float HAZE_WAKE_END_BREAK = 0.3;\n"
+ "static const float HAZE_WAKE_SIDE_SOFT = 0.6;\n"
+ "static const float HAZE_WAKE_HIGH_SOFT = 1.5;\n"
+ "static const float HAZE_WAKE_DRIFT = 16.0;\n"
+ "static const float HAZE_WAKE_SMEAR = 2.5;\n"
+ "static const float HAZE_WAKE_PUSH = 24.0;\n"
+ "static const float HAZE_WAKE_ROLL = 14.0;\n"
+ "static const float HAZE_WAKE_SPIN = 5.0;\n"
+ "static const float HAZE_WAKE_FILL_FROM = 0.25;\n"
+ "static const float HAZE_WAKE_TURB_SCALE = 1.0 / 18.0;\n"
+ "static const float HAZE_WAKE_TURB = 18.0;\n"
+ "static const float HAZE_WAKE_TATTER_SCALE = 1.0 / 14.0;\n"
+ "static const float HAZE_WAKE_GRAIN = 1.0 / 22.0;\n"
+ "static const float HAZE_WAKE_GRAIN_SHOW = 0.8;\n"
+ "\n"
+ "float haze_hash(float2 p)\n"
+ "{\n"
+ " return frac(sin(dot(p, float2(127.1, 311.7))) * 43758.5453);\n"
+ "}\n"
+ "\n"
+ "float haze_noise(float2 p)\n"
+ "{\n"
+ " float2 cell = floor(p);\n"
+ " float2 f = frac(p);\n"
+ " f = f * f * (3.0 - 2.0 * f);\n"
+ " float a = haze_hash(cell);\n"
+ " float b = haze_hash(cell + float2(1.0, 0.0));\n"
+ " float c = haze_hash(cell + float2(0.0, 1.0));\n"
+ " float d = haze_hash(cell + float2(1.0, 1.0));\n"
+ " return lerp(lerp(a, b, f.x), lerp(c, d, f.x), f.y);\n"
+ "}\n"
+ "\n"
+ "float haze_stir(float2 at)\n"
+ "{\n"
+ " return HazeStir.SampleLevel(Sampler, at, 0.0).r;\n"
+ "}\n"
+ "\n"
+ "float4 main(VertexOutput input) : SV_TARGET\n"
+ "{\n"
+ " float raw = Extra.Sample(Sampler, input.Texture).r;\n"
+ " if (raw >= 0.99999) return float4(0.0, 0.0, 0.0, 0.0);\n"
+ " float2 ndc = float2(input.Texture.x * 2.0 - 1.0, 1.0 - input.Texture.y * 2.0);\n"
+ " float4 world = mul(float4(ndc, raw, 1.0), WorldFromClip);\n"
+ " world.xyz /= world.w;\n"
+ " float4 eye = mul(float4(ndc, 0.0, 1.0), WorldFromClip);\n"
+ " eye.xyz /= eye.w;\n"
+ " float below = saturate((Haze.x - world.z) / max(Haze.y, 0.0001));\n"
+ " if (below <= 0.0) return float4(0.0, 0.0, 0.0, 0.0);\n"
+ " float shroudLight = HazeShroud.SampleLevel(Sampler, (world.xy - HazeShroudRect.xy) * HazeShroudRect.zw, 0.0).g;\n"
+ " float reach = saturate(distance(world.xyz, eye.xyz) / max(Haze.w, 0.0001));\n"
+ " float layer = min(below * below * (3.0 - 2.0 * below), HAZE_LOW_CAP);\n"
+ " float amount = Haze.z * layer * (0.65 + 0.35 * reach);\n"
+ " float bank = saturate((world.z - HazeColour.w + 2.0) / 5.0);\n"
+ " bank = bank * bank * (3.0 - 2.0 * bank);\n"
+ " amount *= bank;\n"
+ "\n"
+ " float2 field = (world.xy - HazeField.xy) * HazeField.zw;\n"
+ " float2 slope = float2(haze_stir(field + float2(HAZE_FIELD_TEXEL, 0.0)) - haze_stir(field - float2(HAZE_FIELD_TEXEL, 0.0)),\n"
+ " haze_stir(field + float2(0.0, HAZE_FIELD_TEXEL)) - haze_stir(field - float2(0.0, HAZE_FIELD_TEXEL)));\n"
+ "\n"
+ " float2 warp = float2(0.0, 0.0);\n"
+ " float wakeClear = 0.0;\n"
+ " float wakeStir = 0.0;\n"
+ " float endBreak = (haze_noise(world.xy * HAZE_WAKE_END_SCALE + 11.0) - 0.5) * HAZE_WAKE_END_BREAK;\n"
+ " for (int wake = 0; wake < " DX11_POST_HAZE_WAKE_LIMIT_TEXT "; ++wake)\n"
+ " {\n"
+ " if (wake >= (int)HazeWakeInfo.x) break;\n"
+ " float4 ends = HazeWakeEnds[wake];\n"
+ " float4 shape = HazeWakeShape[wake];\n"
+ " float2 outward;\n"
+ " float2 across;\n"
+ " float off;\n"
+ " float edge;\n"
+ " float age;\n"
+ " float hand;\n"
+ " if (shape.y < 0.0)\n"
+ " {\n"
+ " float2 fromCentre = world.xy - ends.zw;\n"
+ " off = length(fromCentre);\n"
+ " outward = fromCentre / max(off, 0.001);\n"
+ " across = float2(-outward.y, outward.x);\n"
+ " edge = shape.x;\n"
+ " age = shape.w;\n"
+ " hand = 1.0;\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " float2 back = ends.xy - ends.zw;\n"
+ " float2 fromNear = world.xy - ends.zw;\n"
+ " float span2 = max(dot(back, back), 0.0001);\n"
+ " float along = dot(fromNear, back) / span2;\n"
+ " if (along < 0.0 || along > 1.0) continue;\n"
+ " float behind = shape.x + along * sqrt(span2);\n"
+ " float2 sideways = fromNear - back * along;\n"
+ " off = length(sideways);\n"
+ " outward = sideways / max(off, 0.001);\n"
+ " across = back * rsqrt(span2);\n"
+ " hand = (back.x * fromNear.y - back.y * fromNear.x) >= 0.0 ? 1.0 : -1.0;\n"
+ " age = behind * shape.w;\n"
+ " edge = behind * shape.y + age * HAZE_WAKE_DRIFT;\n"
+ " }\n"
+ " float fade = (1.0 - smoothstep(HAZE_WAKE_HOLD, HAZE_WAKE_GONE, age + endBreak)) * shape.z;\n"
+ " if (fade <= 0.0) continue;\n"
+ " float spread = HazeWakeInfo.y * (1.0 + age * HAZE_WAKE_SMEAR) * (1.0 + HAZE_WAKE_HIGH_SOFT * (1.0 - shape.z));\n"
+ " float arm = (off - edge) / spread;\n"
+ " float vortex = exp(-arm * arm) * fade;\n"
+ " float roll = sin(arm * 2.2 - HazeClock.x * HAZE_WAKE_SPIN * hand);\n"
+ " warp += outward * vortex * HAZE_WAKE_PUSH * (1.0 - 0.5 * age) + across * vortex * roll * HAZE_WAKE_ROLL * hand;\n"
+ " float lane = saturate((edge * (1.0 - smoothstep(HAZE_WAKE_FILL_FROM, 1.0, age)) - off + endBreak * spread)\n"
+ " / max(HazeWakeInfo.z, spread * HAZE_WAKE_SIDE_SOFT));\n"
+ " wakeClear = max(wakeClear, lane * fade);\n"
+ " wakeStir = max(wakeStir, vortex);\n"
+ " }\n"
+ " float wakeTouch = saturate(wakeStir + wakeClear);\n"
+ " if (wakeTouch > 0.001)\n"
+ " {\n"
+ " float2 t = world.xy * HAZE_WAKE_TURB_SCALE + HazeClock.x * 0.7;\n"
+ " float2 curl = float2(haze_noise(t + float2(0.0, 0.5)) - haze_noise(t - float2(0.0, 0.5)),\n"
+ " haze_noise(t - float2(0.5, 0.0)) - haze_noise(t + float2(0.5, 0.0)));\n"
+ " warp += curl * HAZE_WAKE_TURB * wakeTouch;\n"
+ " float tatter = haze_noise((world.xy - warp) * HAZE_WAKE_TATTER_SCALE + HazeClock.x * 0.3);\n"
+ " wakeClear *= lerp(HAZE_WAKE_TATTER_KEEP, 1.0, smoothstep(0.3, 0.7, tatter));\n"
+ " }\n"
+ "\n"
+ " float3 ray = world.xyz - eye.xyz;\n"
+ " float entry = (eye.z > Haze.x && abs(ray.z) > 0.0001) ? saturate((Haze.x - eye.z) / ray.z) : 0.0;\n"
+ " float2 shove = slope * HAZE_SWIRL * HazeMotion.z;\n"
+ " float patches = 0.0;\n"
+ " float stir = 0.0;\n"
+ " for (int tap = 0; tap < 4; ++tap)\n"
+ " {\n"
+ " float3 at = eye.xyz + ray * lerp(entry, 1.0, ((float)tap + 0.5) * 0.25);\n"
+ " float2 q = (at.xy - warp - HazeMotion.xy) * HazeMotion.z - shove + at.z * 0.011;\n"
+ " patches += haze_noise(q) * 0.7 + haze_noise(q * 2.7 + 17.0) * 0.3;\n"
+ " stir += haze_stir((at.xy - HazeField.xy) * HazeField.zw);\n"
+ " }\n"
+ " float dense = smoothstep(0.28, 0.72, patches * 0.25);\n"
+ " amount *= lerp(0.65, 1.35, dense);\n"
+ " float fine = 0.0;\n"
+ " if (wakeTouch > 0.001)\n"
+ " {\n"
+ " float2 grain = (world.xy - warp - HazeMotion.xy * 0.5) * HAZE_WAKE_GRAIN;\n"
+ " fine = haze_noise(grain) * 0.6 + haze_noise(grain * 2.3 + 31.0) * 0.4;\n"
+ " amount *= lerp(1.0, 0.4 + 1.2 * fine, wakeTouch * HAZE_WAKE_GRAIN_SHOW);\n"
+ " }\n"
+ "\n"
+ " float clear = max(HazeMotion.w * smoothstep(0.05, 0.6, stir * 0.25), wakeClear) * lerp(1.0, 0.6, reach);\n"
+ " float rim = saturate(length(slope) * HAZE_RIM_GAIN) * (1.0 - clear);\n"
+ " float pushed = wakeStir * (1.0 - clear);\n"
+ " amount *= (1.0 - clear) * (1.0 + 0.12 * rim + HAZE_WAKE_PILE * pushed);\n"
+ " amount += HAZE_WAKE_LIFT * Haze.z * HAZE_LOW_CAP * saturate(below * 4.0) * bank * pushed * smoothstep(0.3, 0.8, fine);\n"
+ "\n"
+ " float2 look = ray.xy * rsqrt(max(dot(ray.xy, ray.xy), 0.0001));\n"
+ " float2 sun = HazeSun.xy * rsqrt(max(dot(HazeSun.xy, HazeSun.xy), 0.0001));\n"
+ " float toward = dot(look, sun);\n"
+ " float3 colour = HazeColour.rgb * (1.0 + HazeSun.w * toward * float3(0.08, 0.02, -0.07));\n"
+ " colour *= 1.0 + 0.06 * (dense - 0.5);\n"
+ " float lit = lerp(1.0, shroudLight, HazeSun.z);\n"
+ " colour *= lit;\n"
+ " amount *= lit * lit * lit;\n"
+ " return float4(colour, saturate(amount));\n"
+ "}\n";
+
// The bright pass, downsampling as it goes: four taps of the full size frame averaged into one
// quarter size texel, then the threshold taken off its brightest channel. What survives is the
// amount by which something was brighter than white, which is a quantity an eight bit scene target
@@ -635,9 +1009,11 @@ DX11PostProcessClass::DX11PostProcessClass()
, BloomCompositeShader(NULL)
, WarpShader(NULL)
, SceneOcclusionShader(NULL)
+ , HazeShader(NULL)
, Sampler(NULL)
, BlendState(NULL)
, MultiplyBlendState(NULL)
+ , AlphaBlendState(NULL)
, DepthState(NULL)
, RasterizerState(NULL)
, ConstantBuffer(NULL)
@@ -650,7 +1026,13 @@ DX11PostProcessClass::DX11PostProcessClass()
, ShadersReady(false)
, Resolved(false)
, Occluded(false)
+ , Hazed(false)
+ , HazeRefused(false)
+ , HazeFieldTexture(NULL)
+ , HazeFieldView(NULL)
+ , HazeShroudView(NULL)
{
+ memset(HazeWorldFromClip, 0, sizeof(HazeWorldFromClip));
memset(PixelShaders, 0, sizeof(PixelShaders));
memset(&SceneTarget, 0, sizeof(SceneTarget));
memset(&SceneCopy, 0, sizeof(SceneCopy));
@@ -688,12 +1070,20 @@ bool DX11PostProcessClass::Initialise(DX11DeviceClass * device)
void DX11PostProcessClass::Shutdown()
{
Release_Targets();
+ release_interface(reinterpret_cast<IUnknown **>(&HazeFieldView));
+ release_interface(reinterpret_cast<IUnknown **>(&HazeFieldTexture));
+ HazeShroudView = NULL;
+ HazeShroudSource = NULL;
+ // A new device starts without it, so the next upload has to make it.
+ HazeFieldDirty = true;
release_interface(reinterpret_cast<IUnknown **>(&ConstantBuffer));
release_interface(reinterpret_cast<IUnknown **>(&RasterizerState));
release_interface(reinterpret_cast<IUnknown **>(&DepthState));
+ release_interface(reinterpret_cast<IUnknown **>(&AlphaBlendState));
release_interface(reinterpret_cast<IUnknown **>(&MultiplyBlendState));
release_interface(reinterpret_cast<IUnknown **>(&BlendState));
release_interface(reinterpret_cast<IUnknown **>(&Sampler));
+ release_interface(reinterpret_cast<IUnknown **>(&HazeShader));
release_interface(reinterpret_cast<IUnknown **>(&SceneOcclusionShader));
release_interface(reinterpret_cast<IUnknown **>(&WarpShader));
release_interface(reinterpret_cast<IUnknown **>(&BloomCompositeShader));
@@ -707,6 +1097,7 @@ void DX11PostProcessClass::Shutdown()
Device = NULL;
ShadersReady = false;
Resolved = false;
+ HazeRefused = false;
}
void DX11PostProcessClass::Set_Chain(const DX11PostEffect effects[DX11_POST_CHAIN_LIMIT],
@@ -820,6 +1211,13 @@ bool DX11PostProcessClass::Create_States()
return false;
}
+ // The pass's colour over the scene's by the pass's alpha, the scene's alpha kept.
+ blend.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
+ blend.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
+ if (FAILED(device->CreateBlendState(&blend, &AlphaBlendState))) {
+ return false;
+ }
+
D3D11_DEPTH_STENCIL_DESC depth;
ZeroMemory(&depth, sizeof(depth));
if (FAILED(device->CreateDepthStencilState(&depth, &DepthState))) {
@@ -975,6 +1373,76 @@ void DX11PostProcessClass::Begin_Frame()
void DX11PostProcessClass::Open_Frame()
{
Occluded = false;
+ Hazed = false;
+}
+
+bool DX11PostProcessClass::Wants_Haze_Program() const
+{
+ return HazeStrength > 0.0f && HazeShader == NULL && !HazeRefused && ShadersReady;
+}
+
+const char * DX11PostProcessClass::Haze_Program_Source() const
+{
+ static const std::string source = std::string(PIXEL_SHADER_PROLOGUE) + HAZE_SHADER_BODY;
+ return source.c_str();
+}
+
+void DX11PostProcessClass::Load_Haze_Program(const void * bytecode, SIZE_T size)
+{
+ if (bytecode == NULL || FAILED(Device->Get_Device()->CreatePixelShader(bytecode, size, NULL, &HazeShader))) {
+ HazeShader = NULL;
+ HazeRefused = true;
+ }
+}
+
+void DX11PostProcessClass::Compile_Haze_Program()
+{
+ if (HazeShader == NULL && !compile_pixel_shader(compiler_function(), Device->Get_Device(),
+ HAZE_SHADER_BODY, &HazeShader)) {
+ HazeShader = NULL;
+ HazeRefused = true;
+ }
+}
+
+bool DX11PostProcessClass::Haze_Scene(ID3D11ShaderResourceView * depth,
+ const float world_from_clip[16])
+{
+ if (HazeStrength <= 0.0f || Hazed || Resolved || !ShadersReady || SceneTarget.View == NULL
+ || Device->Get_Scene_View() != SceneTarget.View) {
+ return false;
+ }
+ // Loaded the first time the prototype asks for it (Load_Haze_Program), so a refusal costs the
+ // haze alone and a launch without the switch loads nothing more.
+ if (HazeShader == NULL) {
+ return false;
+ }
+ memcpy(HazeWorldFromClip, world_from_clip, sizeof(HazeWorldFromClip));
+
+ if (HazeFieldDirty) {
+ if (make_haze_texture(Device->Get_Device(), DX11_POST_HAZE_FIELD_SIZE, &HazeFieldTexture, &HazeFieldView)) {
+ Device->Get_Context()->UpdateSubresource(HazeFieldTexture, 0, NULL, HazeFieldTexels,
+ DX11_POST_HAZE_FIELD_SIZE, 0);
+ }
+ HazeFieldDirty = false;
+ }
+ // Borrowed for this frame only: the shroud's texture (and so its mirror) can be freed by the
+ // next map or a shroud reset, and a frame that set none draws with none.
+ HazeShroudView = HazeShroudSource;
+ HazeShroudSource = NULL;
+
+ PassSetup pass;
+ memset(&pass, 0, sizeof(pass));
+ pass.Shader = HazeShader;
+ pass.Extra = depth;
+ pass.Blend = true;
+ pass.Destination = SceneTarget.View;
+ pass.DestinationWidth = Width;
+ pass.DestinationHeight = Height;
+ pass.SourceWidth = Width;
+ pass.SourceHeight = Height;
+ Draw_Pass(pass);
+ Hazed = true;
+ return true;
}
bool DX11PostProcessClass::Occlude_Scene(ID3D11ShaderResourceView * depth)
@@ -1062,6 +1530,25 @@ void DX11PostProcessClass::Draw_Pass(const PassSetup & pass)
block.Grade[1] = GRADE_CONTRAST;
block.Grade[2] = GRADE_SATURATION;
block.Grade[3] = GRADE_SPLIT;
+ block.Haze[0] = HazeTop;
+ block.Haze[1] = HazeThickness;
+ block.Haze[2] = HazeStrength;
+ block.Haze[3] = HazeReach;
+ block.HazeColour[0] = HazeColour[0];
+ block.HazeColour[1] = HazeColour[1];
+ block.HazeColour[2] = HazeColour[2];
+ block.HazeColour[3] = HazeWater;
+ memcpy(block.WorldFromClip, HazeWorldFromClip, sizeof(block.WorldFromClip));
+ memcpy(block.HazeField, HazeFieldRect, sizeof(block.HazeField));
+ memcpy(block.HazeMotion, HazeMotion, sizeof(block.HazeMotion));
+ memcpy(block.HazeSun, HazeSun, sizeof(block.HazeSun));
+ // the program reads only the sun's bearing, so its z says whether a shroud texture is bound
+ block.HazeSun[2] = (HazeShroudView != NULL) ? 1.0f : 0.0f;
+ memcpy(block.HazeShroudRect, HazeShroudRect, sizeof(block.HazeShroudRect));
+ memcpy(block.HazeWakeInfo, HazeWakeInfo, sizeof(block.HazeWakeInfo));
+ memcpy(block.HazeWakeEnds, HazeWakeEnds, sizeof(block.HazeWakeEnds));
+ memcpy(block.HazeWakeShape, HazeWakeShape, sizeof(block.HazeWakeShape));
+ memcpy(block.HazeClock, HazeClock, sizeof(block.HazeClock));
memcpy(mapped.pData, &block, sizeof(block));
context->Unmap(ConstantBuffer, 0);
@@ -1079,8 +1566,8 @@ void DX11PostProcessClass::Draw_Pass(const PassSetup & pass)
context->RSSetViewports(1, &viewport);
const float blend_factor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
- context->OMSetBlendState(pass.Multiply ? MultiplyBlendState : BlendState, blend_factor,
- 0xffffffff);
+ context->OMSetBlendState(pass.Multiply ? MultiplyBlendState : pass.Blend ? AlphaBlendState : BlendState,
+ blend_factor, 0xffffffff);
context->OMSetDepthStencilState(DepthState, 0);
context->RSSetState(RasterizerState);
@@ -1092,9 +1579,22 @@ void DX11PostProcessClass::Draw_Pass(const PassSetup & pass)
ID3D11ShaderResourceView * resources[2] = { pass.Source, pass.Extra };
context->PSSetShaderResources(0, 2, resources);
context->PSSetConstantBuffers(0, 1, &ConstantBuffer);
+ const bool haze = (pass.Shader == HazeShader);
+ if (haze) {
+ // The same buffer at b1 as well, where the haze program reads its own fields of it, and
+ // the disturbance field at t2 (none yet reads as an unstirred field).
+ context->PSSetConstantBuffers(1, 1, &ConstantBuffer);
+ ID3D11ShaderResourceView * haze_resources[2] = { HazeFieldView, HazeShroudView };
+ context->PSSetShaderResources(2, 2, haze_resources);
+ }
context->Draw(FULL_SCREEN_VERTEX_COUNT, 0);
+ if (haze) {
+ ID3D11ShaderResourceView * no_haze_resources[2] = { NULL, NULL };
+ context->PSSetShaderResources(2, 2, no_haze_resources);
+ }
+
// The texture this pass read is the target the next one writes, and D3D11 unbinds a resource
// silently when it is bound both ways at once. Letting go here says which of the two bindings
// was meant.
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.h
index 031cb8b89..9b8a9b475 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.h
@@ -122,6 +122,55 @@ float DX11Post_Additive_Gain();
// does not start with bloom keeps its scene in eight bits and is never graded.
void DX11Post_Set_Grade(float amount);
+// The Warm Light option's ground haze (MapLight): a pale layer lying in the low ground,
+// laid over the opaque world before the particles out of the frame's depth taken back to world
+// height. Top is the world height the haze thins out to nothing at, thickness how far below that
+// it reaches full strength, strength the most of the haze colour a pixel takes (zero, the default,
+// is no pass at all) and reach the eye distance at which it stops thickening. Nothing below water,
+// the world height of the water surface the haze lies over, takes any. Set every frame.
+void DX11Post_Set_Haze(const float colour[3], float top, float thickness, float strength, float reach,
+ float water);
+
+// The haze's movement. Field_rect is the world rectangle the disturbance field covers, as its
+// origin and one over its size on each axis; drift is how far the wind has carried the haze's
+// patches so far, in world units; noise_scale is one over a patch's size; stir is how much of the
+// haze a full field takes away; toward_sun points at the sun and warmth is how much warmer the
+// haze looks toward it. Set every frame with the haze.
+void DX11Post_Set_Haze_Motion(const float field_rect[4], float drift_x, float drift_y,
+ float noise_scale, float stir, const float toward_sun[3], float warmth);
+
+// The disturbance field: what passed through the haze lately, size by size bytes, row by row from
+// the field's origin, 255 where it is most stirred. Uploaded at the next haze pass.
+const unsigned DX11_POST_HAZE_FIELD_SIZE = 256;
+#define DX11_POST_HAZE_FIELD_SIZE_TEXT "256"
+void DX11Post_Set_Haze_Field(const unsigned char * texels);
+
+// The view of the shroud texture the terrain draws its fog with (Direct3D11_Set_Haze_Shroud finds
+// it), and the terrain's own world to texture mapping (rect: world origin x, y, then one over the
+// world size of the texture x, y). The haze reads its green, 1 in plain sight, lower in the fog,
+// 0 under the shroud, and fades with it, so it lies over exactly the fog the ground shows. Set
+// every frame; null reads everything as in sight. The view is borrowed, not held.
+void DX11Post_Set_Haze_Shroud(ID3D11ShaderResourceView * view, const float rect[4]);
+
+// The wakes aircraft leave in the haze, as segments of their recent paths. A segment is eight
+// numbers: its far end x, y and its near end x, y (the end toward the aircraft), then how far
+// behind the aircraft along the path its near end lies, the tangent of the wake's half-angle, the
+// wake's strength (0 to 1) and one over the path length the wake lasts. Behind the aircraft the
+// haze is pushed apart in a wedge whose edges stand off the path by distance behind times that
+// tangent: along each edge a vortex arm_width world units across stirs and rolls the haze, and
+// the inside clears, easing open over open_soft. A segment with a negative tangent is a ring
+// instead: both ends the centre, its first number the radius and its last how far through its
+// life it is (0 to 1). seconds is the picture's clock, which turns the vortices. Set every
+// frame; a count past the limit keeps the first ones.
+const unsigned DX11_POST_HAZE_WAKE_LIMIT = 64;
+#define DX11_POST_HAZE_WAKE_LIMIT_TEXT "64"
+// Where the segments' second halves start in the haze program's constants: c24 plus the limit,
+// and the clock after them.
+#define DX11_POST_HAZE_WAKE_SHAPE_REGISTER_TEXT "c88"
+#define DX11_POST_HAZE_CLOCK_REGISTER_TEXT "c152"
+void DX11Post_Set_Haze_Wakes(const float (*segments)[8], unsigned count, float arm_width, float open_soft,
+ float seconds);
+
// A blast warping the picture around it: the frame drawn toward a point and then pushed out by a
// ring that travels away from it. Not an effect in the chain and not a switch: whatever chain is
// set, one more pass goes on its end for every frame that has a warp in it, and a frame with none
@@ -197,6 +246,21 @@ public:
// depth and viewport again afterwards. False when it drew nothing.
bool Occlude_Scene(ID3D11ShaderResourceView * depth);
+ // The ground haze (DX11Post_Set_Haze) blended into the scene target as it stands, at the same
+ // moment as Occlude_Scene and under the same terms, once a frame. World_from_clip takes the
+ // depth back to the world. False when it drew nothing; the caller rebinds as for the other.
+ bool Haze_Scene(ID3D11ShaderResourceView * depth, const float world_from_clip[16]);
+
+ // The haze's program comes from the backend's cache of compiled programs (dx11shaders.cache), so
+ // only the first run that meets it compiles it. Wants_Haze_Program is true while the haze is on
+ // and no program is loaded or refused; Load_Haze_Program takes the bytecode for the source
+ // Haze_Program_Source gives, or null when the compiler refused it, which leaves the haze off.
+ bool Wants_Haze_Program() const;
+ const char * Haze_Program_Source() const;
+ void Load_Haze_Program(const void * bytecode, SIZE_T size);
+ // The same program compiled here, past any cache, for a caller without the backend (the tests).
+ void Compile_Haze_Program();
+
// Call once at the very top of a frame, before any scene of it (a mirror's included) begins.
// Arms Occlude_Scene again.
void Open_Frame();
@@ -238,6 +302,8 @@ private:
bool Ungraded;
// The pass's colour multiplies what the destination holds instead of replacing it.
bool Multiply;
+ // The pass's colour goes over what the destination holds by its alpha.
+ bool Blend;
};
bool Create_Shaders();
@@ -261,9 +327,11 @@ private:
ID3D11PixelShader * BloomCompositeShader;
ID3D11PixelShader * WarpShader;
ID3D11PixelShader * SceneOcclusionShader;
+ ID3D11PixelShader * HazeShader;
ID3D11SamplerState * Sampler;
ID3D11BlendState * BlendState;
ID3D11BlendState * MultiplyBlendState;
+ ID3D11BlendState * AlphaBlendState;
ID3D11DepthStencilState * DepthState;
ID3D11RasterizerState * RasterizerState;
ID3D11Buffer * ConstantBuffer;
@@ -292,6 +360,16 @@ private:
bool Resolved;
// Occlude_Scene ran this frame, so Finish leaves the occlusion pass out.
bool Occluded;
+ // Haze_Scene ran this frame, and the matrix it handed the pass.
+ bool Hazed;
+ float HazeWorldFromClip[16];
+ // The haze program, compiled on first use, failed to compile; not tried again.
+ bool HazeRefused;
+ // The haze's disturbance field on the device, made at its first upload.
+ ID3D11Texture2D * HazeFieldTexture;
+ ID3D11ShaderResourceView * HazeFieldView;
+ // The terrain's shroud texture under the haze, borrowed from its D3D9 texture each pass.
+ ID3D11ShaderResourceView * HazeShroudView;
char Diagnostic[192];
};
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp
index 73fb2de91..d625fdbdf 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp
@@ -537,6 +537,16 @@ void Direct3D11_Mirror_Texture(unsigned stage, struct IDirect3DBaseTexture9 * te
Backend.Set_Texture_Missing(stage, texture != NULL && view == NULL);
}
+void Direct3D11_Set_Haze_Shroud(struct IDirect3DBaseTexture9 * texture, const float rect[4])
+{
+ if (!Active) {
+ return;
+ }
+ DX11Post_Set_Haze_Shroud(texture == NULL
+ ? NULL
+ : DX11Texture_Mirror(Device.Get_Device(), Device.Get_Context(), texture), rect);
+}
+
void Direct3D11_Set_Headlights(const float * lights, unsigned count, const float gain[3])
{
if (Active) {
@@ -636,6 +646,13 @@ void Direct3D11_Set_Emissive(bool emissive)
}
}
+void Direct3D11_Set_Team_Glow(bool glow)
+{
+ if (Active) {
+ Backend.Set_Team_Glow(glow);
+ }
+}
+
static bool DrawEffectsAllowed = true;
void Direct3D11_Set_Draw_Effect(unsigned effect, const float parameters[4])
@@ -666,7 +683,25 @@ unsigned Direct3D11_Requested_Draw_Effect(float parameters[4])
void Direct3D11_Occlude_Scene()
{
- if (Active && Backend.Draws_Into_Scene() && Post.Occlude_Scene(Device.Get_Depth_Texture())) {
+ if (!Active || !Backend.Draws_Into_Scene()) {
+ return;
+ }
+ bool drew = Post.Occlude_Scene(Device.Get_Depth_Texture());
+ // The prototype ground haze goes on at the same moment, over the occlusion and under the fire.
+ if (Post.Wants_Haze_Program()) {
+ std::vector<unsigned char> code;
+ if (Backend.Compile_Pixel_Program(Post.Haze_Program_Source(), "dx11haze", code) && !code.empty()) {
+ Post.Load_Haze_Program(&code[0], code.size());
+ } else {
+ Post.Load_Haze_Program(NULL, 0);
+ }
+ }
+ float world_from_clip[16];
+ if (Backend.Scene_World_From_Clip(world_from_clip)
+ && Post.Haze_Scene(Device.Get_Depth_Texture(), world_from_clip)) {
+ drew = true;
+ }
+ if (drew) {
Backend.Resume_Scene();
}
}
@@ -843,6 +878,7 @@ void Direct3D11_Begin_Scene()
if (!FrameOpen) {
begin_frame();
Post.Open_Frame();
+ Backend.Open_Frame();
}
// Before the backend binds anything: the scene goes wherever this says it goes, and a frame
// that asked for a chain and could not have one falls back to the swap chain here rather
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h
index eb4b0f314..e88486b54 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h
@@ -110,6 +110,10 @@ DX11BufferTwinClass * Direct3D11_Twin_Index_Buffer(unsigned byte_count, bool dyn
// first bind and kept on it, so nothing in the loaders has to know this exists.
void Direct3D11_Mirror_Texture(unsigned stage, struct IDirect3DBaseTexture9 * texture);
+// The shroud texture the terrain draws its fog with, handed to the Warm Light haze with the
+// terrain's world to texture mapping (DX11Post_Set_Haze_Shroud). Null reads everything as in sight.
+void Direct3D11_Set_Haze_Shroud(struct IDirect3DBaseTexture9 * texture, const float rect[4]);
+
// The vehicle headlights for the frame, nearest the camera first, eight floats each: world
// position, reach, world direction, cosine of the cone's edge; and what a pixel gains per channel
// per unit of their light. A Direct3D 9 run ignores them.
@@ -179,6 +183,10 @@ void Direct3D11_Set_Fire_Look(bool fire);
// smoke shade (DX11BackendClass::Set_Emissive). The sorting pool sets it.
void Direct3D11_Set_Emissive(bool emissive);
+// The draws that follow are a house colour mesh that glows past white for the bloom
+// (DX11BackendClass::Set_Team_Glow, the Team Glow option). The mesh renderer sets it around the mesh.
+void Direct3D11_Set_Team_Glow(bool glow);
+
// 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 fc96e672d..4e7a024c6 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp
@@ -58,6 +58,7 @@ void Direct3D11_Mirror_Light_Disabled(unsigned) {}
DX11BufferTwinClass * Direct3D11_Twin_Vertex_Buffer(unsigned, bool) { return NULL; }
DX11BufferTwinClass * Direct3D11_Twin_Index_Buffer(unsigned, bool) { return NULL; }
void Direct3D11_Mirror_Texture(unsigned, struct IDirect3DBaseTexture9 *) {}
+void Direct3D11_Set_Haze_Shroud(struct IDirect3DBaseTexture9 *, const float [4]) {}
void Direct3D11_Set_Headlights(const float *, unsigned, const float [3]) {}
void Direct3D11_Set_Blast_Lights(const float *, unsigned) {}
@@ -77,6 +78,7 @@ void Direct3D11_Set_Scene_View(const float [16]) {}
void Direct3D11_Set_Smoke_Glow(bool) {}
void Direct3D11_Set_Fire_Look(bool) {}
void Direct3D11_Set_Emissive(bool) {}
+void Direct3D11_Set_Team_Glow(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/dx8renderer.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8renderer.cpp
index 52411b50f..26962e659 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8renderer.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8renderer.cpp
@@ -1923,6 +1923,12 @@ void DX8TextureCategoryClass::Render(void)
if (draw_effect != 0) {
Direct3D11_Set_Draw_Effect(draw_effect, mesh->Get_Draw_Effect_Parameters());
}
+ // A house colour mesh under the Team Glow option. Immediate draws only: a sorted one draws later,
+ // after this has been put back, and goes without.
+ const bool team_glow = mesh->Peek_Model()->Get_Flag(MeshGeometryClass::TEAM_GLOW) != 0;
+ if (team_glow) {
+ Direct3D11_Set_Team_Glow(true);
+ }
if ((!!mesh->Peek_Model()->Get_Flag(MeshGeometryClass::SORT)) && WW3D::Is_Sorting_Enabled()) {
renderer->Render_Sorted(mesh->Get_Base_Vertex_Offset(),mesh->Get_Bounding_Sphere());
@@ -1982,6 +1988,9 @@ void DX8TextureCategoryClass::Render(void)
static const float no_effect[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
Direct3D11_Set_Draw_Effect(0, no_effect);
}
+ if (team_glow) {
+ Direct3D11_Set_Team_Glow(false);
+ }
//--------------------------------------------------------------------
if (mesh->Get_ObjectScale() != 1.0f)
DX8Wrapper::Set_DX8_Render_State(D3DRS_NORMALIZENORMALS, false);
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp
index 9de0478f1..b2c5e8a5b 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp
@@ -87,7 +87,10 @@ static const EngineShaderEntry ENGINE_SHADERS[] = {
FLAT_TERRAIN_OPENING, TERRAIN_NOISE_2_CHAIN },
{ ENGINE_SHADER_ROAD_NOISE_2, "roadnoise2.pso", "engine:roadnoise2",
ROAD_NOISE_2_OPENING, ROAD_NOISE_2_CHAIN },
- { ENGINE_SHADER_MONOCHROME, "monochrome.pso", "engine:monochrome", NULL, NULL }
+ { ENGINE_SHADER_MONOCHROME, "monochrome.pso", "engine:monochrome", NULL, NULL },
+ { ENGINE_SHADER_WATER_TRAPEZOID_FOAM, "trapezoid water foam ps.1.1", "engine:trapezoidwaterfoam",
+ NULL, NULL },
+ { ENGINE_SHADER_WATER_RIVER_FOAM, "river water foam ps.1.1", "engine:riverwaterfoam", NULL, NULL }
};
static const unsigned ENGINE_SHADER_COUNT = sizeof(ENGINE_SHADERS) / sizeof(ENGINE_SHADERS[0]);
@@ -204,7 +207,8 @@ static void write_trees(std::string & hlsl)
// ffshader's declarations, member for member and in the same order, so a transcribed pixel program
// is bound with the same constant buffer, the same textures and the same samplers as a generated
// one. Reading fewer of them than are declared costs nothing.
-static void write_pixel_preamble(std::string & hlsl, bool volumetric = false)
+static void write_pixel_preamble(std::string & hlsl, bool volumetric = false,
+ const char * declarations = NULL)
{
for (unsigned stage = 0; stage < MAXIMUM_COMBINER_STAGES; ++stage) {
char line[128];
@@ -251,6 +255,9 @@ static void write_pixel_preamble(std::string & hlsl, bool volumetric = false)
if (volumetric) {
hlsl += VOLUMETRIC_SAMPLING;
}
+ if (declarations != NULL) {
+ hlsl += declarations;
+ }
hlsl +=
"\n"
"struct Input\n"
@@ -336,6 +343,135 @@ static void write_river_water(std::string & hlsl)
" current.rgb = saturate(current.rgb + sparkle);\n";
}
+/*
+** The water with foam on it (the Water Foam option), Direct3D 11 only: the SDL3 text is the plain water.
+**
+** How deep the water is under a pixel comes out of the scene's depth, the soft particles' copy at
+** t7, which W3DWater takes right before it draws: the ground and every opaque object are in it and
+** the water is not. The pixel and what stands behind it both go back to the world through
+** WorldFromClip, and the depth is the height between them. The backend uploads that matrix and
+** ShadowViewport for every program that reads the scene's depth, sun's map or not; a cleared depth
+** or no copy at all (a null view reads zero) counts as deep water: no foam band, no edge.
+**
+** Where the foam sits comes from TexCoord2, which both waters fill with the camera position taken
+** back to the world, times NOISE_REPEAT_FACTOR (1/16), plus the scroll: times sixteen it is the
+** world drifting with the water, interpolated exactly, where the depth's way back would shimmer.
+** The swell's phase rides in TextureFactor.g and turns the two noise layers round circles in
+** opposite directions, so the flecks boil instead of sliding. A feathered trapezoid hands over the
+** curve the shoreline tiles wrote into the frame's alpha (TextureFactor.r times 32 is the depth
+** that turns opaque, .a the deepest opacity) and W3DWater blends on the source alpha in place of
+** the destination's, so the shallow foam is not faded out with the water around it.
+**
+** The sun's shadow lands on the surface last but the shroud, through SHADOW_APPLY, the way the
+** ground takes it. Every number to tune is a WATER_FOAM_ constant at the top of the text.
+*/
+static const char * const WATER_FOAM_SAMPLING =
+ "Texture2D SceneDepth : register(t7);\n"
+ "\n"
+ "static const float WATER_FOAM_SHORE_DEPTH = 3.5; // world units of water the shore band reaches through\n"
+ "static const float WATER_FOAM_EDGE = 0.6; // world units over which the water fades into the bank\n"
+ "static const float WATER_FOAM_FINE = 0.22; // fleck noise, cells per world unit\n"
+ "static const float WATER_FOAM_BROAD = 0.03; // the patches the flecks gather in\n"
+ "static const float WATER_FOAM_SWIRL = 1.4; // how far a cycle moves the fine layer, in cells\n"
+ "static const float WATER_FOAM_CAPS = 0.55; // whitecap strength\n"
+ "static const float WATER_FOAM_CAP_LOW = 0.42; // fine times broad where a fleck starts\n"
+ "static const float WATER_FOAM_CAP_HIGH = 0.62; // and where it is solid\n"
+ "static const float WATER_FOAM_OPACITY = 0.85; // how opaque full foam makes the water\n"
+ "static const float3 WATER_FOAM_COLOUR = float3(0.90, 0.94, 0.96);\n"
+ "\n"
+ "float foam_hash(float2 p)\n"
+ "{\n"
+ " float3 q = frac(p.xyx * 0.1031);\n"
+ " q += dot(q, q.yzx + 33.33);\n"
+ " return frac((q.x + q.y) * q.z);\n"
+ "}\n"
+ "\n"
+ "float foam_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(foam_hash(i), foam_hash(i + float2(1.0, 0.0)), f.x),\n"
+ " lerp(foam_hash(i + float2(0.0, 1.0)), foam_hash(i + float2(1.0, 1.0)), f.x), f.y);\n"
+ "}\n"
+ "\n"
+ "float3 foam_world(float2 pixel, float depth)\n"
+ "{\n"
+ " float2 ndc = float2(pixel.x * ShadowViewport.x * 2.0 - 1.0, 1.0 - pixel.y * ShadowViewport.y * 2.0);\n"
+ " float4 world = mul(float4(ndc, depth, 1.0), WorldFromClip);\n"
+ " return world.xyz / world.w;\n"
+ "}\n"
+ "\n"
+ "float foam_water_depth(float4 position)\n"
+ "{\n"
+ " float scene = SceneDepth.Load(int3(position.xy, 0)).r;\n"
+ " if (ShadowViewport.x <= 0.0 || scene <= 0.0 || scene >= 1.0) return 1000.0;\n"
+ " return max(foam_world(position.xy, position.z).z - foam_world(position.xy, scene).z, 0.0);\n"
+ "}\n"
+ "\n"
+ "float foam_amount(float2 world, float depth, float phase)\n"
+ "{\n"
+ " float angle = phase * 6.2831853;\n"
+ " float2 swirl = float2(cos(angle), sin(angle)) * WATER_FOAM_SWIRL;\n"
+ " float fine = foam_noise(world * WATER_FOAM_FINE + swirl);\n"
+ " float broad = foam_noise(world * WATER_FOAM_BROAD - swirl.yx * 0.15);\n"
+ " float caps = smoothstep(WATER_FOAM_CAP_LOW, WATER_FOAM_CAP_HIGH, fine * broad) * WATER_FOAM_CAPS;\n"
+ " // A band that thins with depth, frayed by the fine grain so it laps rather than strokes.\n"
+ " float shore = 1.0 - saturate(depth / WATER_FOAM_SHORE_DEPTH);\n"
+ " float band = smoothstep(0.25, 0.65, shore * (0.55 + 0.45 * fine) + shore * shore * 0.4);\n"
+ " return saturate(max(caps, band));\n"
+ "}\n"
+ "\n";
+
+// The foam, the feather and the bank's fade, after the water's own colour and before the shadow.
+// shade is how bright the vertex colour lets the foam be, which carries the river's shroud.
+static void write_water_foam(std::string & hlsl, const char * edge_alpha)
+{
+ hlsl +=
+ " float water_depth = foam_water_depth(input.Position);\n"
+ " float foam = foam_amount(input.TexCoord2 * 16.0, water_depth, TextureFactor.g);\n"
+ " if (TextureFactor.a > 0.0) {\n"
+ " current.a = min(water_depth / max(TextureFactor.r * 32.0, 0.01), TextureFactor.a);\n"
+ " }\n"
+ " float shade = max(input.Diffuse.r, max(input.Diffuse.g, input.Diffuse.b));\n"
+ " current.rgb = lerp(current.rgb, WATER_FOAM_COLOUR * shade, foam);\n"
+ " current.a = lerp(current.a, ";
+ hlsl += edge_alpha;
+ hlsl +=
+ ", foam * WATER_FOAM_OPACITY) * saturate(water_depth / WATER_FOAM_EDGE);\n";
+ hlsl += SHADOW_APPLY;
+}
+
+static void write_trapezoid_water_foam(std::string & hlsl)
+{
+ write_pixel_preamble(hlsl, true, WATER_FOAM_SAMPLING);
+ hlsl +=
+ " float4 current = saturate(input.Diffuse * texel0);\n"
+ " current.rgb = saturate(texel1.rgb * texel2.rgb + current.rgb);\n";
+ write_water_foam(hlsl, "1.0");
+ hlsl += " current.rgb = saturate(current.rgb * texel3.rgb);\n";
+}
+
+// The river's edge texture fades its ends as well as its banks, and the foam stops where it does.
+static void write_river_water_foam(std::string & hlsl)
+{
+ write_pixel_preamble(hlsl, true, WATER_FOAM_SAMPLING);
+ hlsl +=
+ " float4 current;\n"
+ " current.rgb = saturate(input.Diffuse.rgb * texel0.rgb);\n"
+ " current.a = saturate(texel0.a * texel3.a);\n"
+ " float3 sparkle = saturate(texel1.rgb * texel2.rgb);\n"
+ " sparkle = saturate(sparkle + texel3.rgb);\n"
+ " sparkle = saturate(sparkle * input.Diffuse.a);\n"
+ " current.rgb = saturate(current.rgb + sparkle);\n";
+ write_water_foam(hlsl, "texel3.a");
+}
+
+bool EngineShader_Reads_Scene_Depth(EngineShaderProgram program)
+{
+ return program == ENGINE_SHADER_WATER_TRAPEZOID_FOAM || program == ENGINE_SHADER_WATER_RIVER_FOAM;
+}
+
/*
** The reflection W3DWater lays over map water once the water itself is drawn:
**
@@ -512,6 +648,22 @@ static bool write_engine_pixel_program(EngineShaderProgram program,
else if (program == ENGINE_SHADER_WATER_REFLECTION) {
write_water_reflection(hlsl);
}
+ else if (program == ENGINE_SHADER_WATER_TRAPEZOID_FOAM) {
+ if (volumetric) {
+ write_trapezoid_water_foam(hlsl);
+ }
+ else {
+ write_trapezoid_water(hlsl); // SDL3: no scene depth and no WorldFromClip in its block
+ }
+ }
+ else if (program == ENGINE_SHADER_WATER_RIVER_FOAM) {
+ if (volumetric) {
+ write_river_water_foam(hlsl);
+ }
+ else {
+ write_river_water(hlsl);
+ }
+ }
else if (program == ENGINE_SHADER_MONOCHROME) {
write_monochrome(hlsl);
}
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.h
index 2f591f111..3ee0c4b58 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.h
@@ -70,7 +70,12 @@ enum EngineShaderProgram
ENGINE_SHADER_FLAT_TERRAIN_NOISE,
ENGINE_SHADER_FLAT_TERRAIN_NOISE_2,
ENGINE_SHADER_ROAD_NOISE_2,
- ENGINE_SHADER_MONOCHROME
+ ENGINE_SHADER_MONOCHROME,
+ // The trapezoid and river water again with foam, shore depth and the sun's shadow
+ // (the Water Foam option). Same D3D9 bytecode, a second name; after the table's last shipped program
+ // so the shader case sweep and its reference set stay as they were.
+ ENGINE_SHADER_WATER_TRAPEZOID_FOAM,
+ ENGINE_SHADER_WATER_RIVER_FOAM
};
// The name the engine loaded the shader under: a path for the ones that ship as files
@@ -96,6 +101,10 @@ bool EngineShader_Pixel_Program(EngineShaderProgram program,
// the trees are not among them: both have shadows of their own.
bool EngineShader_Paints_Ground(EngineShaderProgram program);
+// Which transcribed programs read the scene's depth copy at t7: the foam water, for how deep the
+// water is under each pixel. The copy is the soft particles' (DX11BackendClass::Take_Scene_Depth).
+bool EngineShader_Reads_Scene_Depth(EngineShaderProgram program);
+
// What the pipeline cache keys this program under and what the dump calls its file.
const char * EngineShader_Name(EngineShaderProgram program);
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp
index de79ad6f7..9a2500bdf 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp
@@ -266,6 +266,10 @@ static bool generate_combiners(const CombinerDescription & description,
}
std::string body;
+ // Black until stage 0 samples, so a team glow draw with no stage glows not at all.
+ if (description.TeamGlow) {
+ body += " float4 team_texel = float4(0.0, 0.0, 0.0, 0.0);\n";
+ }
for (unsigned stage = 0; stage < description.StageCount; ++stage) {
const CombinerStage & source = description.Stages[stage];
@@ -295,6 +299,11 @@ static bool generate_combiners(const CombinerDescription & description,
snprintf(line, sizeof(line), " texel = float4(1.0, 1.0, 1.0, 1.0);\n");
}
body += line;
+ // The paint, kept for the team glow's brightness: a later stage's texel is a detail or an
+ // environment map, not the house colour's pattern.
+ if (stage == 0 && description.TeamGlow) {
+ body += " team_texel = texel;\n";
+ }
std::string colour_argument0, colour_argument1, colour_argument2;
std::string alpha_argument0, alpha_argument1, alpha_argument2;
@@ -466,6 +475,17 @@ static bool generate_combiners(const CombinerDescription & description,
: " float fire_shape = " FIRE_LOOK_BURN_SHAPE_ALPHA ";\n" FIRE_LOOK_BURN
" current.a *= fire_keep;\n";
}
+ // The house colour's hue at full brightness, taken from the lit colour before the shade touches
+ // it, so the light's level drops out. Only the texture's bright texels get it, and only as much
+ // as the hue is saturated: a grey or white team, or a dull panel, would glow white.
+ if (description.TeamGlow) {
+ hlsl += " float team_peak = max(max(current.r, current.g), max(current.b, 1.0 / 64.0));\n"
+ " float3 team_hue = current.rgb / team_peak;\n"
+ " float team_saturation = 1.0 - min(min(team_hue.r, team_hue.g), team_hue.b);\n"
+ " float team_bright = smoothstep(" TEAM_GLOW_LOW ", " TEAM_GLOW_HIGH ","
+ " dot(team_texel.rgb, float3(0.299, 0.587, 0.114)));\n"
+ " float3 team_glow = team_hue * (team_bright * team_saturation * " TEAM_GLOW_GAIN ");\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";
@@ -481,6 +501,17 @@ static bool generate_combiners(const CombinerDescription & description,
hlsl += " current.rgb = saturate(current.rgb + input.Specular.rgb * texel.rgb);\n";
}
+ // After the shade, past 1.0 for the bloom on the half float target, then the whole colour scaled
+ // down until its brightest channel is at TEAM_GLOW_CEILING. One factor on all three channels
+ // keeps their ratio, where a per-channel clamp (or the tone curve on a channel far past it)
+ // flattens the top one and moves the hue toward white. Before the fog, so a fogged base still
+ // fades with distance.
+ if (description.TeamGlow) {
+ hlsl += " current.rgb += team_glow;\n"
+ " current.rgb *= min(1.0, " TEAM_GLOW_CEILING
+ " / max(max(current.r, current.g), max(current.b, 1.0 / 64.0)));\n";
+ }
+
if (target == COMBINER_SHADER_TARGET_D3D11
&& !CombinerShader_Append_Pixel_Pipeline(description.PixelPipeline, hlsl)) {
return false;
@@ -580,6 +611,9 @@ std::string CombinerShader_Key(const CombinerDescription & description)
if (description.SmokeGlow) {
key += ":G";
}
+ if (description.TeamGlow) {
+ key += ":H";
+ }
if (description.SoftParticle != SOFT_PARTICLE_NONE) {
snprintf(field, sizeof(field), ":Z%u", description.SoftParticle);
key += field;
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h
index 27f1e4dd0..33199e404 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h
@@ -123,8 +123,27 @@ struct CombinerDescription
// through the colour, for an additive one. Initialised here for a caller that fills the rest
// field by field.
unsigned FireLook = 0;
+
+ // D3D11 only: a house colour mesh under the Team Glow option (DX11BackendClass::Set_Team_Glow). After
+ // the shade the pixel gains its own hue at full brightness, worth TEAM_GLOW_GAIN, the hue's
+ // saturation and how far the texel's luminance is between TEAM_GLOW_LOW and TEAM_GLOW_HIGH, then
+ // the colour is scaled as one so no channel passes TEAM_GLOW_CEILING. Initialised here for a
+ // caller that fills the rest field by field.
+ bool TeamGlow = false;
};
+// What the brightest house colour texel adds on top of itself under TeamGlow, in units of its own
+// brightest channel. The bloom's threshold is 1.0, so a whole texel lit past 0.2 goes over, which
+// is a stripe in shade as well as in the sun.
+#define TEAM_GLOW_GAIN "0.8"
+// The texel luminance where the glow starts and where it is whole: the panel's grey stays paint
+// and only the stripe's highlights glow.
+#define TEAM_GLOW_LOW "0.45"
+#define TEAM_GLOW_HIGH "0.8"
+// The brightest channel a glowing pixel may reach, the rest scaled with it: at most half a unit
+// past the bloom's threshold, where the tone curve still keeps a saturated hue apart from white.
+#define TEAM_GLOW_CEILING "1.5"
+
enum
{
FIRE_LOOK_NONE = 0,
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.h
index 7633a1bf4..08878b98d 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.h
@@ -121,6 +121,10 @@ public:
PRELIT_LIGHTMAP_MULTI_TEXTURE = 0x00008000,
ALLOW_NPATCHES = 0x00010000,
+
+ // Not in any file: W3DAssetManager::Recolor_Mesh sets it on a house colour mesh under
+ // the Team Glow option, and the mesh renderer hands it to Direct3D11_Set_Team_Glow.
+ TEAM_GLOW = 0x00020000,
};
void Reset_Geometry(int polycount,int vertcount);
diff --git a/GeneralsMD/Code/Tests/test_dx11post.cpp b/GeneralsMD/Code/Tests/test_dx11post.cpp
index 8398602e5..ec9d1dc66 100644
--- a/GeneralsMD/Code/Tests/test_dx11post.cpp
+++ b/GeneralsMD/Code/Tests/test_dx11post.cpp
@@ -687,3 +687,96 @@ TEST(dx11post_the_scene_takes_its_occlusion_once_a_frame_and_the_chain_then_skip
device.Set_Scene_View(NULL);
delete [] picture;
}
+
+// The prototype haze, white over a black scene, with the given wakes; hands back the level at the
+// middle of the picture and at a corner. The clip to world matrix is the identity, so a pixel's
+// world x and y are its own clip x and y and the depth, cleared to a half, is its height: under the
+// haze's top of one.
+static bool haze_levels(DeviceFixture & fixture, const float (*segments)[8], unsigned count,
+ unsigned char & middle_level, unsigned char & corner_level)
+{
+ const float WAKE_SPREAD = 0.05f;
+ const float OPEN_SOFT = 0.05f;
+ const float HAZE_TOP = 1.0f;
+ const float HAZE_THICKNESS = 1.0f;
+ const float HAZE_STRENGTH = 1.0f;
+ const float HAZE_REACH = 1000.0f;
+ const float NO_WATER = -1.0e6f;
+ const float NOISE_SCALE = 1.0f;
+ const float STIR = 0.85f;
+ const float SCENE_DEPTH = 0.5f;
+ const float CLOCK = 1.0f;
+ DX11DeviceClass & device = fixture.Get_Device();
+ DX11PostProcessClass & post = fixture.Get_Post();
+
+ DX11Post_Set_Haze_Wakes(segments, count, WAKE_SPREAD, OPEN_SOFT, CLOCK);
+ const float white[3] = { 1.0f, 1.0f, 1.0f };
+ DX11Post_Set_Haze(white, HAZE_TOP, HAZE_THICKNESS, HAZE_STRENGTH, HAZE_REACH, NO_WATER);
+ const float field[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
+ const float overhead[3] = { 0.0f, 0.0f, 1.0f };
+ DX11Post_Set_Haze_Motion(field, 0.0f, 0.0f, NOISE_SCALE, STIR, overhead, 0.0f);
+
+ unsigned char picture[SURFACE_SIZE * SURFACE_SIZE * BYTES_A_PIXEL];
+ fill_flat(picture, DARK_LEVEL);
+ const DX11PostEffect copy_only[] = { DX11_POST_COPY };
+ post.Set_Chain(copy_only, 1);
+ post.Compile_Haze_Program();
+ post.Open_Frame();
+ post.Begin_Frame();
+ device.Set_Scene_View(post.Scene_View());
+ device.Get_Context()->ClearDepthStencilView(device.Get_Depth_Stencil_View(), D3D11_CLEAR_DEPTH,
+ SCENE_DEPTH, 0);
+ const float identity[16] = {
+ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f };
+ const bool drawn = write_scene(device, post, picture)
+ && post.Haze_Scene(device.Get_Depth_Texture(), identity) && post.Run_Chain();
+ device.Set_Scene_View(NULL);
+ DX11Post_Set_Haze(white, 0.0f, HAZE_THICKNESS, 0.0f, HAZE_REACH, NO_WATER);
+ DX11Post_Set_Haze_Wakes(segments, 0, WAKE_SPREAD, OPEN_SOFT, CLOCK);
+
+ unsigned pitch = 0;
+ unsigned char * result = drawn ? read_back_buffer(device, pitch) : NULL;
+ if (result == NULL) {
+ return false;
+ }
+ middle_level = pixel_level(result, pitch, SURFACE_SIZE / 2, SURFACE_SIZE / 2);
+ corner_level = pixel_level(result, pitch, 1, 1);
+ delete [] result;
+ return true;
+}
+
+// A hovering helicopter's rotor wash, drawn for real: the disc inside its ring clears, and the haze
+// well outside it is left as it was. The ring sits in a late slot behind segments far off the
+// picture, which is where the second half of each segment lives past the first 32.
+TEST(dx11post_a_hover_ring_parts_the_haze_inside_it_in_any_slot)
+{
+ DeviceFixture fixture;
+ if (!fixture.Create()) {
+ printf("skip: no Direct3D 11 device on this machine\n");
+ return;
+ }
+
+ const unsigned RING_SLOT = 40;
+ const float RING_RADIUS = 0.5f;
+ const float RING_AGE = 0.3f;
+ const float FAR_OFF = 100.0f;
+ const unsigned char CLEARED_BY_AT_LEAST = 8;
+ float segments[RING_SLOT + 1][8];
+ for (unsigned slot = 0; slot < RING_SLOT; ++slot) {
+ const float far_segment[8] = { FAR_OFF, FAR_OFF, FAR_OFF + 1.0f, FAR_OFF, 0.0f, 0.2f, 1.0f, 0.01f };
+ memcpy(segments[slot], far_segment, sizeof(far_segment));
+ }
+ const float ring[8] = { 0.0f, 0.0f, 0.0f, 0.0f, RING_RADIUS, -1.0f, 1.0f, RING_AGE };
+ memcpy(segments[RING_SLOT], ring, sizeof(ring));
+
+ unsigned char calm_middle = 0;
+ unsigned char calm_corner = 0;
+ unsigned char washed_middle = 0;
+ unsigned char washed_corner = 0;
+ CHECK(haze_levels(fixture, segments, RING_SLOT, calm_middle, calm_corner));
+ CHECK(haze_levels(fixture, segments, RING_SLOT + 1, washed_middle, washed_corner));
+ printf("middle %u calm, %u washed; corner %u calm, %u washed\n", calm_middle, washed_middle,
+ calm_corner, washed_corner);
+ CHECK(calm_middle >= washed_middle + CLEARED_BY_AT_LEAST);
+ CHECK_EQ(calm_corner, washed_corner);
+}
diff --git a/GeneralsMD/Code/Tests/test_engineshader.cpp b/GeneralsMD/Code/Tests/test_engineshader.cpp
index 1bd8a0735..3195aa4a3 100644
--- a/GeneralsMD/Code/Tests/test_engineshader.cpp
+++ b/GeneralsMD/Code/Tests/test_engineshader.cpp
@@ -395,4 +395,15 @@ TEST(engineshader_writes_programs_the_compiler_accepts)
std::string monochrome;
CHECK(EngineShader_Pixel_Program(ENGINE_SHADER_MONOCHROME, pipeline, monochrome));
CHECK(compiles(compile, monochrome, EngineShader_Name(ENGINE_SHADER_MONOCHROME), PIXEL_PROFILE));
+
+ std::string trapezoid_foam;
+ CHECK(EngineShader_Pixel_Program(ENGINE_SHADER_WATER_TRAPEZOID_FOAM, pipeline, trapezoid_foam));
+ CHECK(contains(trapezoid_foam, "SceneDepth"));
+ CHECK(compiles(compile, trapezoid_foam, EngineShader_Name(ENGINE_SHADER_WATER_TRAPEZOID_FOAM),
+ PIXEL_PROFILE));
+
+ std::string river_foam;
+ CHECK(EngineShader_Pixel_Program(ENGINE_SHADER_WATER_RIVER_FOAM, pipeline, river_foam));
+ CHECK(compiles(compile, river_foam, EngineShader_Name(ENGINE_SHADER_WATER_RIVER_FOAM),
+ PIXEL_PROFILE));
}
diff --git a/GeneralsMD/Code/Tools/optionsmenu_layout.py b/GeneralsMD/Code/Tools/optionsmenu_layout.py
index ccb4a55da..375c6bd95 100644
--- a/GeneralsMD/Code/Tools/optionsmenu_layout.py
+++ b/GeneralsMD/Code/Tools/optionsmenu_layout.py
@@ -220,6 +220,9 @@ NEW_CONTROLS = [
(LABEL, "LabelMenuTransitionSpeed", "GUI:MenuTransitionSpeed"),
(SLIDER, "SliderMenuTransitionSpeed", None),
(CHECK, "CheckTurboModeMissions", "GUI:TurboModeMissions"),
+ (CHECK, "CheckMapLight", "GUI:MapLight"),
+ (CHECK, "CheckTeamGlow", "GUI:TeamGlow"),
+ (CHECK, "CheckWaterFoam", "GUI:WaterFoam"),
]
# EA's check boxes that shipped HIDDEN off the panel's right edge with working code behind them in
@@ -338,7 +341,9 @@ GROUP_LAYOUT = [
setting("LabelLightingStyle", "ComboBoxLightingStyle"),
setting("LabelBloom", "ComboBoxBloom"),
("check", "CheckGroundLighting"),
- ("check", "CheckHeatEffects")])]),
+ ("check", "CheckHeatEffects"),
+ ("check", "CheckMapLight"),
+ ("check", "CheckTeamGlow")])]),
("PageEffects", [
("GUI:OptionsGroupShadows",
@@ -348,6 +353,7 @@ GROUP_LAYOUT = [
("GUI:OptionsGroupExtras", [
("check", "CheckShowProps"),
("check", "CheckSmoothWater"),
+ ("check", "CheckWaterFoam"),
("check", "CheckExtraAnimations"),
("check", "CheckTreeSway"),
("check", "CheckBehindBuilding")]),