Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(ww3d2): water foam without blocks or a solid grey shore
Olcay Seygan3d9c5d5f5e6e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a75476ce2..789325473 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -948,7 +948,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 youare 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; it dresses the Classic water and stands down while the Modern water style is picked. Warm Light and Haze, at the foot of the Image group on the Graphics page, swings the sun low and warm and lays a light haze over the low ground, a fixed pattern that holds still whatever flies or drives through it. 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.+- 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. The foam no longer paints blocky camouflage patches or a solid grey outline on the water: it is broken lace along the shore and sparse flecks on open water. It dresses the Classic water and stands down while the Modern water style is picked. Warm Light and Haze, at the foot of the Image group on the Graphics page, swings the sun low and warm and lays a light haze over the low ground, a fixed pattern that holds still whatever flies or drives through it. 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.## Every replay, not just the last onediff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cppindex 743926f06..2c2a6b092 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp@@ -945,8 +945,8 @@ bool Supported()#if ZH_MODERN_WATER/** The Modern style is asked for and a device draws it. Classic graphics is the 2003 picture, so it- keeps EA's water whatever WaterStyle says, as it keeps the old clouds and drops the foam; the- quality slider and its presets put Modern into WaterStyle from Medium up. */+ keeps EA's water whatever WaterStyle says, as it keeps the old clouds and drops the foam. The+ quality slider and its presets leave WaterStyle alone: Modern is the player's own pick. */static Bool wantsModernWater(void){return TheGlobalData && TheGlobalData->m_waterStyle != 0 && !TheGlobalData->m_classicGraphicsdiff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cppindex 3873940e7..f05bfb79a 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp@@ -380,14 +380,15 @@ static void write_river_water(std::string & hlsl)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_SHORE_DEPTH = 3.0; // world units of water the lace at the shore reaches through\n"+ "static const float WATER_FOAM_SHORE = 0.75; // lace strength at the water's edge\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_FINE = 0.16; // lace, cells per world unit of its coarsest octave\n"+ "static const float WATER_FOAM_BROAD = 0.022; // the patches whitecaps gather in\n"+ "static const float WATER_FOAM_SWIRL = 0.9; // how far a cycle moves the lace, in cells\n"+ "static const float WATER_FOAM_CAPS = 0.32; // whitecap strength\n"+ "static const float WATER_FOAM_CAP_LOW = 0.52; // broad patch value where whitecaps start\n"+ "static const float WATER_FOAM_CAP_HIGH = 0.74; // and where they are at full strength\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"@@ -421,16 +422,37 @@ static const char * const WATER_FOAM_SAMPLING =" return max(foam_world(position.xy, position.z).z - foam_world(position.xy, scene).z, 0.0);\n""}\n""\n"+ // Foam is a web of thin veins. Value noise thresholded on its own shows its lattice as square blocks,+ // so every octave turns away from the last and the veins come from where the noise crosses its middle.+ // The fine octave's crease goes under a pixel from the top of the camera, and there it crawls as the+ // swell moves it, so it hands over to its own mean as a pixel grows past a quarter of its cell.+ "float foam_lace(float2 p)\n"+ "{\n"+ " float pixel = max(length(ddx(p)), length(ddy(p))) * 2.03;\n"+ " float2x2 turn = float2x2(0.8, 0.6, -0.6, 0.8);\n"+ " float2 q = mul(turn, p);\n"+ " float wander = foam_noise(q * 0.5 + 7.3);\n"+ " q += float2(wander, foam_noise(q.yx * 0.5 + 19.1)) * 1.6;\n"+ " float one = 1.0 - abs(2.0 * foam_noise(q) - 1.0);\n"+ " q = mul(turn, q) * 2.03 + 3.7;\n"+ " float two = 1.0 - abs(2.0 * foam_noise(q) - 1.0);\n"+ " return one * lerp(two, 0.64, saturate((pixel - 0.25) * 2.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 lace = foam_lace(world * WATER_FOAM_FINE + swirl);\n"+ " float aa = fwidth(lace);\n"+ // Bent and doubled, or the patches gather on the broad noise's own lattice as faint squares.+ " float2 patch = mul(float2x2(0.8, -0.6, 0.6, 0.8), world) * WATER_FOAM_BROAD - swirl.yx * 0.1;\n"+ " patch += float2(foam_noise(patch * 0.61 + 3.1), foam_noise(patch.yx * 0.61 + 11.7)) * 1.5;\n"+ " float broad = foam_noise(patch) * 0.65 + foam_noise(mul(float2x2(0.6, 0.8, -0.8, 0.6), patch) * 2.3 + 5.3) * 0.35;\n"+ " float caps = smoothstep(0.55 - aa, 0.95 + aa, lace) * smoothstep(WATER_FOAM_CAP_LOW, WATER_FOAM_CAP_HIGH, broad) * WATER_FOAM_CAPS;\n"+ " // The lace thickens toward the edge and only there does it close up, so the shore laps.\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"+ " float band = smoothstep(0.7 - 0.55 * shore - aa, 0.95 - 0.45 * shore + aa, lace) * sqrt(shore) * WATER_FOAM_SHORE;\n"" return saturate(max(caps, band));\n""}\n""\n";