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.

refactor(ww3d2): remove generated normal maps and terrain bump

Olcay Seyganac0bf310ced1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d6b6a712e..32f932e65 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -416,11 +416,8 @@ found and fixed — EA's own, not port damage.**
- Hotkeys work again after Alt+Tab, and the game's own pointer comes back with them. Since 2.4.0, returning to a fullscreen game left Windows thinking no window was listening to the keyboard: every key you pressed made the Windows error sound and did nothing in the game, and the plain Windows arrow stood in for the game's cursor. The game takes the keyboard back as it comes up from the taskbar now.
- 481 base-game textures at four times the resolution now beat Zero Hour's downscaled copies.
- The ground is drawn at twice the detail. Every map square used to get a 64-pixel patch of its ground texture, squeezed into sixteen-bit colour; it gets 128 pixels now in full colour, so sand, gravel and tracks stop turning to blocks and bands when you zoom in, and a ground texture that ships at twice the size is shown at that size.
-- The ground has relief. Every grain of sand, pebble and crack catches the map's own sun on one side and falls into shade on the other, worked out from the ground's own picture when the map loads, and it follows the sun on a dusk map or a night one. The light the ground already had from its hills is kept; the relief goes on top. It is part of the new picture, so a machine on the old renderer keeps the flat ground.
-- Buildings and vehicles no longer go dark as you pull the camera back. The surface detail that catches the sun was stored at smaller sizes for far-off viewing, and those smaller copies were all tilted the same way, so from the default camera height or higher a GLA Command Center's gold dome turned brown and its walls went dull. The small copies are made again, straight this time, and the dome stays gold at every zoom. It is one new download of the surface detail file, 333 MB.
+- The fake relief is gone, and the sharp textures stay. Every model and the ground used to be lit through bumps guessed from the colours of the texture itself, so a dark stain read as a dent and a painted stripe as a ridge, and soot on a damaged wall turned into black and white marble. Units, buildings and the ground are lit the way EA lit them in 2003 again, on top of the textures at twice their size. The update is 333 MB smaller, and a game folder that has the old surface detail file loses it on the next update.
- 625 sharpened textures no longer turn black from the normal camera height. Their far-off copies were made by a tool that dimmed each one by how see-through it was, and some of these pictures are almost entirely see-through in a layer the game never shows, so the tech reinforcement pad in the middle of Twilight Flame drew pitch black unless you zoomed right in. Its far copy measured 1.5 out of 255 where the close one measured 118. They are made again the way EA made theirs, and the pad keeps its colour at every zoom.
-- A damaged building looks damaged, not carved out of marble. The damaged and burning versions of a building's skin are separate pictures a quarter the size of the healthy one, and the surface detail made from them spread one blotch of soot into a hill across a whole wall panel, so a command centre under fire turned black and white. They draw flat now, and the panels, rivets and deck stripes show through the soot again.
-- A tank keeps its surface detail when it fires. The flash of a gun, an explosion or a fire lights whatever stands next to it, and that light used to switch the whole model back to the old flat lighting for as long as it lasted, so every shot and every blast nearby wiped the relief off a vehicle for a moment. The flash is added on top now and the sun keeps drawing the detail.
- Headlights light the road. On a night map a Humvee, an Avenger or a truck used to drive behind two glowing cones that lit nothing, and the ground in front of it stayed as dark as the rest of the map. Now the lamps throw a warm pool of light ahead of the vehicle that moves with it, across the ground, the buildings and the other units standing in it. Most of a map's trees and its water are not lit by it yet. The sixteen lit vehicles nearest the camera shine; an enemy's lamps show only where you can see the enemy. Twenty lit vehicles on Dark Night at 1920x1080 ran at 2.63ms a frame against 2.67ms without, which is inside the noise. It is part of the new picture: on the old renderer or the Classic graphics setting the lamps are the glowing cones they always were.
- A long thin texture loads at the size it was drawn at. Anything wider than eight to one used to be stretched onto a bigger, blurrier one, because that was the limit of a 2002 graphics card; the card is asked now, and modern ones have no such limit.
- Anything standing still keeps its shadow in the fog. A town you have already walked through used
@@ -1089,7 +1086,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
- Display, graphics, effects, audio, controls, interface and network, behind seven buttons across the top. The original screen was one panel with everything on it at once, and it was already full the day it shipped: the language filter, the keyboard button and four camera checkboxes are all still in there, parked off the right edge where nobody can reach them, because there was nowhere left to put them.
- Every setting sits with the ones that do the same kind of job. Display is the screen and its brightness. Graphics is what the picture costs and how sharp it is, with the glow and the lighting in a group of their own instead of mixed in with the anti-aliasing. Effects is what stands in the world: all seven shadow boxes together, cloud shadows included, then the scenery, then smoke. Controls splits the camera, the orders, building placement and the mouse into four groups, and Interface holds the command bar size, the income readout, the health bars, the colours, the order lines and the language. In Classic the screen leaves out the twelve boxes Classic ignores anyway, from zoom to cursor and grid placement to the HUD size and the health bar choice, and closes the gaps they leave, so a box on that screen always does something.
-- Classic Graphics, on the Graphics page, puts the game back the way it looked in 2003 in one click: its own textures and ground in place of the upscaled ones, the old hard shadows, the round dark patch under every tree where Reforged lays the tree's own outline on the ground, no bump detail on the models and no glow or sharpening over the picture. Leave it off and you have Reforged. The rest of the options stay yours either way, and the box takes effect the next time the game starts.
+- Classic Graphics, on the Graphics page, puts the game back the way it looked in 2003 in one click: its own textures and ground in place of the upscaled ones, the old hard shadows, the round dark patch under every tree where Reforged lays the tree's own outline on the ground, and no glow or sharpening over the picture. Leave it off and you have Reforged. The rest of the options stay yours either way, and the box takes effect the next time the game starts.
- Interface, in the launcher, picks between Classic and Reforged. Classic is the command bar, mouse and hotkeys of Zero Hour 1.04 that your hands still remember; Reforged is the console in the middle, right-click orders and the key grid this version built. Every player starts on Classic, and a game started without the launcher is Classic too. The choice is yours alone: two players on different styles still play the same match and the same replay. It takes effect the next time the game starts. Classic's screen is EA's again: the one-piece command bar in each side's own painting, the radar with its flashing under-attack lamp, the beacon button, six lines of messages in the top left that fade as they did, superweapon countdowns written out by name, the old chat line and quit menu, lettering at the old sizes, and Tab opening diplomacy. What it does not do is stretch. On a 16:9 or 21:9 screen the bar, the menus and every dialog sit in a 4:3 frame in the middle at their drawn shape, and the battlefield runs out to both edges past them; at 2560x1080 that is 560 pixels of ground on either side of the bar. The mouse and keys are 1.04's as well. The left button selects and gives the order, so an enemy under it is an attack and a bunker under your infantry is a way in; the right button drops your selection or takes back a half-given order, and a right drag scrolls the map. Ctrl held is force fire. Alt held lays waypoints, and the white path joining them is drawn again. A guard order holds the range it always held, Shift and a number adds that group to what you have selected, and a build button is one unit a click. The keys are your language's own key map from the game's files, with nothing of Reforged's grid laid over it, and a build button's key is the letter 1.04 gave it, taken from the English name in every language, so a Turkish or German player presses the same key an English one does. The letter sits in the button's corner on the dark badge Reforged puts its grid keys on; the tooltip's name is plain white with no letter picked out. A structure is selected on its own, as it always was. The radar shows no money piles or tech buildings, the piles carry no money over them, and the clock plate, the frame counter and the experience bar under the portrait stay off the screen. So does the peace time plate, though a host's truce still holds. The money readout is the money alone, with no income figure beside it. Health bars and garrison squares look and behave as they do in Reforged, and the Health Bars and empty garrison squares settings are back on Classic's options page. The build buttons are the pictures alone, without the seconds, price and power figures. Those seconds were measured against the wall clock, so on a match running just under full speed a 120 second build read 125. An upgrade bought for a group of buildings goes to the one whose buttons you see. In a network game a Classic player's camera is not sent to observers, as it never was in 1.04. The camera zooms on the middle of the screen ten units a notch, as near and as far as Reforged's camera goes, turns without snapping, and scrolls from the last three pixels of a full screen and not at all in a window, whatever the options say. A move order puts 1.04's animated ring on the ground where it lands, and no marker or line stays behind it. None of it reaches the battle itself: Classic sends the game only the orders 1.04 sent, so a Classic player and a Reforged one share a match, and a replay plays back the same in either.
- Every graphics setting is on the Graphics and Effects pages. Shadows, clouds, ground lighting, soft water edges, trees, extra animations, heat haze, texture resolution and the particle limit used to hide in a popup that only opened if you picked Custom from the detail box on another page, so choosing High never showed you what High turns on. Pick a preset now and its settings change in front of you; touch any one of them and the box reads Custom. Texture filtering and the number of anisotropic samples, which needed a text editor, sit there too.
- Every page is sorted into titled groups by what the settings do, and the groups sit in the same three columns on every tab. On Graphics the detail preset heads the first column with the texture and particle sliders under it, the picture settings take the second and the terrain the third. The framed boxes the original drew inside each page are gone. They were sized for headings that no longer exist, which is why no two pages started their first setting at the same height.
@@ -1767,6 +1764,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
- Soldiers used to drop their posed shadow once the camera pulled far enough back to make each man a
few pixels tall. It saved frame time in a big crowd and it made the army look flat at the zoom
most games are played at, so it came out again: every soldier on screen keeps his shadow.
+- The surface relief on models and ground was built, shipped on 2026-09-19, fixed twice and taken out again on 2026-10-06. There was no height in the art to begin with: every bump was guessed from a texture's colours, 5443 of them for the models and the ground's worked out on every map load, so the light could only ever be as right as the guess. The textures at twice their size were the part worth keeping, and they stay.
- The six-rung difficulty ladder is back down to three. The three extra rungs were built, played and taken out again: a player picks a level once and wants to know what it means, and six names that each moved one switch was a worse answer to that than three that each describe an opponent. The machinery underneath is the same, so the levels are still tunable in the data files, and Hard kept the top rung's numbers rather than its old ones.
- The three-piece command bar was reverted once, for having nowhere to put the painting of the bar, and is back now that the painting has been cut into three to match. Each piece is fitted by matching it against the artwork it was cut from rather than by eye: the eyeballed fit was four percent out, which nobody sees on the metal and everybody sees on the money readout.
- Units no longer call their shots. For a while a unit put the shot it was lining up on a shared list, and the rest of its group passed over any enemy that list said was already dead, so a squad would spread its fire instead of emptying it into one tank. In play it cost more than it saved: soldiers held their fire on a target somebody else had called while enemies stood in reach, and each patch for that was one more exception. It is gone, and units pick and fire at their targets the way the 2003 game does. Over five 280-unit clashes, stops of three seconds or more with an enemy in range and no shot came to 33, where the last version of the list left 34 and the one before it 167. Replays recorded with it play out differently.
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/TerrainTex.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/TerrainTex.h
index abb0e3681..8e2e01d25 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/TerrainTex.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/TerrainTex.h
@@ -57,18 +57,11 @@ public:
/// Create texture for a height map.
TerrainTextureClass(int height, int width);
- /// The atlas's shape in a format of the caller's choosing: the normal atlas.
- TerrainTextureClass(int height, WW3DFormat format);
-
// just use default destructor. ~TerrainTextureClass(void);
public:
int update(WorldHeightMap *htMap); ///< Sets the pixels, and returns the actual height of the texture.
- /// The same layout filled with each tile's normals instead of its colours. Needs a 32 bit texture.
- int updateNormals(WorldHeightMap *htMap);
Bool updateFlat(WorldHeightMap *htMap, Int xCell, Int yCell, Int cellWidth, Int pixelsPerCell); ///< Sets the pixels.
void setLOD(Int LOD);
-protected:
- int fill(WorldHeightMap *htMap, Bool normals);
};
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/PosixDevice/Render/SdlConstants.h b/GeneralsMD/Code/GameEngineDevice/Source/PosixDevice/Render/SdlConstants.h
index bf5dda8f9..f96fe2483 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/PosixDevice/Render/SdlConstants.h
+++ b/GeneralsMD/Code/GameEngineDevice/Source/PosixDevice/Render/SdlConstants.h
@@ -63,8 +63,9 @@ struct SdlPixelConstants
/// What an engine pixel program's b0 declares (A3e, engineshader.cpp's write_pixel_preamble): the Direct3D
/// 11 backend's PixelConstantBlock, field for field. The first three are SdlPixelConstants; the rest -
-/// the normal mapped lights, the terrain's sun, the shadow and the sky - serve the bumped terrain and
-/// the fork's Direct3D 11 additions, which A3e does not draw, and stay zero: zero shadow parameters
+/// the normal mapped lights, the terrain's sun, the shadow and the sky - are unread padding from the
+/// normal maps taken out on 2026-10-06 and the fork's Direct3D 11 additions, which A3e does not
+/// draw, and stay zero: zero shadow parameters
/// read as a pixel the sun reaches.
struct SdlEnginePixelConstants
{
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/PosixDevice/Render/SdlProgramCache.cpp b/GeneralsMD/Code/GameEngineDevice/Source/PosixDevice/Render/SdlProgramCache.cpp
index ac8100581..1a08bd6e6 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/PosixDevice/Render/SdlProgramCache.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/PosixDevice/Render/SdlProgramCache.cpp
@@ -258,7 +258,7 @@ const SdlProgram &SdlProgramCache::Engine_Pixel_Program(int program, const Pixel
return existing->second;
}
std::string hlsl;
- const bool written = EngineShader_Pixel_Program(engine, pipeline, hlsl, false, COMBINER_SHADER_TARGET_SDL3_GPU);
+ const bool written = EngineShader_Pixel_Program(engine, pipeline, hlsl, COMBINER_SHADER_TARGET_SDL3_GPU);
const SdlProgram &made = Make(PixelPrograms, key, written, hlsl, false);
EnginePixelByBytes.Add(&lookup, sizeof(lookup), &PixelPrograms[key]);
return made;
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp
index d453f7c05..b0a22a1c4 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp
@@ -90,66 +90,14 @@ TerrainTextureClass::TerrainTextureClass(int height, int width) :
{
}
-TerrainTextureClass::TerrainTextureClass(int height, WW3DFormat format) :
- TextureClass(TEXTURE_WIDTH, height, format, MIP_LEVELS_3 )
-{
-}
-
-int TerrainTextureClass::update(WorldHeightMap *htMap)
-{
- return fill(htMap, false);
-}
-
-int TerrainTextureClass::updateNormals(WorldHeightMap *htMap)
-{
- return fill(htMap, true);
-}
-
-// How steep the ground's own detail is made: a brightness step of one across a pixel tilts the
-// normal by this much. Chosen by eye on the desert and grass tiles; the backend's
-// NORMAL_MAP_STRENGTH scales it again at draw time.
-static const Real TERRAIN_BUMP_DEPTH = 6.0f;
-
-/** One tile's normals, stored the way the tile's own data is (bottom row first), which is what
- fill turns the right way up. Brightness stands in for height, so every grain, crack and pebble
- gets a slope and a flat patch of paint stays flat. Rows here run against v in the atlas, hence
- the sign on the green channel. It wraps at the tile's own edge: right for a class of one tile,
- a faint seam between the tiles of a bigger one. */
-static void terrainTileNormals(const UnsignedByte *tileBGRA, Int extent, UnsignedByte *normalsBGRA)
-{
- static Real height[MAX_TILE_PIXEL_EXTENT*MAX_TILE_PIXEL_EXTENT];
- for (Int pixel = 0; pixel < extent*extent; ++pixel) {
- const UnsignedByte *source = tileBGRA + pixel*TILE_BYTES_PER_PIXEL;
- height[pixel] = (0.114f*source[0] + 0.587f*source[1] + 0.299f*source[2]) / 255.0f;
- }
- for (Int row = 0; row < extent; ++row) {
- for (Int column = 0; column < extent; ++column) {
- const Int left = row*extent + (column + extent - 1) % extent;
- const Int right = row*extent + (column + 1) % extent;
- const Int below = ((row + extent - 1) % extent)*extent + column;
- const Int above = ((row + 1) % extent)*extent + column;
- const Real slopeU = (height[right] - height[left]) * 0.5f * TERRAIN_BUMP_DEPTH;
- // The row above in the tile is the row before in the atlas, so v grows downwards here.
- const Real slopeV = (height[below] - height[above]) * 0.5f * TERRAIN_BUMP_DEPTH;
- const Real length = sqrtf(slopeU*slopeU + slopeV*slopeV + 1.0f);
- UnsignedByte *target = normalsBGRA + (row*extent + column)*TILE_BYTES_PER_PIXEL;
- target[0] = (UnsignedByte)((1.0f/length*0.5f + 0.5f)*255.0f + 0.5f); // z in blue
- target[1] = (UnsignedByte)((-slopeV/length*0.5f + 0.5f)*255.0f + 0.5f); // y in green
- target[2] = (UnsignedByte)((-slopeU/length*0.5f + 0.5f)*255.0f + 0.5f); // x in red
- target[3] = 0xff;
- }
- }
-}
-
//=============================================================================
-// TerrainTextureClass::fill
+// TerrainTextureClass::update
//=============================================================================
/** Sets the tile bitmap data into the texture. The tiles are placed with 4
pixel borders around them, so that when the tiles are scaled and bilinearly
- interpolated, you don't get seams between the tiles. With normals, each
- tile's normals go where its colours would, into a 32 bit texture. */
+ interpolated, you don't get seams between the tiles. */
//=============================================================================
-int TerrainTextureClass::fill(WorldHeightMap *htMap, Bool normals)
+int TerrainTextureClass::update(WorldHeightMap *htMap)
{
// D3DTexture is our texture;
@@ -197,13 +145,9 @@ int TerrainTextureClass::fill(WorldHeightMap *htMap, Bool normals)
ICoord2D position = pTile->m_tileLocationInTexture;
if (position.x<=0) continue; // all real tile offsets start at 2. jba.
- static UnsignedByte tileNormals[DATA_LEN_BYTES];
- if (normals) {
- terrainTileNormals(pTile->getRGBDataForWidth(tilePixelExtent), tilePixelExtent, tileNormals);
- }
Int i,j;
for (j=0; j<tilePixelExtent; j++) {
- UnsignedByte *pBGR = normals ? tileNormals : pTile->getRGBDataForWidth(tilePixelExtent);
+ UnsignedByte *pBGR = pTile->getRGBDataForWidth(tilePixelExtent);
pBGR += (tilePixelExtent-1-j)*TILE_BYTES_PER_PIXEL*tilePixelExtent; // invert to match.
Int row = position.y+j;
UnsignedByte *pBGRX = ((UnsignedByte*)locked_rect.pBits) +
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
index 15b669674..6721b4b04 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
@@ -518,11 +518,6 @@ W3DDisplay::~W3DDisplay()
// Same reason as above: WW3D2 has no logging in a shipping build, and a -dx11 run that made no
// device at all would otherwise look exactly like one that made a device nothing drew through.
- if( Direct3D11_Normal_Maps_Active() )
- {
- DEBUG_LOG(("NORMALMAPS: %I64u draws lit per pixel\n", Direct3D11_Normal_Mapped_Draws()));
- }
-
if( Direct3D11_Is_Enabled() )
{
unsigned pipelines = 0;
@@ -1140,10 +1135,8 @@ void W3DDisplay::init( void )
// next to its exe, and the shipped programs there are read-only anyway.
Direct3D11_Set_Shader_Cache_Directory( TheGlobalData->getPath_UserData().str() );
pushDirect3D11PostChain();
- // Classic graphics is read here once and not again: a texture that has looked for its normal
- // map keeps the answer, and a tile size cannot change under a loaded map. The menu says the
- // setting waits for the next launch.
- Direct3D11_Normal_Maps_Enable( !TheGlobalData->m_classicGraphics );
+ // Classic graphics is read here once and not again: a tile size cannot change under a loaded
+ // map. The menu says the setting waits for the next launch.
// Before any map is read: every tile and the atlas are sized by it. A headless run draws no
// ground, so it keeps EA's tile and the memory, and classic graphics keeps EA's tile to look it.
TheTilePixelExtent = (TheGlobalData->m_headless || TheGlobalData->m_classicGraphics)
@@ -2576,11 +2569,6 @@ AGAIN:
{
USE_PERF_TIMER(BigAssRenderLoop)
static Bool couldRender = true;
- // The bumped ground is shaded against the first terrain light, the one its
- // vertex colours were lit by. A script can change the time of day, so every frame.
- const Coord3D &sun = TheGlobalData->m_terrainLightPos[0];
- const float sunDirection[3] = { sun.x, sun.y, sun.z };
- Direct3D11_Set_Terrain_Sun( sunDirection );
if ((TheGlobalData->m_breakTheMovie == FALSE) && (TheGlobalData->m_disableRender == false) && WW3D::Begin_Render( true, true, Vector3( 0.0f, 0.0f, 0.0f ), TheWaterTransparency->m_minWaterOpacity ) == WW3D_ERROR_OK)
{
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp
index c2d5b60ed..ea9513b0a 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp
@@ -2266,13 +2266,6 @@ Int TerrainShaderPixelShader::set(Int pass)
//setup base pass
DX8Wrapper::Set_DX8_Texture(0, W3DShaderManager::getShaderTexture(0)->Peek_D3D_Texture());
DX8Wrapper::Set_DX8_Texture(1, W3DShaderManager::getShaderTexture(1)->Peek_D3D_Texture());
- // The atlas is bound here straight to the device, past TextureClass::Apply, so its
- // normal atlas has to be handed over here too.
- if (Direct3D11_Normal_Maps_Active())
- {
- TextureClass *normalAtlas = W3DShaderManager::getShaderTexture(0)->Peek_Normal_Map();
- Direct3D11_Mirror_Normal_Map(normalAtlas != NULL ? normalAtlas->Peek_D3D_Base_Texture() : NULL);
- }
DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
index 017e25515..31045f803 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
@@ -54,7 +54,6 @@
#include "W3DDevice/GameClient/HeightMap.h"
#include "W3DDevice/GameClient/TerrainTex.h"
#include "W3DDevice/GameClient/W3DShadow.h"
-#include "dx11runtime.h"
#include "Common/file.h"
@@ -1593,15 +1592,6 @@ TextureClass *WorldHeightMap::getTerrainTexture(void)
m_terrainTex = MSGNEW("WorldHeightMap_getTerrainTexture") TerrainTextureClass(pow2Height);
m_terrainTexHeight = m_terrainTex->update(this);
m_extraBlendUVGeneration++; // the tiles just moved in the texture, and its height may have changed
- if (Direct3D11_Normal_Maps_Active()) {
- // The ground's normals, laid out exactly as its colours, so the pixel program
- // reads both at the same coordinate. Built from the tiles every load; nothing ships one.
- TerrainTextureClass *normalTex = MSGNEW("WorldHeightMap_getTerrainTexture")
- TerrainTextureClass(pow2Height, WW3D_FORMAT_A8R8G8B8);
- normalTex->updateNormals(this);
- m_terrainTex->Set_Normal_Map(normalTex);
- REF_PTR_RELEASE(normalTex);
- }
char buf[64];
sprintf(buf, "Base tex height %d\n", pow2Height);
DEBUG_LOG((buf));
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
index 40c09a05c..b84db977d 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
@@ -39,22 +39,6 @@ static const char * const ENTRY_POINT = "main";
static const char * const VERTEX_PROFILE = "vs_4_0";
static const char * const PIXEL_PROFILE = "ps_4_0";
-// How far a normal map tilts the normal (1 is as the map is written), the exponent of the
-// highlight it adds, and how bright that highlight is where the map's alpha is one. Picked by eye
-// on four tanks and a desert base.
-static const float NORMAL_MAP_STRENGTH = 1.0f;
-// The power was 24, which is a lobe narrow enough that a top-down camera over a fixed sun almost
-// never catches it: the gloss map decided what could shine and then nothing did. Ten is wide
-// enough to catch a hull at the angles this game is actually played at.
-static const float NORMAL_MAP_HIGHLIGHT_POWER = 10.0f;
-static const float NORMAL_MAP_HIGHLIGHT_SCALE = 0.9f;
-
-// How much of the sky a metal surface returns, and how dark the horizon is against straight up.
-// The sun's own dot on a hull is one small spot; the flank of a tank reads as metal because of what
-// it mirrors over its whole area, and from this camera that is nearly all sky.
-static const float SKY_REFLECTION_STRENGTH = 0.35f;
-static const float SKY_HORIZON_SHARE = 0.45f;
-
// The three stage counts are one count in three headers. The vertex constant block is copied
// wholesale out of the backend's own texture transforms, the generated pixel shader declares one
// sampler per texture the backend binds, and a mismatch is a silent overrun rather than a build
@@ -242,7 +226,6 @@ DX11BackendClass::DX11BackendClass()
, CurrentTargetResource(NULL)
, TargetCopy(NULL)
, TargetCopyView(NULL)
- , NormalMap(NULL)
, ShadowMapSurface(NULL)
, ShadowMapDepth(NULL)
, ShadowMapTexture(NULL)
@@ -261,7 +244,6 @@ DX11BackendClass::DX11BackendClass()
, ShadowSkyFill(0.0f)
, ShadowReceiving(false)
, SmokeGlow(false)
- , NormalMappedDraws(0)
, DrawsMade(0)
, DrawsRefused(0)
, RefusedNoBuffer(0)
@@ -299,7 +281,6 @@ DX11BackendClass::DX11BackendClass()
memset(EngineConstants, 0, sizeof(EngineConstants));
memset(MissingTexture, 0, sizeof(MissingTexture));
memset(Lights, 0, sizeof(Lights));
- memset(TerrainSun, 0, sizeof(TerrainSun));
memset(MaterialAmbient, 0, sizeof(MaterialAmbient));
memset(MaterialDiffuse, 0, sizeof(MaterialDiffuse));
memset(MaterialSpecular, 0, sizeof(MaterialSpecular));
@@ -1153,38 +1134,6 @@ void DX11BackendClass::Set_Texture(unsigned stage, ID3D11ShaderResourceView * te
}
}
-void DX11BackendClass::Set_Normal_Map(ID3D11ShaderResourceView * normal_map)
-{
- if ((NormalMap == NULL) != (normal_map == NULL)) {
- PipelineChanged = true;
- }
- NormalMap = normal_map;
-}
-
-// The pixel half bumps the directional lights; a point or spot light is summed per vertex into the
-// base it adds to (ffvertex.cpp). It used to turn the whole draw back to per-vertex lighting, so a
-// tank lost its relief every time its own gun flashed, and anything next to an explosion or a fire
-// went flat with it. A transcribed program is its own lighting.
-bool DX11BackendClass::Normal_Mapped() const
-{
- return NormalMap != NULL && Textures[0] != NULL
- && VertexProgram == ENGINE_SHADER_NONE && PixelProgram == ENGINE_SHADER_NONE
- && RenderStates.Get_Render_State(D3DRS_LIGHTING) != FALSE
- && (VertexFormat & D3DFVF_NORMAL) != 0;
-}
-
-bool DX11BackendClass::Terrain_Bumped() const
-{
- return NormalMap != NULL && Textures[0] != NULL && VertexProgram == ENGINE_SHADER_NONE
- && EngineShader_Can_Bump(PixelProgram) && (VertexFormat & D3DFVF_XYZRHW) == 0;
-}
-
-void DX11BackendClass::Set_Terrain_Sun(const float direction[3])
-{
- memcpy(TerrainSun, direction, sizeof(TerrainSun));
- ConstantsChanged = true;
-}
-
void DX11BackendClass::Set_Headlights(const float * lights, unsigned count, const float gain[3])
{
if (count > HEADLIGHT_SLOTS) {
@@ -1738,7 +1687,6 @@ bool DX11BackendClass::Build_Combiner_Description(CombinerDescription & descript
target.TextureBound = Textures[stage] != NULL;
description.StageCount = stage + 1;
}
- description.NormalMapped = description.StageCount > 0 && Normal_Mapped();
description.ShadowReceiving = description.StageCount > 0 && Shadow_Receiving();
description.SmokeGlow = Smoke_Glow();
return description.StageCount > 0;
@@ -1821,8 +1769,6 @@ bool DX11BackendClass::Build_Vertex_Description(VertexPipelineDescription & desc
description.FogEnabled = RenderStates.Get_Render_State(D3DRS_FOGENABLE) != FALSE;
description.FogVertexMode = RenderStates.Get_Render_State(D3DRS_FOGVERTEXMODE);
- description.NormalMapped = (Normal_Mapped()
- && StageStates[0][D3DTSS_COLOROP] != D3DTOP_DISABLE) || Terrain_Bumped();
description.SmokeGlow = Smoke_Glow();
return true;
}
@@ -1901,11 +1847,9 @@ bool DX11BackendClass::Resolve(Pipeline & pipeline)
const std::string vertex_key = (VertexProgram != ENGINE_SHADER_NONE)
? std::string(EngineShader_Name(VertexProgram))
: VertexShader_Key(vertex_description);
- const bool terrain_bumped = vertex_description.NormalMapped && PixelProgram != ENGINE_SHADER_NONE;
const std::string pixel_key = (PixelProgram != ENGINE_SHADER_NONE)
? EngineShader_Name(PixelProgram)
+ CombinerShader_Pipeline_Key(combiner_description.PixelPipeline)
- + (terrain_bumped ? ":N" : "")
: CombinerShader_Key(combiner_description);
const std::string key = vertex_key + pixel_key + format;
@@ -1941,8 +1885,7 @@ bool DX11BackendClass::Resolve(Pipeline & pipeline)
return false;
}
const bool wrote_pixel = (PixelProgram != ENGINE_SHADER_NONE)
- ? EngineShader_Pixel_Program(PixelProgram, combiner_description.PixelPipeline, pixel_hlsl,
- terrain_bumped)
+ ? EngineShader_Pixel_Program(PixelProgram, combiner_description.PixelPipeline, pixel_hlsl)
: CombinerShader_Generate(combiner_description, COMBINER_SHADER_TARGET_D3D11, pixel_hlsl);
if (!wrote_pixel) {
Note_Refusal("the pixel half would not generate this description");
@@ -2215,45 +2158,6 @@ void DX11BackendClass::Upload_Pixel_Constants()
pixel_block.AlphaReference[0] =
static_cast<float>(RenderStates.Get_Render_State(D3DRS_ALPHAREF) & 0xff);
- // The normal mapped program's lights, the enabled directional ones first and in camera space
- // like the vertex block's; a point or spot light is already in the vertex colour it adds to. A
- // slot with no light gets a direction anyway: the highlight normalises the half vector, and a
- // zero direction there is a NaN that no zero colour cancels.
- unsigned normal_slot = 0;
- for (unsigned index = 0; index < MAXIMUM_VERTEX_LIGHTS && normal_slot < NORMAL_MAPPED_LIGHTS;
- ++index) {
- if (!Lights[index].Enabled || Lights[index].Type != D3DLIGHT_DIRECTIONAL) {
- continue;
- }
- float * direction = pixel_block.NormalLightDirection[normal_slot];
- transform_direction(Lights[index].Direction, View, direction);
- const float length = sqrtf(direction[0] * direction[0] + direction[1] * direction[1]
- + direction[2] * direction[2]);
- if (length > 0.0f) {
- direction[0] /= length;
- direction[1] /= length;
- direction[2] /= length;
- }
- memcpy(pixel_block.NormalLightDiffuse[normal_slot], Lights[index].Diffuse, sizeof(float) * 4);
- ++normal_slot;
- }
- for (; normal_slot < NORMAL_MAPPED_LIGHTS; ++normal_slot) {
- pixel_block.NormalLightDirection[normal_slot][2] = 1.0f;
- }
- pixel_block.NormalMapParameters[0] = NORMAL_MAP_STRENGTH;
- pixel_block.NormalMapParameters[1] = NORMAL_MAP_HIGHLIGHT_POWER;
- pixel_block.NormalMapParameters[2] = NORMAL_MAP_HIGHLIGHT_SCALE;
- const float sun[4] = { TerrainSun[0], TerrainSun[1], TerrainSun[2], 0.0f };
- transform_direction(sun, View, pixel_block.TerrainSunDirection);
- const float sun_length = sqrtf(pixel_block.TerrainSunDirection[0] * pixel_block.TerrainSunDirection[0]
- + pixel_block.TerrainSunDirection[1] * pixel_block.TerrainSunDirection[1]
- + pixel_block.TerrainSunDirection[2] * pixel_block.TerrainSunDirection[2]);
- if (sun_length > 0.0f) {
- for (unsigned axis = 0; axis < 3; ++axis) {
- pixel_block.TerrainSunDirection[axis] /= sun_length;
- }
- }
-
// A camera space draw's pixels go back to the world through the scene camera's view, not through
// the identity it was drawn with; see Set_Scene_View in the header.
const bool camera_space = Camera_Space_Draw();
@@ -2301,25 +2205,6 @@ void DX11BackendClass::Upload_Pixel_Constants()
}
}
- /* The sky a metal surface mirrors. There is no cubemap: the colour is the map's own sunlight,
- which is what makes a night map's metal cold and a desert's warm without anything being
- authored, and the direction it is brightest in is straight up in camera space. */
- const float * sun_colour = Lights[0].Enabled ? Lights[0].Diffuse : NULL;
- for (unsigned channel = 0; channel < 3; ++channel) {
- pixel_block.Sky[channel] = (sun_colour != NULL) ? sun_colour[channel] : 1.0f;
- }
- pixel_block.Sky[3] = SKY_REFLECTION_STRENGTH;
- const float world_up[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
- transform_direction(world_up, View, pixel_block.SkyUp);
- const float up_length = sqrtf(pixel_block.SkyUp[0] * pixel_block.SkyUp[0]
- + pixel_block.SkyUp[1] * pixel_block.SkyUp[1] + pixel_block.SkyUp[2] * pixel_block.SkyUp[2]);
- if (up_length > 0.0f) {
- for (unsigned axis = 0; axis < 3; ++axis) {
- pixel_block.SkyUp[axis] /= up_length;
- }
- }
- pixel_block.SkyUp[3] = SKY_HORIZON_SHARE;
-
if (!PixelConstantsHeld
|| memcmp(&HeldPixelConstants, &pixel_block, sizeof(pixel_block)) != 0) {
PixelConstantsHeld = false;
@@ -2538,11 +2423,6 @@ void DX11BackendClass::Bind_State_Objects()
memcpy(Bound.Textures, textures, sizeof(textures));
}
}
- // Left bound when the draw does not read it, since only a normal mapped program declares t4.
- if (NormalMap != NULL && (!known || NormalMap != Bound.NormalMap)) {
- context->PSSetShaderResources(DX11_BACKEND_TEXTURE_STAGES, 1, &NormalMap);
- Bound.NormalMap = NormalMap;
- }
// The sun's map at t5 with a sampler of its own at s5, clamped so a pixel past the edge of the
// box reads the edge rather than wrapping the far side of the map over it.
@@ -2717,9 +2597,6 @@ bool DX11BackendClass::Draw_Indexed(unsigned index_count, unsigned start_index,
context->DrawIndexed(index_count, start_index, base_vertex);
++DrawsMade;
- if (Normal_Mapped() || Terrain_Bumped()) {
- ++NormalMappedDraws;
- }
if (CurrentTarget != NULL) {
++DrawsIntoTargets;
MaskWhileTargeted |= RenderStates.Get_Render_State(D3DRS_COLORWRITEENABLE);
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h
index 78da50c83..7cc1cedf9 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h
@@ -88,16 +88,6 @@ public:
void Set_Sampler_State(unsigned sampler, D3DSAMPLERSTATETYPE state, DWORD value);
void Set_Texture(unsigned stage, ID3D11ShaderResourceView * texture);
- // The normal map that goes with the texture at stage zero, or null when it has none. A lit
- // draw with directional lights only is then lit per pixel through it, and so is the terrain;
- // every other draw ignores it.
- void Set_Normal_Map(ID3D11ShaderResourceView * normal_map);
- unsigned long long Normal_Mapped_Draw_Count() const { return NormalMappedDraws; }
-
- // The way the sun's light travels, in world space: the terrain has no D3D light of its own, its
- // light is baked into the vertices, so its bump is shaded against this.
- void Set_Terrain_Sun(const float direction[3]);
-
// The vehicle headlights for the frame, eight floats a light: world position, reach, world
// direction, cosine of the cone's edge. Past HEADLIGHT_SLOTS the rest are dropped; the caller
// sorts them nearest first. Zero lights leaves every program's pixels as they were. The gain
@@ -316,8 +306,11 @@ private:
float LightFields[MAXIMUM_VERTEX_LIGHTS][VERTEX_REGISTERS_PER_LIGHT][4];
};
- // The normal map fields go last: a program that is not normal mapped declares the first three
- // and nothing else, which a larger buffer serves.
+ // A program that receives no shadow declares the first three fields and nothing else, which a
+ // larger buffer serves. The four after AlphaReference, and Sky and SkyUp, belonged to the normal
+ // maps taken out on 2026-10-06; nothing reads them and nothing writes them, but the generated
+ // programs still declare them, and every field behind them is found by its offset. They stay
+ // until the generators and the cached programs move together.
struct PixelConstantBlock
{
float TextureFactor[4];
@@ -353,10 +346,6 @@ private:
float HeadlightPosition[HEADLIGHT_SLOTS][4];
float HeadlightDirection[HEADLIGHT_SLOTS][4];
};
- // A model under directional lights, drawn by generated programs.
- bool Normal_Mapped() const;
- // The ground, drawn by one of the transcribed terrain programs with its light baked in.
- bool Terrain_Bumped() const;
// A draw that is painting the world and can take a shadow from the sun's map.
bool Shadow_Receiving() const;
@@ -388,9 +377,6 @@ private:
DX11SamplerBlockClass Samplers[DX11_BACKEND_TEXTURE_STAGES];
DWORD StageStates[DX11_BACKEND_TEXTURE_STAGES][DX11_BACKEND_STAGE_STATES];
ID3D11ShaderResourceView * Textures[DX11_BACKEND_TEXTURE_STAGES];
- ID3D11ShaderResourceView * NormalMap;
- unsigned long long NormalMappedDraws;
- float TerrainSun[3];
DWORD VertexFormat;
ID3D11Buffer * StreamBuffer;
@@ -742,7 +728,6 @@ private:
ID3D11RasterizerState * Rasterizer;
ID3D11SamplerState * Samplers[DX11_BACKEND_TEXTURE_STAGES];
ID3D11ShaderResourceView * Textures[DX11_BACKEND_TEXTURE_STAGES];
- ID3D11ShaderResourceView * NormalMap;
// The sun's map and the smoke's at t5 and t6, and their samplers as last passed: the
// second sampler is null when only the first was set.
ID3D11ShaderResourceView * Maps[2];
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp
index ab077b8b5..149d49b2d 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp
@@ -35,7 +35,6 @@ static HRESULT PresentFailure = S_OK;
static bool PresentFailureReported = false;
static bool VSyncRequested = false;
static bool Active = false;
-static bool NormalMapsEnabled = true;
static DX11DeviceClass Device;
static DX11BackendClass Backend;
static DX11PostProcessClass Post;
@@ -255,39 +254,6 @@ void Direct3D11_Mirror_Texture(unsigned stage, struct IDirect3DBaseTexture9 * te
: DX11Texture_Mirror(Device.Get_Device(), Device.Get_Context(), texture);
Backend.Set_Texture(stage, view);
Backend.Set_Texture_Missing(stage, texture != NULL && view == NULL);
-
- // A new texture at stage zero drops the old one's normal map. TextureClass::Apply hands over
- // the new one's right after this, and a texture bound any other way has none.
- if (stage == 0) {
- Backend.Set_Normal_Map(NULL);
- }
-}
-
-void Direct3D11_Normal_Maps_Enable(bool enabled)
-{
- NormalMapsEnabled = enabled;
-}
-
-bool Direct3D11_Normal_Maps_Active()
-{
- return Active && NormalMapsEnabled;
-}
-
-void Direct3D11_Mirror_Normal_Map(struct IDirect3DBaseTexture9 * normal_map)
-{
- if (!Active) {
- return;
- }
- Backend.Set_Normal_Map(normal_map == NULL
- ? NULL
- : DX11Texture_Mirror(Device.Get_Device(), Device.Get_Context(), normal_map));
-}
-
-void Direct3D11_Set_Terrain_Sun(const float direction[3])
-{
- if (Active) {
- Backend.Set_Terrain_Sun(direction);
- }
}
void Direct3D11_Set_Headlights(const float * lights, unsigned count, const float gain[3])
@@ -297,11 +263,6 @@ void Direct3D11_Set_Headlights(const float * lights, unsigned count, const float
}
}
-unsigned long long Direct3D11_Normal_Mapped_Draws()
-{
- return Active ? Backend.Normal_Mapped_Draw_Count() : 0;
-}
-
bool Direct3D11_Begin_Shadow_Map(unsigned size)
{
return Active ? Backend.Begin_Shadow_Map(size) : false;
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h
index 42790b3dd..e61da0735 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h
@@ -110,21 +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);
-// Normal maps: TextureClass looks for a "<name>_nrm.dds" beside every texture it binds at stage
-// zero and hands it over here, null when there is none; the terrain builds its own. Active is
-// false on a Direct3D 9 run, which has no pixel half to light with, and after the classic graphics
-// setting turned them off, which it does once, before the first texture is bound.
-void Direct3D11_Normal_Maps_Enable(bool enabled);
-bool Direct3D11_Normal_Maps_Active();
-void Direct3D11_Mirror_Normal_Map(struct IDirect3DBaseTexture9 * normal_map);
-
-// The way the sun's light travels, world space, for the bumped terrain. Set once a frame.
-void Direct3D11_Set_Terrain_Sun(const float direction[3]);
// 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.
void Direct3D11_Set_Headlights(const float * lights, unsigned count, const float gain[3]);
-unsigned long long Direct3D11_Normal_Mapped_Draws();
// The sun's depth buffer. Between Begin and End every draw lands in it and nowhere else, which is
// how the caster pass is written without the engine knowing what a render target is. False from
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp
index 44659a8a4..1a03edec4 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp
@@ -59,12 +59,7 @@ DX11BufferTwinClass * Direct3D11_Twin_Vertex_Buffer(unsigned, bool) { return NUL
DX11BufferTwinClass * Direct3D11_Twin_Index_Buffer(unsigned, bool) { return NULL; }
void Direct3D11_Mirror_Texture(unsigned, struct IDirect3DBaseTexture9 *) {}
-void Direct3D11_Normal_Maps_Enable(bool) {}
-bool Direct3D11_Normal_Maps_Active() { return false; }
-void Direct3D11_Mirror_Normal_Map(struct IDirect3DBaseTexture9 *) {}
-void Direct3D11_Set_Terrain_Sun(const float [3]) {}
void Direct3D11_Set_Headlights(const float *, unsigned, const float [3]) {}
-unsigned long long Direct3D11_Normal_Mapped_Draws() { return 0; }
bool Direct3D11_Begin_Shadow_Map(unsigned) { return false; }
void Direct3D11_End_Shadow_Map() {}
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp
index 1c70c3a98..9de0478f1 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp
@@ -204,32 +204,7 @@ 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.
-// The bumped terrain's own light: the share of it that does not depend on which way the ground
-// faces. Without one the ratio below divides by nearly nothing on ground turned from the sun.
-static const char * const TERRAIN_BUMP_AMBIENT = "0.4";
-
-// A tangent space normal from the atlas, put into camera space on the frame the coordinate set
-// actually has at this pixel: tangent where u grows, bitangent where v grows. The same
-// construction ffshader uses for models, as a function because the terrain has two layers.
-static const char * const TERRAIN_BUMP_FUNCTION =
- "float3 bumped_normal(float3 position, float3 surface, float2 coordinate, float3 texel)\n"
- "{\n"
- " float3 position_dx = ddx(position);\n"
- " float3 position_dy = ddy(position);\n"
- " float2 coordinate_dx = ddx(coordinate);\n"
- " float2 coordinate_dy = ddy(coordinate);\n"
- " float3 across_dy = cross(position_dy, surface);\n"
- " float3 across_dx = cross(surface, position_dx);\n"
- " float3 tangent = across_dy * coordinate_dx.x + across_dx * coordinate_dy.x;\n"
- " float3 bitangent = across_dy * coordinate_dx.y + across_dx * coordinate_dy.y;\n"
- " float frame_scale = rsqrt(max(max(dot(tangent, tangent), dot(bitangent, bitangent)), 1e-20));\n"
- " float3 bump = texel * 2.0 - 1.0;\n"
- " bump.xy *= NormalMapParameters.x;\n"
- " return normalize((tangent * bump.x + bitangent * bump.y) * frame_scale + surface * bump.z);\n"
- "}\n"
- "\n";
-
-static void write_pixel_preamble(std::string & hlsl, bool bumped = false, bool volumetric = false)
+static void write_pixel_preamble(std::string & hlsl, bool volumetric = false)
{
for (unsigned stage = 0; stage < MAXIMUM_COMBINER_STAGES; ++stage) {
char line[128];
@@ -272,9 +247,6 @@ static void write_pixel_preamble(std::string & hlsl, bool bumped = false, bool v
hlsl += VOLUMETRIC_CONSTANTS;
}
hlsl += "};\n";
- if (bumped) {
- hlsl += "Texture2D NormalMap : register(t4);\n";
- }
hlsl += SHADOW_SAMPLING;
if (volumetric) {
hlsl += VOLUMETRIC_SAMPLING;
@@ -294,15 +266,9 @@ static void write_pixel_preamble(std::string & hlsl, bool bumped = false, bool v
}
hlsl += " float Fog : FOG;\n";
- if (bumped) {
- hlsl += NORMAL_MAPPED_VARYINGS;
- }
hlsl +=
"};\n"
"\n";
- if (bumped) {
- hlsl += TERRAIN_BUMP_FUNCTION;
- }
hlsl +=
"float4 main(Input input) : SV_Target\n"
"{\n";
@@ -425,9 +391,9 @@ static void write_monochrome(std::string & hlsl)
// matters is the one at the top, and it applies at every step, not only the last: a chain that
// overflows in the middle and comes back down is a different colour with the clamps than without them.
static void write_multiply_chain(std::string & hlsl, const EngineShaderEntry & entry,
- bool bumped, bool volumetric)
+ bool volumetric)
{
- write_pixel_preamble(hlsl, bumped, volumetric);
+ write_pixel_preamble(hlsl, volumetric);
hlsl += " float4 current = saturate(";
hlsl += entry.Opening;
@@ -441,30 +407,6 @@ static void write_multiply_chain(std::string & hlsl, const EngineShaderEntry & e
// The ground is where a shadow is read, so every transcribed program that paints it takes one.
hlsl += volumetric ? VOLUMETRIC_SHADOW_APPLY : SHADOW_APPLY;
-
- if (!bumped) {
- return;
- }
-
- // The vertex colour already carries the light the ground's own slope gets, so the bump is a
- // ratio on top of it: how much more or less the bumped surface faces the sun than the flat one
- // the triangle is. The two layers blend by the same alpha the colours do.
- char line[1024];
- snprintf(line, sizeof(line),
- " float3 flat_normal = normalize(cross(ddx(input.ViewPosition), ddy(input.ViewPosition)));\n"
- " if (dot(flat_normal, input.ViewPosition) > 0.0) { flat_normal = -flat_normal; }\n"
- " float3 to_sun = -TerrainSunDirection.xyz;\n"
- " float3 near_layer = bumped_normal(input.ViewPosition, flat_normal, input.TexCoord0,"
- " NormalMap.Sample(Sampler0, input.TexCoord0).xyz);\n"
- " float3 far_layer = bumped_normal(input.ViewPosition, flat_normal, input.TexCoord1,"
- " NormalMap.Sample(Sampler1, input.TexCoord1).xyz);\n"
- " float3 surface = normalize(lerp(near_layer, far_layer, input.Diffuse.a));\n"
- " float flat_light = %s + (1.0 - %s) * saturate(dot(flat_normal, to_sun));\n"
- " float bumped_light = %s + (1.0 - %s) * saturate(dot(surface, to_sun));\n"
- " float shade = bumped_light / flat_light;\n"
- " current.rgb = saturate(current.rgb * shade);\n",
- TERRAIN_BUMP_AMBIENT, TERRAIN_BUMP_AMBIENT, TERRAIN_BUMP_AMBIENT, TERRAIN_BUMP_AMBIENT);
- hlsl += line;
}
bool EngineShader_Paints_Ground(EngineShaderProgram program)
@@ -475,12 +417,6 @@ bool EngineShader_Paints_Ground(EngineShaderProgram program)
|| program == ENGINE_SHADER_FLAT_TERRAIN_NOISE_2 || program == ENGINE_SHADER_ROAD_NOISE_2;
}
-bool EngineShader_Can_Bump(EngineShaderProgram program)
-{
- return program == ENGINE_SHADER_TERRAIN || program == ENGINE_SHADER_TERRAIN_NOISE
- || program == ENGINE_SHADER_TERRAIN_NOISE_2;
-}
-
static char lowered(char character)
{
return (character >= 'A' && character <= 'Z') ? (char)(character - 'A' + 'a') : character;
@@ -540,11 +476,10 @@ bool EngineShader_Vertex_Program(EngineShaderProgram program, std::string & hlsl
}
static bool write_engine_pixel_program(EngineShaderProgram program,
- const PixelPipelineDescription & pipeline, std::string & hlsl, bool bumped, bool volumetric);
+ const PixelPipelineDescription & pipeline, std::string & hlsl, bool volumetric);
bool EngineShader_Pixel_Program(EngineShaderProgram program,
- const PixelPipelineDescription & pipeline, std::string & hlsl, bool bumped,
- CombinerShaderTarget target)
+ const PixelPipelineDescription & pipeline, std::string & hlsl, CombinerShaderTarget target)
{
// As the vertex half: D3D11 only, and SDL3 GPU as the D3D11 text rebound, without the smoke the
// SDL3 backend has no map for.
@@ -553,23 +488,20 @@ bool EngineShader_Pixel_Program(EngineShaderProgram program,
return false;
}
if (target == COMBINER_SHADER_TARGET_SDL3_GPU) {
- return write_engine_pixel_program(program, pipeline, hlsl, bumped, false)
+ return write_engine_pixel_program(program, pipeline, hlsl, false)
&& SDL3_Shader_Retarget(hlsl, false);
}
- return write_engine_pixel_program(program, pipeline, hlsl, bumped, true);
+ return write_engine_pixel_program(program, pipeline, hlsl, true);
}
static bool write_engine_pixel_program(EngineShaderProgram program,
- const PixelPipelineDescription & pipeline, std::string & hlsl, bool bumped, bool volumetric)
+ const PixelPipelineDescription & pipeline, std::string & hlsl, bool volumetric)
{
hlsl.clear();
- if (bumped && !EngineShader_Can_Bump(program)) {
- return false;
- }
const EngineShaderEntry * entry = entry_for(program);
if (entry != NULL && entry->Opening != NULL) {
- write_multiply_chain(hlsl, *entry, bumped, volumetric);
+ write_multiply_chain(hlsl, *entry, volumetric);
}
else if (program == ENGINE_SHADER_WATER_TRAPEZOID) {
write_trapezoid_water(hlsl);
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.h
index 07f52cae1..2f591f111 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.h
@@ -88,17 +88,10 @@ bool EngineShader_Vertex_Program(EngineShaderProgram program, std::string & hlsl
// The pixel half. The alpha test and the fog come from the render state and are written into the
// program the way ffshader writes them, because D3D9 applies both around a bound pixel shader and
// D3D11 applies neither.
-//
-// bumped is the terrain's normal atlas at work: the ground is shaded again through the normal atlas at t4,
-// by how much the bumped surface faces the sun more or less than the flat one does. Only the three
-// blending terrain programs take it; for any other the call is refused.
bool EngineShader_Pixel_Program(EngineShaderProgram program,
- const PixelPipelineDescription & pipeline, std::string & hlsl, bool bumped = false,
+ const PixelPipelineDescription & pipeline, std::string & hlsl,
CombinerShaderTarget target = COMBINER_SHADER_TARGET_D3D11);
-// Whether a program is one bumped can be asked of.
-bool EngineShader_Can_Bump(EngineShaderProgram program);
-
// Which transcribed programs paint the ground, and so read the sun's shadow map. The water and
// the trees are not among them: both have shadows of their own.
bool EngineShader_Paints_Ground(EngineShaderProgram program);
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp
index c91f2e37b..d88dc4fde 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp
@@ -233,57 +233,6 @@ static bool alpha_test_expression(FixedFunctionValue function, std::string & exp
}
}
-// The vertex colour lit again with the normal the map gives, written over input.Diffuse before the
-// stages read it, and the highlight the stages add afterwards. The map carries no tangents and
-// the game's meshes have none either, so the frame is rebuilt per pixel from how the position and
-// the coordinate change across the screen: a tangent is whichever way u grows and a bitangent
-// whichever way v grows, which is the convention the maps are written in and which holds on a
-// mirrored island too. The light directions are the way the light travels, in camera space.
-static void append_normal_mapped_lighting(std::string & hlsl, unsigned coordinate_set)
-{
- char line[2048];
- snprintf(line, sizeof(line),
- " float3 surface_normal = normalize(input.ViewNormal);\n"
- " float3 position_dx = ddx(input.ViewPosition);\n"
- " float3 position_dy = ddy(input.ViewPosition);\n"
- " float2 coordinate_dx = ddx(input.TexCoord%u);\n"
- " float2 coordinate_dy = ddy(input.TexCoord%u);\n"
- " float3 across_dy = cross(position_dy, surface_normal);\n"
- " float3 across_dx = cross(surface_normal, position_dx);\n"
- " float3 tangent = across_dy * coordinate_dx.x + across_dx * coordinate_dy.x;\n"
- " float3 bitangent = across_dy * coordinate_dx.y + across_dx * coordinate_dy.y;\n"
- " float frame_scale = rsqrt(max(max(dot(tangent, tangent), dot(bitangent, bitangent)), 1e-20));\n"
- " float4 normal_texel = NormalMap.Sample(Sampler0, input.TexCoord%u);\n"
- " float3 bump = normal_texel.xyz * 2.0 - 1.0;\n"
- " bump.xy *= NormalMapParameters.x;\n"
- " float3 bumped = normalize((tangent * bump.x + bitangent * bump.y) * frame_scale"
- " + surface_normal * bump.z);\n"
- " float3 to_eye = normalize(-input.ViewPosition);\n"
- " float3 bumped_light = float3(0.0, 0.0, 0.0);\n"
- " float3 highlight = float3(0.0, 0.0, 0.0);\n"
- " for (int light = 0; light < %u; ++light) {\n"
- " float3 to_light = -NormalLightDirection[light].xyz;\n"
- " bumped_light += NormalLightDiffuse[light].rgb * saturate(dot(bumped, to_light));\n"
- " highlight += NormalLightDiffuse[light].rgb"
- " * pow(saturate(dot(bumped, normalize(to_light + to_eye))), NormalMapParameters.y);\n"
- " }\n"
- " highlight *= normal_texel.a * NormalMapParameters.z;\n"
- /* What makes metal read as metal from a camera this far out is not the sun's own dot on it,
- which is one small spot, but the sky it mirrors over its whole flank. There is no cubemap
- here and none is needed: the sky over this game is a gradient and a sun, so the mirrored
- direction is turned into a colour rather than looked up. Sky.rgb is the map's own light,
- Sky.a how much of it metal returns, and the share grows towards the grazing angles where a
- real surface turns into a mirror. The gloss map gates it, so cloth and sand get none. */
- " float3 mirrored = reflect(-to_eye, bumped);\n"
- " float sky_height = saturate(dot(mirrored, SkyUp.xyz) * 0.5 + 0.5);\n"
- " float3 sky = lerp(Sky.rgb * SkyUp.w, Sky.rgb, sky_height);\n"
- " float grazing = pow(1.0 - saturate(dot(bumped, to_eye)), 4.0);\n"
- " highlight += sky * Sky.a * normal_texel.a * (0.3 + 0.7 * grazing);\n"
- " input.Diffuse.rgb = saturate(input.LitMaterial * bumped_light + input.LitBase);\n",
- coordinate_set, coordinate_set, coordinate_set, NORMAL_MAPPED_LIGHTS);
- hlsl += line;
-}
-
static bool generate_combiners(const CombinerDescription & description,
CombinerShaderTarget target, std::string & hlsl, bool volumetric);
@@ -307,10 +256,6 @@ static bool generate_combiners(const CombinerDescription & description,
if (description.StageCount == 0 || description.StageCount > MAXIMUM_COMBINER_STAGES) {
return false;
}
- if (description.NormalMapped
- && (target != COMBINER_SHADER_TARGET_D3D11 || !description.Stages[0].TextureBound)) {
- return false;
- }
std::string body;
for (unsigned stage = 0; stage < description.StageCount; ++stage) {
@@ -408,10 +353,10 @@ static bool generate_combiners(const CombinerDescription & description,
" float4 FogColour;\n"
" float4 AlphaReference;\n";
// A shader declares a prefix of the block the backend uploads, so a field is found by what
- // comes before it and not by its name. The shadow fields sit behind the normal mapped ones
- // and the terrain's sun, so a program that reads them has to declare those too, used or
- // not: without them a shadow matrix lands where the first light's direction is.
- if (description.NormalMapped || description.ShadowReceiving) {
+ // comes before it and not by its name. The shadow fields sit behind the old normal mapped
+ // ones and the terrain's sun, so a program that reads them has to declare those too, unused:
+ // without them a shadow matrix lands where the first light's direction is.
+ if (description.ShadowReceiving) {
char line[256];
snprintf(line, sizeof(line),
" float4 NormalLightDirection[%u];\n"
@@ -419,8 +364,6 @@ static bool generate_combiners(const CombinerDescription & description,
" float4 NormalMapParameters;\n",
NORMAL_MAPPED_LIGHTS, NORMAL_MAPPED_LIGHTS);
hlsl += line;
- }
- if (description.NormalMapped || description.ShadowReceiving) {
hlsl +=
" float4 TerrainSunDirection;\n"
// row_major for the reason the vertex half gives: every matrix the engine has is a
@@ -438,9 +381,6 @@ static bool generate_combiners(const CombinerDescription & description,
hlsl += VOLUMETRIC_CONSTANTS;
}
hlsl += "};\n";
- if (description.NormalMapped) {
- hlsl += "Texture2D NormalMap : register(t4);\n";
- }
if (description.ShadowReceiving) {
hlsl += SHADOW_SAMPLING;
}
@@ -483,9 +423,6 @@ static bool generate_combiners(const CombinerDescription & description,
if (target == COMBINER_SHADER_TARGET_D3D11) {
hlsl += " float Fog : FOG;\n";
}
- if (description.NormalMapped) {
- hlsl += NORMAL_MAPPED_VARYINGS;
- }
hlsl +=
"};\n"
"\n";
@@ -495,16 +432,9 @@ static bool generate_combiners(const CombinerDescription & description,
hlsl +=
"{\n"
" float4 texel;\n";
- if (description.NormalMapped) {
- append_normal_mapped_lighting(hlsl,
- stage_register(target, 0, description.Stages[0].TextureCoordinateIndex));
- }
hlsl += " float4 current = input.Diffuse;\n";
hlsl += body;
- if (description.NormalMapped) {
- hlsl += " current.rgb = saturate(current.rgb + highlight);\n";
- }
- else if (description.SpecularAdd && !description.SmokeGlow) {
+ 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";
}
@@ -589,9 +519,6 @@ std::string CombinerShader_Key(const CombinerDescription & description)
// both, which costs a D3D9 cache entry that generates the same text as another and buys one
// cache that is right for either profile.
key += CombinerShader_Pipeline_Key(description.PixelPipeline);
- if (description.NormalMapped) {
- key += ":N";
- }
if (description.ShadowReceiving) {
key += ":S";
}
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h
index 2841b10ab..329713dea 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h
@@ -85,12 +85,6 @@ struct CombinerDescription
// bound pixel shader, and generating them there would apply each of them twice.
PixelPipelineDescription PixelPipeline;
- // D3D11 only: light the pixel again through the normal map at t4 before the
- // stages read the diffuse colour, and add a highlight scaled by the map's alpha after them.
- // The vertex half has to have been generated with the same flag. Initialised here because
- // callers fill a description field by field and one written before this existed never sets it.
- bool NormalMapped = false;
-
// D3D11 only: take the pixel back out of clip space, look it up in the sun's depth buffer at t5
// and darken it by how much of the filter comes back blocked. No vertex half is involved: the
// position comes from SV_Position and one matrix, which is what keeps this off the varyings the
@@ -101,8 +95,8 @@ struct CombinerDescription
// (D3DRENDERSTATETYPE: "added to the base color after the texture cascade but before alpha
// blending"). Every profile writes it, D3D9's included: D3D9 does the add only for its
// fixed-function stages, and a bound pixel shader, which the D3D9 profile's program is, replaces
- // it ("Writing HLSL Shaders in Direct3D 9"). A normal mapped program adds its own highlight
- // instead. Initialised here for a caller that fills the rest field by field.
+ // it ("Writing HLSL Shaders in Direct3D 9"). Initialised here for a caller that fills the rest
+ // field by field.
bool SpecularAdd = false;
// D3D11 only: the vertex half carries a fire's glow in the specular slot (VertexPipelineDescription::
@@ -113,8 +107,8 @@ struct CombinerDescription
bool SmokeGlow = false;
};
-// The normal mapped pixel program reads this many directional lights from its constants. Slots
-// past the draw's own lights carry no colour and add nothing.
+// The constant block still carries this many normal mapped light slots, unread, so the shadow and
+// sky fields behind them keep their offsets.
const unsigned NORMAL_MAPPED_LIGHTS = 4;
// How much of the sun reaches a pixel, shared by the generated programs and the transcribed ones so
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.cpp
index 16b56f89a..8834b4620 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.cpp
@@ -383,7 +383,7 @@ static void append_input_coordinate_sets(std::string & hlsl, unsigned coordinate
// What every generated vertex program writes, whatever it was generated from. Shader model 4
// links the stages by slot in declaration order, so this structure and ffshader's input structure
// are one thing in two files: a program that writes a different set links against nothing.
-static void append_output_structure(std::string & hlsl, bool for_d3d11, bool normal_mapped)
+static void append_output_structure(std::string & hlsl, bool for_d3d11)
{
hlsl +=
"struct Output\n"
@@ -400,9 +400,6 @@ static void append_output_structure(std::string & hlsl, bool for_d3d11, bool nor
}
hlsl += " float Fog : FOG;\n";
- if (normal_mapped) {
- hlsl += NORMAL_MAPPED_VARYINGS;
- }
hlsl +=
"};\n"
"\n";
@@ -441,7 +438,7 @@ static bool generate_pretransformed(const VertexPipelineDescription & descriptio
hlsl +=
"};\n"
"\n";
- append_output_structure(hlsl, for_d3d11, false);
+ append_output_structure(hlsl, for_d3d11);
hlsl +=
"Output main(Input input)\n"
"{\n"
@@ -509,9 +506,6 @@ bool VertexShader_Generate(const VertexPipelineDescription & description,
if (description.LightingEnabled && !has_normal(description.FVF)) {
return false;
}
- if (description.NormalMapped && is_pretransformed(description.FVF)) {
- return false;
- }
if (description.SmokeGlow
&& (description.LightingEnabled || !has_normal(description.FVF) || is_pretransformed(description.FVF))) {
return false;
@@ -566,9 +560,9 @@ bool VertexShader_Generate(const VertexPipelineDescription & description,
// Each light's own ambient is in that second sum (ambient_light, summed in append_light). It
// was left out once on the belief that W3D's lights all have a black one; its point lights do
// not (dx8wrapper.cpp's light environment, W3DDisplay's dynamic lights).
- // A normal mapped draw lights its directional lights per pixel. A point or spot light - the
- // flash of a gun, the glow of a fire - stays per vertex and is summed on its own, so it can
- // be handed to the pixel half as part of the base it adds the bumped light to.
+ // A point or spot light is summed on its own and folded in after the loop. The split served
+ // the normal mapped path, which is gone; it stays because the text is what the shader cache
+ // is keyed by.
body += " float3 diffuse_light = float3(0.0, 0.0, 0.0);\n";
body += " float3 local_light = float3(0.0, 0.0, 0.0);\n";
body += " float3 specular_light = float3(0.0, 0.0, 0.0);\n";
@@ -596,14 +590,6 @@ bool VertexShader_Generate(const VertexPipelineDescription & description,
+ ambient + ".rgb * (GlobalAmbient.rgb + ambient_light) + " + emissive + ".rgb);\n";
body += " output.Diffuse.a = " + diffuse + ".a;\n";
- if (description.NormalMapped) {
- body += " output.ViewPosition = view_position.xyz;\n";
- body += " output.ViewNormal = view_normal;\n";
- body += " output.LitBase = " + diffuse + ".rgb * local_light + " + ambient
- + ".rgb * (GlobalAmbient.rgb + ambient_light) + " + emissive + ".rgb;\n";
- body += " output.LitMaterial = " + diffuse + ".rgb;\n";
- }
-
if (description.SpecularEnabled) {
std::string specular;
if (!material_source_expression(description.SpecularMaterialSource, "MaterialSpecular",
@@ -661,17 +647,6 @@ bool VertexShader_Generate(const VertexPipelineDescription & description,
body += " output.Fog = 1.0;\n";
}
- // An unlit normal mapped draw is the terrain, whose light is baked into its vertex colour. The
- // pixel half only wants the position from it, to rebuild the surface frame; the lit colour it
- // would otherwise be handed is not used.
- if (description.NormalMapped && !description.LightingEnabled) {
- body +=
- " output.ViewPosition = view_position.xyz;\n"
- " output.ViewNormal = view_normal;\n"
- " output.LitBase = float3(0.0, 0.0, 0.0);\n"
- " output.LitMaterial = float3(0.0, 0.0, 0.0);\n";
- }
-
const bool for_d3d11 = (target == VERTEX_SHADER_TARGET_D3D11);
hlsl = "// Generated from a fixed-function vertex pipeline description. See ffvertex.h.\n";
@@ -710,7 +685,7 @@ bool VertexShader_Generate(const VertexPipelineDescription & description,
hlsl +=
"};\n"
"\n";
- append_output_structure(hlsl, for_d3d11, description.NormalMapped);
+ append_output_structure(hlsl, for_d3d11);
hlsl +=
"Output main(Input input)\n"
"{\n"
@@ -774,9 +749,6 @@ std::string VertexShader_Key(const VertexPipelineDescription & description)
snprintf(field, sizeof(field), ":F%u,%lu", description.FogEnabled ? 1u : 0u,
description.FogEnabled ? description.FogVertexMode : 0ul);
key += field;
- if (description.NormalMapped) {
- key += ":N";
- }
if (description.SmokeGlow) {
key += ":G";
}
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.h
index da96f41d3..82b336048 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffvertex.h
@@ -53,14 +53,6 @@ const unsigned MAXIMUM_VERTEX_STAGES = 4;
// three, and every register past this one is a register the D3D9 profile does not have to spare.
const unsigned MAXIMUM_VERTEX_LIGHTS = 4;
-// What a normal mapped vertex program writes after the fog factor, and what the pixel program
-// declares after it. One string in one place because shader model 4 links the two by slot.
-#define NORMAL_MAPPED_VARYINGS \
- " float3 ViewPosition : TEXCOORD4;\n" \
- " float3 ViewNormal : TEXCOORD5;\n" \
- " float3 LitBase : TEXCOORD6;\n" \
- " float3 LitMaterial : TEXCOORD7;\n"
-
// Where each constant sits in the D3D9 profile's register file, which is what
// SetVertexShaderConstantF is given. The D3D11 profile puts the same values in one constant buffer
// in this order instead, so the two halves of the generator share the layout and nothing else.
@@ -139,13 +131,6 @@ struct VertexPipelineDescription
// enabled is table fog, which is the pixel half's business and not this one's.
FixedFunctionValue FogVertexMode;
- // Stage zero's texture has a normal map beside it, so the lights are summed per
- // pixel instead of here. The program still lights the vertex, and past the fog factor it also
- // writes the camera space position and normal and the two halves of the lit colour that do
- // not depend on the normal, which ffshader reads to light the pixel again. An unlit one is the
- // terrain, whose pixel half (engineshader) reads only the position. Initialised here for a caller that fills the rest field by field.
- bool NormalMapped = false;
-
// An unlit draw whose normal is not a normal: the sorted smoke billboards put the glow of the
// fires near them there, and the program hands it on in the specular colour, which an unlit draw
// with no second colour in its vertices otherwise leaves black. The pixel half adds it after the
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sdl3target.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sdl3target.h
index 569797868..8e1736331 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sdl3target.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sdl3target.h
@@ -49,9 +49,9 @@
** 5. Every texture read through its own sampler, at its own slot. SDL binds textures and
** samplers as pairs, slot n being texture n with sampler n, and SDL_shadercross pairs them by
** that rule too: a texture read through another slot's sampler is given no slot of its own and
-** collides with texture 0 on Metal. The generators do exactly that with the normal map (t4),
-** read through stage 0's sampler - and in the bumped terrain through stage 1's as well, for the
-** far layer. So each such read is rebound:
+** collides with texture 0 on Metal. The generators did exactly that with the normal map (t4),
+** read through stage 0's sampler, until the normal maps were taken out on 2026-10-06; the
+** rebinding stays for any such read. So each such read is rebound:
** - the reads through the lowest-numbered sampler keep the texture's own slot, with a sampler
** of that slot beside it;
** - the reads through any other sampler read a second name for the same texture, at the next
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.cpp
index 1c2f7568b..ab57ffce9 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.cpp
@@ -121,8 +121,6 @@ TextureBaseClass::TextureBaseClass
: MipLevelCount(mip_level_count),
D3DTexture(NULL),
Initialized(false),
- NormalMap(NULL),
- NormalMapLooked(false),
Name(""),
FullPath(""),
texture_id(unused_texture_id++),
@@ -161,7 +159,6 @@ TextureBaseClass::~TextureBaseClass(void)
D3DTexture->Release();
D3DTexture = NULL;
}
- REF_PTR_RELEASE(NormalMap);
DX8TextureManagerClass::Remove(this);
}
@@ -1012,85 +1009,9 @@ void TextureClass::Apply(unsigned int stage)
DX8Wrapper::Set_DX8_Texture(stage, NULL);
}
- if (stage == 0 && Direct3D11_Normal_Maps_Active())
- {
- TextureClass * normal_map = Find_Normal_Map();
- Direct3D11_Mirror_Normal_Map(normal_map != NULL ? normal_map->Peek_D3D_Base_Texture() : NULL);
- }
-
Filter.Apply(stage);
}
-void TextureClass::Set_Normal_Map(TextureClass * normal_map)
-{
- REF_PTR_SET(NormalMap, normal_map);
- NormalMapLooked = true;
-}
-
-bool Texture_Name_Is_Damage_State(const char * name)
-{
- static const char STATE_LETTERS[] = "desgnr";
- static const size_t LONGEST_STATE_TAG = 4;
-
- const char * tag = strrchr(name, '_');
- if (tag == NULL)
- {
- return false;
- }
- ++tag;
-
- size_t length = 0;
- bool damaged = false;
- for (; tag[length] != '\0' && tag[length] != '.'; ++length)
- {
- const char letter = (char)tolower((unsigned char)tag[length]);
- if (strchr(STATE_LETTERS, letter) == NULL)
- {
- return false;
- }
- damaged = damaged || letter == 'd' || letter == 'e';
- }
- return damaged && length <= LONGEST_STATE_TAG;
-}
-
-TextureClass * TextureClass::Find_Normal_Map()
-{
- static const char NORMAL_MAP_SUFFIX[] = "_nrm.dds";
-
- // A damage state is a separate texture a quarter the size of the building's own, so its normal
- // map spread a texel of relief over a whole panel: the damaged walls lit up as black and white
- // marble. It draws flat, as it did in 2003.
- if (!NormalMapLooked && Texture_Name_Is_Damage_State(Get_Texture_Name()))
- {
- NormalMapLooked = true;
- }
-
- if (!NormalMapLooked)
- {
- NormalMapLooked = true;
- char name[_MAX_PATH];
- strncpy(name, Get_Texture_Name(), sizeof(name) - sizeof(NORMAL_MAP_SUFFIX));
- name[sizeof(name) - sizeof(NORMAL_MAP_SUFFIX)] = '\0';
- char * extension = strrchr(name, '.');
- if (extension != NULL)
- {
- *extension = '\0';
- }
- strcat(name, NORMAL_MAP_SUFFIX);
-
- file_auto_ptr file(_TheFileFactory, name);
- if (file->Is_Available())
- {
- NormalMap = WW3DAssetManager::Get_Instance()->Get_Texture(name);
- }
- }
- if (NormalMap != NULL && !NormalMap->Is_Initialized())
- {
- NormalMap->Init();
- }
- return NormalMap;
-}
-
//**********************************************************************************************
//! Get surface from mip level
/*!
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.h
index ffde9f29e..4d0c0ba5e 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.h
@@ -216,11 +216,6 @@ protected:
bool Initialized;
- // What TextureClass::Find_Normal_Map found, and whether it has looked. Here rather than on
- // TextureClass because this is the one constructor every texture goes through.
- TextureClass * NormalMap;
- bool NormalMapLooked;
-
// For debug purposes the texture sets this true if it is a lightmap texture
bool IsLightmap;
bool IsCompressionAllowed;
@@ -351,19 +346,8 @@ public:
virtual TextureClass* As_TextureClass() { return this; }
- // Hand a texture built in memory its normal map, for one with no file name to look
- // one up by - the terrain atlas.
- void Set_Normal_Map(TextureClass * normal_map);
-
- // What Set_Normal_Map or an earlier lookup found, without looking. For a caller that binds the
- // Direct3D texture itself and so never passes through Apply.
- TextureClass * Peek_Normal_Map() const { return NormalMap; }
-
protected:
- // "<name>_nrm.dds" through the file factory, looked for once and kept.
- TextureClass * Find_Normal_Map();
-
WW3DFormat TextureFormat;
// legacy
@@ -496,10 +480,6 @@ protected:
int Depth;
};
-// Is this texture file one of a building's damage states - "<name>_d", "_e", or the night, snow
-// and garrison copies of those, "_dn", "_es", "_dsg" and the rest? Those carry no normal map.
-bool Texture_Name_Is_Damage_State(const char * name);
-
// Utility functions for loading and saving texture descriptions from/to W3D files
TextureClass *Load_Texture(ChunkLoadClass & cload);
void Save_Texture(TextureClass * texture, ChunkSaveClass & csave);
diff --git a/GeneralsMD/Code/Tests/shader_cases.h b/GeneralsMD/Code/Tests/shader_cases.h
index b852d983e..47a7a3cfb 100644
--- a/GeneralsMD/Code/Tests/shader_cases.h
+++ b/GeneralsMD/Code/Tests/shader_cases.h
@@ -22,13 +22,13 @@
* target's text unchanged) and test_shader_sdl (the SDL3 GPU target through glslang, SPIR-V and
* MSL).
*
- * The reference set is the 49 programs decision 4 was measured on (PORTING.md):
+ * The reference set is the 49 programs decision 4 was measured on (PORTING.md), less the three
+ * bumped terrain programs that went with the normal maps, so 46:
* - 19 pixel programs: every case test_ffshadercompile compiles,
* - 14 vertex programs: every case test_ffvertexcompile compiles,
- * - 16 engine programs: every program engineshader.cpp transcribes, the three bumped terrain
- * variants included.
+ * - 13 engine programs: every program engineshader.cpp transcribes.
* Each is copied from the test that owns it, field for field. The rest are marked Reference = false:
- * the normal mapped, shadow receiving and pre-transformed programs those tests never asked for,
+ * the shadow receiving and pre-transformed programs those tests never asked for,
* which are exactly the branches a new target has to get right.
*/
#pragma once
@@ -69,7 +69,6 @@ struct ShaderCase
VertexPipelineDescription Vertex;
EngineShaderProgram Engine;
PixelPipelineDescription EnginePipeline;
- bool EngineBumped;
};
inline const char *Shader_Case_Target_Name(ShaderCaseTarget target)
@@ -106,19 +105,17 @@ inline ShaderCase combiner(const std::string &name, bool reference)
memset(&c.Combiner.Stages, 0, sizeof(c.Combiner.Stages));
c.Combiner.StageCount = 0;
memset(&c.Combiner.PixelPipeline, 0, sizeof(c.Combiner.PixelPipeline));
- c.Combiner.NormalMapped = false;
c.Combiner.ShadowReceiving = false;
c.Vertex = VertexPipelineDescription();
c.Engine = ENGINE_SHADER_NONE;
memset(&c.EnginePipeline, 0, sizeof(c.EnginePipeline));
- c.EngineBumped = false;
return c;
}
// test_ffvertexcompile's plain_description.
inline VertexPipelineDescription plain_vertex()
{
- // Value-initialised: zero, and NormalMapped its declared false. A memset over a structure with a
+ // Value-initialised: zero, and the flags their declared false. A memset over a structure with a
// default member initialiser is what gcc's -Wclass-memaccess warns about.
VertexPipelineDescription description = VertexPipelineDescription();
description.FVF = FF_FVF_XYZ | FF_FVF_NORMAL | FF_FVF_TEX2 | FF_FVF_DIFFUSE;
@@ -207,13 +204,6 @@ inline std::vector<ShaderCase> Shader_Cases()
}
// ---- beyond the reference set: the pixel branches the compile tests never reached ----
- {
- ShaderCase c = combiner("ps_extra_normal_mapped", false);
- c.Combiner.StageCount = 1;
- c.Combiner.Stages[0] = one_stage(FF_TOP_MODULATE, FF_TA_TEXTURE, FF_TA_DIFFUSE, FF_TOP_MODULATE, FF_TA_TEXTURE, FF_TA_DIFFUSE, 0, true);
- c.Combiner.NormalMapped = true;
- cases.push_back(c);
- }
{
ShaderCase c = combiner("ps_extra_shadow_receiving", false);
c.Combiner.StageCount = 1;
@@ -222,17 +212,6 @@ inline std::vector<ShaderCase> Shader_Cases()
c.Combiner.PixelPipeline.FogEnabled = true;
cases.push_back(c);
}
- {
- ShaderCase c = combiner("ps_extra_normal_mapped_shadow_receiving", false);
- c.Combiner.StageCount = 2;
- c.Combiner.Stages[0] = one_stage(FF_TOP_MODULATE, FF_TA_TEXTURE, FF_TA_DIFFUSE, FF_TOP_MODULATE, FF_TA_TEXTURE, FF_TA_DIFFUSE, 0, true);
- c.Combiner.Stages[1] = one_stage(FF_TOP_BLENDCURRENTALPHA, FF_TA_TEXTURE, FF_TA_CURRENT, FF_TOP_DISABLE, FF_TA_TEXTURE, FF_TA_CURRENT, 1, true);
- c.Combiner.NormalMapped = true;
- c.Combiner.ShadowReceiving = true;
- c.Combiner.PixelPipeline.AlphaTestEnabled = true;
- c.Combiner.PixelPipeline.AlphaFunction = FF_CMP_GREATEREQUAL;
- cases.push_back(c);
- }
// ---- test_ffvertexcompile ----
struct VertexCase
@@ -292,21 +271,6 @@ inline std::vector<ShaderCase> Shader_Cases()
}
// ---- beyond the reference set: the vertex branches the compile tests never reached ----
- {
- VertexPipelineDescription description = plain_vertex();
- description.LightingEnabled = true;
- description.LightCount = 1;
- description.Lights[0].Type = FF_LIGHT_DIRECTIONAL;
- description.NormalMapped = true;
- cases.push_back(vertex("vs_extra_normal_mapped_lit", false, description));
- }
- {
- VertexPipelineDescription description = plain_vertex();
- description.NormalMapped = true;
- description.FogEnabled = true;
- description.FogVertexMode = FF_FOG_LINEAR;
- cases.push_back(vertex("vs_extra_normal_mapped_unlit", false, description));
- }
{
VertexPipelineDescription description = plain_vertex();
description.FVF = FF_FVF_XYZRHW | FF_FVF_DIFFUSE | FF_FVF_TEX1;
@@ -361,7 +325,7 @@ inline std::vector<ShaderCase> Shader_Cases()
cases.push_back(vertex("vs_extra_passthrough_count2", false, description));
}
- // ---- engineshader.cpp: every program, pixel and vertex, bumped where it can be ----
+ // ---- engineshader.cpp: every program, pixel and vertex ----
for (int program = ENGINE_SHADER_TREES; program <= ENGINE_SHADER_MONOCHROME; ++program) {
const EngineShaderProgram which = (EngineShaderProgram)program;
std::string name = EngineShader_Name(which);
@@ -382,12 +346,6 @@ inline std::vector<ShaderCase> Shader_Cases()
if (EngineShader_Pixel_Program(which, c.EnginePipeline, scratch)) {
c.Name = "ps_es_" + name;
cases.push_back(c);
- if (EngineShader_Can_Bump(which)) {
- c.Name = "ps_es_" + name + "_bumped";
- c.EngineBumped = true;
- cases.push_back(c);
- c.EngineBumped = false;
- }
// Beyond the reference set: the alpha test and the fog, which the engine's pixel programs
// take from the render state the way ffshader's do.
c.Name = "ps_es_" + name + "_extra_alphatest_fog";
@@ -403,7 +361,7 @@ inline std::vector<ShaderCase> Shader_Cases()
return cases;
}
-// One case for one target. False when the generator refuses it (a normal map on D3D9) or when the
+// One case for one target. False when the generator refuses it or when the
// target does not apply (the engine programs exist only on the shader model 4 profiles).
inline bool Shader_Case_Generate(const ShaderCase &c, ShaderCaseTarget target, std::string &hlsl)
{
@@ -428,11 +386,11 @@ inline bool Shader_Case_Generate(const ShaderCase &c, ShaderCaseTarget target, s
#if !defined(SHADER_CASES_BEFORE_SDL3_TARGET)
if (target == SHADER_CASE_SDL3_GPU) {
return c.VertexStage ? EngineShader_Vertex_Program(c.Engine, hlsl, VERTEX_SHADER_TARGET_SDL3_GPU)
- : EngineShader_Pixel_Program(c.Engine, c.EnginePipeline, hlsl, c.EngineBumped, COMBINER_SHADER_TARGET_SDL3_GPU);
+ : EngineShader_Pixel_Program(c.Engine, c.EnginePipeline, hlsl, COMBINER_SHADER_TARGET_SDL3_GPU);
}
#endif
return c.VertexStage ? EngineShader_Vertex_Program(c.Engine, hlsl)
- : EngineShader_Pixel_Program(c.Engine, c.EnginePipeline, hlsl, c.EngineBumped);
+ : EngineShader_Pixel_Program(c.Engine, c.EnginePipeline, hlsl);
}
return false;
}
diff --git a/GeneralsMD/Code/Tests/test_ffvertex.cpp b/GeneralsMD/Code/Tests/test_ffvertex.cpp
index 37b1c8b9d..b22c7892e 100644
--- a/GeneralsMD/Code/Tests/test_ffvertex.cpp
+++ b/GeneralsMD/Code/Tests/test_ffvertex.cpp
@@ -120,25 +120,6 @@ TEST(ffvertex_a_point_light_attenuates_and_stops_at_its_range)
CHECK(!contains(hlsl, "spot_cosine"));
}
-// A normal mapped draw bumps its directional lights per pixel. A gun flash or a fire is a point
-// light, and it used to send the whole draw back to vertex lighting; now it rides in the base.
-TEST(ffvertex_a_normal_mapped_draw_carries_its_point_lights_in_the_base)
-{
- VertexPipelineDescription description = plain_description();
- description.LightingEnabled = true;
- description.NormalMapped = true;
- description.LightCount = 2;
- description.Lights[0].Type = FF_LIGHT_DIRECTIONAL;
- description.Lights[1].Type = FF_LIGHT_POINT;
-
- std::string hlsl;
- CHECK(VertexShader_Generate(description, VERTEX_SHADER_TARGET_D3D11, hlsl));
- CHECK(contains(hlsl, "diffuse_light += Light0Diffuse.rgb"));
- CHECK(contains(hlsl, "local_light += Light1Diffuse.rgb"));
- CHECK(contains(hlsl, "diffuse_light += local_light;"));
- CHECK(contains(hlsl, ".rgb * local_light + "));
-}
-
TEST(ffvertex_a_spot_light_adds_the_cone_to_the_point_light_terms)
{
VertexPipelineDescription description = plain_description();
diff --git a/GeneralsMD/Code/Tests/test_ffvertexcompile.cpp b/GeneralsMD/Code/Tests/test_ffvertexcompile.cpp
index d3f642c97..7b11244ac 100644
--- a/GeneralsMD/Code/Tests/test_ffvertexcompile.cpp
+++ b/GeneralsMD/Code/Tests/test_ffvertexcompile.cpp
@@ -211,45 +211,6 @@ TEST(ffvertexcompile_a_two_stage_program_compiles)
CHECK(compiles(compile, eleven, D3D11_PROFILE));
}
-// Normal maps: a unit's draw, lit by the game's three directional lights, with both halves
-// generated normal mapped. The pixel half uses ddx and ddy, which only a pixel profile has, and
-// reads the four values the vertex half writes past the fog factor.
-TEST(ffvertexcompile_a_normal_mapped_pair_compiles_on_d3d11)
-{
- D3DCompileFunction compile = load_compiler();
- if (compile == NULL) {
- printf(" d3dcompiler_47.dll not present, skipping\n");
- return;
- }
-
- VertexPipelineDescription vertex = plain_description();
- vertex.LightingEnabled = true;
- vertex.LightCount = 3;
- for (unsigned index = 0; index < vertex.LightCount; ++index) {
- vertex.Lights[index].Type = D3DLIGHT_DIRECTIONAL;
- }
- vertex.NormalMapped = true;
-
- CombinerDescription pixel;
- memset(&pixel, 0, sizeof(pixel));
- pixel.StageCount = 1;
- pixel.Stages[0].ColourOperation = D3DTOP_MODULATE;
- pixel.Stages[0].ColourArgument1 = D3DTA_TEXTURE;
- pixel.Stages[0].ColourArgument2 = D3DTA_DIFFUSE;
- pixel.Stages[0].AlphaOperation = D3DTOP_SELECTARG1;
- pixel.Stages[0].AlphaArgument1 = D3DTA_TEXTURE;
- pixel.Stages[0].TextureBound = true;
- pixel.NormalMapped = true;
-
- std::string vertex_hlsl;
- std::string pixel_hlsl;
- CHECK(VertexShader_Generate(vertex, VERTEX_SHADER_TARGET_D3D11, vertex_hlsl));
- CHECK(CombinerShader_Generate(pixel, COMBINER_SHADER_TARGET_D3D11, pixel_hlsl));
- CHECK(compiles(compile, vertex_hlsl, D3D11_PROFILE));
- CHECK(compiles(compile, pixel_hlsl, "ps_4_0"));
- CHECK(!CombinerShader_Generate(pixel, COMBINER_SHADER_TARGET_D3D9, pixel_hlsl));
-}
-
// The smoke billboards' glow: the unlit vertex half hands the normal on in the specular slot, keyed
// apart from the same program without it, and refuses a lit draw, whose normal is a normal.
TEST(ffvertexcompile_the_smoke_glow_rides_the_specular_slot)
diff --git a/GeneralsMD/Code/Tests/test_shader_sdl.cpp b/GeneralsMD/Code/Tests/test_shader_sdl.cpp
index 0867a3112..53f89e737 100644
--- a/GeneralsMD/Code/Tests/test_shader_sdl.cpp
+++ b/GeneralsMD/Code/Tests/test_shader_sdl.cpp
@@ -20,7 +20,8 @@
* the generators write, under the SDL3 GPU target, taken the whole way to what SDL's GPU backends
* accept (decision 4).
*
- * For each program in shader_cases.h - the 49 decision 4 was measured on, and the extras - it:
+ * For each program in shader_cases.h - the 49 decision 4 was measured on less the three bumped
+ * terrain programs that went with the normal maps, and the extras - it:
* 1. generates the SDL3_GPU text,
* 2. compiles it to SPIR-V through SDL3_Compile_HLSL_To_SPIRV (the one place the HLSL front end is
* named, so this test follows the compiler if decision 4's exit is ever taken),
@@ -39,9 +40,7 @@
* binds Trees.vso and no pixel shader (it loads Trees.pso and never binds it), and engineshader
* transcribes no Trees pixel program;
* - the engine's pixel programs (water, terrain, road, monochrome) meet ffvertex's programs only:
- * their draws bind a .pso over the fixed-function vertex pipeline;
- * - a normal mapped pixel program meets only vertex programs that write the normal mapped
- * varyings, as ffshader.h requires of its callers.
+ * their draws bind a .pso over the fixed-function vertex pipeline.
* Trees against a water or terrain pixel program does not link - they read coordinate sets 2 and 3
* and Trees writes two - and the game never draws it.
*
@@ -196,11 +195,6 @@ bool vertex_layout(const std::string & hlsl, std::vector<SDL_GPUVertexAttribute>
return !attributes.empty();
}
-bool writes_normal_mapped_varyings(const std::string & hlsl)
-{
- return hlsl.find("ViewPosition : TEXCOORD4") != std::string::npos;
-}
-
TEST(every_generated_program_reaches_sdl3_gpu)
{
const char * spirv_val = getenv("ZH_SPIRV_VAL");
@@ -293,7 +287,7 @@ TEST(every_generated_program_reaches_sdl3_gpu)
print_tally("reference set", reference, validating, metal);
print_tally("beyond it", extra, validating, metal);
- CHECK_EQ(reference.programs, 49u);
+ CHECK_EQ(reference.programs, 46u);
CHECK(extra.programs > 0);
if (device != NULL) {
@@ -321,7 +315,6 @@ TEST(every_vertex_program_links_with_every_pixel_program_it_can_meet)
std::string name;
std::string hlsl;
SDL_GPUShader * shader;
- bool normal_mapped;
bool engine;
};
std::vector<Built> vertex, pixel;
@@ -338,8 +331,6 @@ TEST(every_vertex_program_links_with_every_pixel_program_it_can_meet)
}
built.shader = SDL3_Create_Shader(device, spirv, cases[i].VertexStage, log);
built.engine = cases[i].Kind == SHADER_CASE_ENGINE;
- built.normal_mapped = cases[i].VertexStage ? writes_normal_mapped_varyings(built.hlsl)
- : built.hlsl.find("ViewPosition : TEXCOORD4") != std::string::npos;
if (built.shader == NULL) {
CHECK(false);
continue;
@@ -365,7 +356,6 @@ TEST(every_vertex_program_links_with_every_pixel_program_it_can_meet)
target.format = SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM;
for (size_t p = 0; p < pixel.size(); ++p) {
- if (pixel[p].normal_mapped && !vertex[v].normal_mapped) continue;
if (vertex[v].engine && pixel[p].engine) continue; // the game never draws that pair
++pairs;
SDL_GPUGraphicsPipelineCreateInfo info;
diff --git a/GeneralsMD/Code/Tests/test_ww3d2.cpp b/GeneralsMD/Code/Tests/test_ww3d2.cpp
index 56aa1b737..6f922d8bc 100644
--- a/GeneralsMD/Code/Tests/test_ww3d2.cpp
+++ b/GeneralsMD/Code/Tests/test_ww3d2.cpp
@@ -1729,24 +1729,3 @@ TEST(sorting_depth_key_orders_the_way_the_depths_do)
/* the same depth twice is the same key, which is what keeps equal depths in pooled order */
CHECK_EQ( SortingRendererClass::_Depth_Sort_Key( 3.25f ), SortingRendererClass::_Depth_Sort_Key( 3.25f ) );
}
-
-// ---------------------------------------------------------------------------------------------
-// A building's damage states are separate low resolution textures, and their normal maps drew the
-// damaged walls as marble. Which names count as one decides which textures lose the relief.
-// ---------------------------------------------------------------------------------------------
-#include "texture.h"
-
-TEST(damage_state_textures_are_told_apart_by_their_suffix)
-{
- CHECK( Texture_Name_Is_Damage_State( "ubarfrccmd_d.dds" ) );
- CHECK( Texture_Name_Is_Damage_State( "ubarfrccmd_E.tga" ) );
- CHECK( Texture_Name_Is_Damage_State( "abbarracks_dn.dds" ) );
- CHECK( Texture_Name_Is_Damage_State( "abbarracks_dsg.dds" ) );
- CHECK( Texture_Name_Is_Damage_State( "cbhouse_esn" ) );
-
- CHECK( !Texture_Name_Is_Damage_State( "ubarfrccmd.dds" ) );
- CHECK( !Texture_Name_Is_Damage_State( "ubarfrccmd_n.dds" ) );
- CHECK( !Texture_Name_Is_Damage_State( "ubarfrccmd_sng.dds" ) );
- CHECK( !Texture_Name_Is_Damage_State( "avcrusader_tread.dds" ) );
- CHECK( !Texture_Name_Is_Damage_State( "cbtree_dead.dds" ) );
-}
diff --git a/GeneralsMD/Code/Tests/w3d_view/w3d_view.cpp b/GeneralsMD/Code/Tests/w3d_view/w3d_view.cpp
index 5abfda149..c43358cc6 100644
--- a/GeneralsMD/Code/Tests/w3d_view/w3d_view.cpp
+++ b/GeneralsMD/Code/Tests/w3d_view/w3d_view.cpp
@@ -260,7 +260,7 @@ SDL_GPUShader *generatedShader(SDL_GPUDevice *device, const std::string &hlsl, b
// The mesh draw's fixed-function state, as W3D sets it for a lit, textured, uncoloured mesh.
VertexPipelineDescription meshVertexState()
{
- VertexPipelineDescription description = VertexPipelineDescription(); // zero, and NormalMapped false
+ VertexPipelineDescription description = VertexPipelineDescription(); // zero, and the flags false
description.FVF = FF_FVF_XYZ | FF_FVF_NORMAL | FF_FVF_TEX1;
description.LightingEnabled = true;
description.LightCount = 1;
@@ -294,7 +294,6 @@ CombinerDescription meshPixelState(bool alphaTest)
memset(&description.PixelPipeline, 0, sizeof(description.PixelPipeline));
description.PixelPipeline.AlphaTestEnabled = alphaTest;
description.PixelPipeline.AlphaFunction = FF_CMP_GREATEREQUAL;
- description.NormalMapped = false;
description.ShadowReceiving = false;
return description;
}
diff --git a/GeneralsMD/Code/Tools/vendor.ps1 b/GeneralsMD/Code/Tools/vendor.ps1
index 19acaa08a..b720e61d6 100644
--- a/GeneralsMD/Code/Tools/vendor.ps1
+++ b/GeneralsMD/Code/Tools/vendor.ps1
@@ -185,8 +185,8 @@ function Install-Nanosvg {
Step "nanosvg -> Libraries\Source\nanosvg"
}
-# --- The fork's own upscaled art: every 3D texture at twice its size, the normal maps the models
-# are lit through, and the ground. Not in git - ReforgedTextures.big alone is a gigabyte, ten times
+# --- The fork's own upscaled art: every 3D texture at twice its size, and the ground. Not in git -
+# ReforgedTextures.big alone is a gigabyte, ten times
# what GitHub takes in a file, and LFS in a fork is billed to the parent repository.
#
# It comes from the release channel, the same place a player's launcher takes it from, and the
@@ -204,7 +204,10 @@ function Install-Nanosvg {
#
# With neither, the step is skipped: the game plays at the textures it shipped with, and
# experiments/doku-upscale is where the art is made.
-$artPattern = 'Reforged.*\.big$'
+#
+# ReforgedNormals.big, the generated normal maps, is left out: the game stopped reading them on
+# 2026-10-06, and a channel release from before that still lists the archive.
+$artPattern = 'Reforged(?!Normals).*\.big$'
$artRelease = 'https://github.com/olcayseygan/CnCGeneralsZH-Reforged/releases/download/art-latest'
function Get-ChannelUrl {
@@ -244,7 +247,7 @@ function Get-ArtFromRelease {
} catch {
return @()
}
- @($manifest.files | ForEach-Object {
+ @($manifest.files | Where-Object { $_.name -match $artPattern } | ForEach-Object {
[pscustomobject]@{
name = $_.name
url = "$artRelease/$($_.name)"
diff --git a/GeneralsMD/Code/Tools/vendor.sh b/GeneralsMD/Code/Tools/vendor.sh
index f204f7cae..0d27b80e7 100755
--- a/GeneralsMD/Code/Tools/vendor.sh
+++ b/GeneralsMD/Code/Tools/vendor.sh
@@ -396,8 +396,8 @@ install_gamespy_unix_patch() {
# pin a choice that C4 has not made, and M1 is a headless build that links neither binkvideo nor
# milesaudio, so nothing before M2 needs it.
-# --- The fork's own upscaled art: every 3D texture at twice its size, the normal maps the models
-# are lit through, and the ground. Not in git - ReforgedTextures.big alone is a gigabyte, ten times
+# --- The fork's own upscaled art: every 3D texture at twice its size, and the ground. Not in git -
+# ReforgedTextures.big alone is a gigabyte, ten times
# what GitHub takes in a file, and LFS in a fork is billed to the parent repository.
#
# It comes from the release channel, the same place a player's launcher takes it from, and the
@@ -415,7 +415,10 @@ install_gamespy_unix_patch() {
#
# With neither, the step is skipped: the game plays at the textures it shipped with, and
# experiments/doku-upscale is where the art is made.
-art_pattern='Reforged.*\.big$'
+#
+# ReforgedNormals.big, the generated normal maps, is left out: the game stopped reading them on
+# 2026-10-06, and a channel release from before that still lists the archive.
+art_pattern='Reforged(?!Normals).*\.big$'
art_release='https://github.com/olcayseygan/CnCGeneralsZH-Reforged/releases/download/art-latest'
# --- litehtml 0.10, the whole repository: the HTML and CSS layout engine behind the pages upstream
@@ -708,11 +711,12 @@ get_art_from_release() {
local manifest
if ! manifest=$(curl -fsSL "$art_release/art.json" 2>/dev/null); then return 0; fi
printf '%s' "$manifest" | python3 -c '
-import json, sys
-base = sys.argv[1]
+import json, re, sys
+base, pattern = sys.argv[1], re.compile(sys.argv[2])
for f in json.load(sys.stdin)["files"]:
- print("\t".join([f["name"], base + "/" + f["name"], str(f["size"]), f["sha256"]]))
-' "$art_release"
+ if pattern.search(f["name"]):
+ print("\t".join([f["name"], base + "/" + f["name"], str(f["size"]), f["sha256"]]))
+' "$art_release" "$art_pattern"
}
install_art() {