Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(w3ddevice): internal hdr tone mapping keeps fire's colour, as an option
Olcay Seyganb4d58131f975
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8a99ff0e3..b0aff9280 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,10 @@ found and fixed, EA's own, not port damage.**---+## Fire keeps its colour++- Internal HDR Tone Mapping, under Options, Effects, is a new setting, off by default until it has been played. The name is exact: the game's picture has held light past white for a long time, then squeezed nearly all of it into one white on the way out, so a Strategy Center going up was a blown patch with no shape. With this on that fireball stays orange and yellow, a night fire shows its flame tongue, and the white heart of a nuke shrinks, about 54,000 near-white pixels down to about 24,000 in the same shot. Team colours hold a little more colour, and ground lit by a blast leans more orange. Ground and walls away from a fire do not change. Your monitor still gets a normal image: an HDR screen gets no HDR signal, and no HDR screen has seen this. In a battle of three armies and three superweapons the graphics card's frame reads 7.95 ms on and 7.78 and 8.12 ms off, which is no cost anyone can measure. The Direct3D 9 picture and Classic Graphics keep the old look.+## Tanks sit on the ground- Ambient Occlusion, under Options, Effects, is a new setting, off by default until it has been played. EA gave a unit one shadow, the sun's, so on its shaded side a tank met the sand with nothing between them and read as hovering. Now the ground at the tracks of a tank on Golden Oasis loses about 40% of its light and has it all back 130 pixels out, the foot of a War Factory's wall and the crease under a turret go dark the same way, and open ground stays exactly as it was. The water and the fog of war stay out of it. In a battle of three armies and three superweapons the graphics card's frame goes from 7.9 ms to 8.2 ms. The Direct3D 9 picture and Classic Graphics keep the old look.diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex e8060b1e7..bd39dbd5d 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -1532,6 +1532,14 @@ TOOLTIP:AmbientOcclusion"Corners and the ground under what stands on it go darker, so a tank sits on the sand instead of hovering over it. Water and the fog of war stay out of it. Direct3D 11 only, and off under Classic Graphics. Applies when you press Accept."END+GUI:InternalHdr+"Internal HDR Tone Mapping"+END++TOOLTIP:InternalHdr+"Fire, blasts and lasers past white keep their colour on the way to your screen instead of ending in one flat white, and team colours hold a little more of theirs. Ground and walls away from a fire stay as they were. This is inside the game's picture: your monitor still gets a normal image, and an HDR monitor gets no HDR signal. Direct3D 11 only, and off under Classic Graphics. Applies when you press Accept."+END+GUI:FormationDrag"Drag Out A Formation"ENDdiff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex ff6d2f779..402557a9c 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -15925,6 +15925,14 @@ TOOLTIP:AmbientOcclusion"Köşeler ve bir şeyin üstünde durduğu zemin koyulaşır, böylece tank kumun üstünde uçuyormuş gibi değil kumda duruyormuş gibi görünür. Su ve savaş sisi bundan etkilenmez. Yalnızca Direct3D 11 ile, Klasik Grafikler açıkken kapalıdır. Kabul Et'e basınca uygulanır."END+GUI:InternalHdr+"Dahili HDR Ton Eşleme"+END++TOOLTIP:InternalHdr+"Ateş, patlama ve lazerler beyazı geçince ekrana düz beyaz olarak gelmek yerine renklerini korur, takım renkleri de rengini biraz daha iyi tutar. Ateşten uzak zemin ve duvarlar olduğu gibi kalır. Bu oyunun kendi görüntüsünün içindedir: monitörünüz yine normal görüntü alır, HDR monitöre HDR sinyali gitmez. Yalnızca Direct3D 11 ile, Klasik Grafikler açıkken kapalıdır. Kabul Et'e basınca uygulanır."+END+GUI:FormationDrag"Sürükleyerek Düzen Kur"ENDdiff --git a/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd b/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wndindex 4d09c8459..6cb564e46 100644--- a/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd+++ b/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd@@ -7001,6 +7001,53 @@ WINDOWWINDOWWINDOWTYPE = CHECKBOX;SCREENRECT = UPPERLEFT: 288 350, BOTTOMRIGHT: 512 374, CREATIONRESOLUTION: 800 600;+ NAME = "OptionsMenu.wnd:CheckInternalHdr";+ STATUS = ENABLED+IMAGE+BORDER;+ STYLE = CHECKBOX+MOUSETRACK;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 14, BOLD: 0;+ HEADERTEMPLATE = "MinorTitle";+ TOOLTIPTEXT = "TOOLTIP:InternalHdr";+ TOOLTIPDELAY = -1;+ TEXT = "GUI:InternalHdr";+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 186 255 12 255, HILITEBORDER: 0 0 0 255;+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: Active-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,+ IMAGE: Active-Checked, COLOR: 0 0 255 255, BORDERCOLOR: 128 128 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: Disabled-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 192 192 192 255,+ IMAGE: Disabled-Checked, COLOR: 64 64 64 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 255, BORDERCOLOR: 128 255 128 255,+ IMAGE: Active-HiLighted, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,+ IMAGE: Active-Checked, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ END+ CHILD+ WINDOW+ WINDOWTYPE = CHECKBOX;+ SCREENRECT = UPPERLEFT: 288 378, BOTTOMRIGHT: 512 402, CREATIONRESOLUTION: 800 600;NAME = "OptionsMenu.wnd:CheckExtraAnimations";STATUS = ENABLED+IMAGE+BORDER;STYLE = CHECKBOX+MOUSETRACK;@@ -7047,7 +7094,7 @@ WINDOWCHILDWINDOWWINDOWTYPE = CHECKBOX;- SCREENRECT = UPPERLEFT: 288 378, BOTTOMRIGHT: 512 402, CREATIONRESOLUTION: 800 600;+ SCREENRECT = UPPERLEFT: 288 406, BOTTOMRIGHT: 512 430, CREATIONRESOLUTION: 800 600;NAME = "OptionsMenu.wnd:CheckTreeSway";STATUS = ENABLED+IMAGE+BORDER;STYLE = CHECKBOX+MOUSETRACK;@@ -7094,7 +7141,7 @@ WINDOWCHILDWINDOWWINDOWTYPE = CHECKBOX;- SCREENRECT = UPPERLEFT: 288 406, BOTTOMRIGHT: 512 430, CREATIONRESOLUTION: 800 600;+ SCREENRECT = UPPERLEFT: 288 434, BOTTOMRIGHT: 512 458, CREATIONRESOLUTION: 800 600;NAME = "OptionsMenu.wnd:CheckBehindBuilding";STATUS = ENABLED+IMAGE+BORDER;STYLE = CHECKBOX+MOUSETRACK;diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex 0d23bb097..cf6c305b4 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -710,6 +710,7 @@ public:Bool m_firelight; ///< "Firelight": flames light the ground, walls and units around them (Direct3D 11, client only)Bool m_hemiAmbient; ///< "HemiAmbient": models take the ambient from the sky above and the ground below (Direct3D 11, client only)Bool m_ambientOcclusion; ///< "AmbientOcclusion": corners and the ground under what stands on it darken, half size in world units (Direct3D 11, client only)+ Bool m_internalHdr; ///< "InternalHdr": what passes white in the half float scene keeps its colour on the way to eight bits; no HDR monitor output (Direct3D 11, client only)Int m_maxParticleCount; ///< maximum number of particles that can existInt m_maxFieldParticleCount; ///< maximum number of field-type particles that can exist (roughly)diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex 8f55f126b..7fee9075f 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -1139,6 +1139,7 @@ GlobalData::GlobalData()m_firelight = FALSE;m_hemiAmbient = FALSE;m_ambientOcclusion = FALSE;+ m_internalHdr = FALSE;m_horizontalScrollSpeedFactor = 1.0;m_verticalScrollSpeedFactor = 1.0;diff --git a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cppindex 9c9f098d5..54a4be747 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp@@ -146,6 +146,7 @@ OPTION_BOOL_ACCESSORS( m_groundMarks )OPTION_BOOL_ACCESSORS( m_firelight )OPTION_BOOL_ACCESSORS( m_hemiAmbient )OPTION_BOOL_ACCESSORS( m_ambientOcclusion )+OPTION_BOOL_ACCESSORS( m_internalHdr )OPTION_INT_ACCESSORS( m_shadowQuality )OPTION_INT_ACCESSORS( m_graphicsQuality )@@ -643,6 +644,13 @@ const OptionDef TheOptionCatalog[] =OPTION_BOOL, APPLY_LIVE, 0, 1,get_m_ambientOcclusion, set_m_ambientOcclusion },+ // What passes white keeps its colour on the way to the eight bit screen; no HDR monitor output. The+ // post chain is told every frame. Classic graphics has no half float scene and -d3d9 no chain, and+ // no row in the quality table: an opt-in until it has been seen. On Options > Effects.+ { "InternalHdr", OPT_WND( "CheckInternalHdr" ), "GUI:InternalHdr",+ OPTION_BOOL, APPLY_LIVE, 0, 1,+ get_m_internalHdr, set_m_internalHdr },+// The size of the sun's depth map. The shadow pass asks for it every frame and the backend makes// the map again when the size changes, so a new level shows on the next frame. On Options >// Effects. Classic graphics and -d3d9 draw no map at all.diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cppindex bb904115c..ededad83d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp@@ -2961,7 +2961,7 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )// three looks only the Direct3D 11 picture draws; under -d3d9 their boxes keep the saved value, greyedif( !TheGlobalData->m_direct3D11 ){- static const char *const direct3D11Only[] = { "MapLight", "TeamGlow", "WaterFoam", "GroundMarks", "Firelight", "HemiAmbient", "AmbientOcclusion" };+ static const char *const direct3D11Only[] = { "MapLight", "TeamGlow", "WaterFoam", "GroundMarks", "Firelight", "HemiAmbient", "AmbientOcclusion", "InternalHdr" };for( Int i = 0; i < (Int)( sizeof( direct3D11Only ) / sizeof( direct3D11Only[ 0 ] ) ); ++i )findOptionWidget( *findOptionDef( direct3D11Only[ i ] ) )->winEnable( FALSE );}diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cppindex b6c158cdb..d1d215ce3 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp@@ -423,6 +423,7 @@ static Int fixedFunctionBloomIntensity(void)const GlowTuning tuning = glowTuning();DX11Post_Set_Bloom(tuning.threshold, tuning.intensity, tuning.additiveGain, tuning.blurPasses);DX11Post_Set_Grade(TheGlobalData->m_lightingStyle == LIGHTING_STYLE_REFORGED ? 1.0f : 0.0f);+ DX11Post_Set_Internal_Hdr(TheGlobalData->m_internalHdr != FALSE);#endifreturn 0;}diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.cppindex 92ddaf704..1527dbc6d 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.cpp+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.cpp@@ -121,6 +121,13 @@ void DX11Post_Set_Grade(float amount)GradeAmount = (amount < 0.0f) ? 0.0f : (amount > 1.0f) ? 1.0f : amount;}+static bool InternalHdr = false;++void DX11Post_Set_Internal_Hdr(bool on)+{+ InternalHdr = on;+}+static float HazeColour[3] = { 0.0f, 0.0f, 0.0f };static float HazeTop = 0.0f;static float HazeThickness = 1.0f;@@ -299,6 +306,35 @@ static const char * const TONE_MAP_SHADER_BODY =" return float4(grade(tone_curve(Source.Sample(Sampler, input.Texture).rgb)), 1.0);\n""}\n";+// Internal HDR Tone Mapping. tone_curve's room runs out fast, a channel at 1.3 is within two percent+// of white, so a fire whose channels all pass that is one flat white however hot it is. Here a pixel+// past white first has its whole colour scaled back, so that its brightest channel sits at one plus a+// share of the doublings it is past white, and then takes tone_curve as any other pixel does. The+// ratio of its channels goes through unchanged, each doubling is a little more channel past the knee,+// so orange climbs through yellow toward white across five or six doublings instead of half of one.+// A pixel with no channel past white is what tone_curve made it, which away from a fire is the ground,+// the walls and nearly all the rest of the art. Team colour stripes do pass white, and so does what a+// glow or the Firelight option lights past it, so those come out more coloured than they did.+//+// Text of its own and not in the prologue: the haze's and the occlusion's programs are keyed in the+// shader cache by a source that takes the prologue in, and this leaves them as they were.+#define WIDE_CURVE_TEXT \+ "static const float WIDE_RISE = 0.3;\n" \+ "float3 wide_curve(float3 colour)\n" \+ "{\n" \+ " float peak = max(colour.r, max(colour.g, colour.b));\n" \+ " if (peak > 1.0) colour *= (1.0 + WIDE_RISE * log2(peak)) / peak;\n" \+ " return tone_curve(colour);\n" \+ "}\n" \+ "\n"++static const char * const TONE_MAP_WIDE_SHADER_BODY =+ WIDE_CURVE_TEXT+ "float4 main(VertexOutput input) : SV_TARGET\n"+ "{\n"+ " return float4(grade(wide_curve(Source.Sample(Sampler, input.Texture).rgb)), 1.0);\n"+ "}\n";+// FXAA, the 2009 shape of it: read the luminance of the four diagonal neighbours and the centre,// leave the pixel alone unless the spread between them says an edge runs through it, work out which// way the edge lies from which pair of corners is brighter, and average along it. Two samples give@@ -779,6 +815,15 @@ static const char * const BLOOM_COMPOSITE_SHADER_BODY =" return float4(grade(tone_curve(scene + glow * Tuning.y)), 1.0);\n""}\n";+static const char * const BLOOM_COMPOSITE_WIDE_SHADER_BODY =+ WIDE_CURVE_TEXT+ "float4 main(VertexOutput input) : SV_TARGET\n"+ "{\n"+ " float3 scene = Source.Sample(Sampler, input.Texture).rgb;\n"+ " float3 glow = Extra.Sample(Sampler, input.Texture).rgb;\n"+ " return float4(grade(wide_curve(scene + glow * Tuning.y)), 1.0);\n"+ "}\n";+// A blast bending the picture, one read per pixel whatever the number of warps: every warp adds// to where the pixel reads from, and the frame is sampled once at the sum.//@@ -943,12 +988,14 @@ DX11PostProcessClass::DX11PostProcessClass(): Device(NULL), VertexShader(NULL), ToneMapShader(NULL)+ , ToneMapWideShader(NULL), SharpenMultisampledShader(NULL), BloomExtractShader(NULL), NearPlane(1.0f), FarPlane(1200.0f), BloomBlurShader(NULL), BloomCompositeShader(NULL)+ , BloomCompositeWideShader(NULL), WarpShader(NULL), SceneOcclusionShader(NULL), HazeShader(NULL)@@ -1031,9 +1078,11 @@ void DX11PostProcessClass::Shutdown()}release_interface(reinterpret_cast<IUnknown **>(&SceneOcclusionShader));release_interface(reinterpret_cast<IUnknown **>(&WarpShader));+ release_interface(reinterpret_cast<IUnknown **>(&BloomCompositeWideShader));release_interface(reinterpret_cast<IUnknown **>(&BloomCompositeShader));release_interface(reinterpret_cast<IUnknown **>(&BloomBlurShader));release_interface(reinterpret_cast<IUnknown **>(&BloomExtractShader));+ release_interface(reinterpret_cast<IUnknown **>(&ToneMapWideShader));release_interface(reinterpret_cast<IUnknown **>(&ToneMapShader));release_interface(reinterpret_cast<IUnknown **>(&SharpenMultisampledShader));for (unsigned index = 0; index < DX11_POST_SIMPLE_EFFECTS; ++index) {@@ -1112,12 +1161,15 @@ bool DX11PostProcessClass::Create_Shaders()}return compile_pixel_shader(compiler, device, TONE_MAP_SHADER_BODY, &ToneMapShader)+ && compile_pixel_shader(compiler, device, TONE_MAP_WIDE_SHADER_BODY, &ToneMapWideShader)&& compile_pixel_shader(compiler, device, SHARPEN_MULTISAMPLED_SHADER_BODY,&SharpenMultisampledShader)&& compile_pixel_shader(compiler, device, BLOOM_EXTRACT_SHADER_BODY, &BloomExtractShader)&& compile_pixel_shader(compiler, device, BLOOM_BLUR_SHADER_BODY, &BloomBlurShader)&& compile_pixel_shader(compiler, device, BLOOM_COMPOSITE_SHADER_BODY,&BloomCompositeShader)+ && compile_pixel_shader(compiler, device, BLOOM_COMPOSITE_WIDE_SHADER_BODY,+ &BloomCompositeWideShader)&& compile_pixel_shader(compiler, device, WARP_SHADER_BODY, &WarpShader)&& compile_pixel_shader(compiler, device, AO_SCENE_SHADER_BODY, &SceneOcclusionShader);}@@ -1707,7 +1759,7 @@ ID3D11ShaderResourceView * DX11PostProcessClass::Run_Bloom(ID3D11RenderTargetVie}}- pass.Shader = BloomCompositeShader;+ pass.Shader = InternalHdr ? BloomCompositeWideShader : BloomCompositeShader;pass.Source = scene;pass.Extra = BloomTargets[source].Resource;pass.Destination = destination;@@ -1753,7 +1805,7 @@ bool DX11PostProcessClass::Finish(const DX11PostEffect * effects, unsigned count// chain keeps its shape so turning it back on costs no rebuild of the targets.PassSetup tone;memset(&tone, 0, sizeof(tone));- tone.Shader = ToneMapShader;+ tone.Shader = InternalHdr ? ToneMapWideShader : ToneMapShader;tone.Source = scene;tone.Destination = bloom_destination;tone.DestinationWidth = Width;diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.hindex a224208da..78b83c5e5 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.h+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11post.h@@ -122,6 +122,15 @@ float DX11Post_Additive_Gain();// does not start with bloom keeps its scene in eight bits and is never graded.void DX11Post_Set_Grade(float amount);+// The Internal HDR Tone Mapping option: the half float scene comes down to eight bits through+// wide_curve instead of tone_curve, wherever a match's frame does (the bloom composite and the plain+// tone pass), so what was past white keeps its colour and its order instead of ending in one white.+// A pixel with no channel past white comes out as it did. Off, the default and what the tests start+// from, runs the old programs. The frame on the monitor is still eight bits: this is no HDR output.+// The game sets it every frame from the option. A chain that does not start with bloom keeps its+// scene in eight bits and has nothing to map.+void DX11Post_Set_Internal_Hdr(bool on);+// The Warm Light option's ground haze (MapLight): a pale layer lying in the low ground,// laid over the opaque world before the particles out of the frame's depth taken back to world// height. Top is the world height the haze thins out to nothing at, thickness how far below that@@ -316,10 +325,12 @@ private:ID3D11VertexShader * VertexShader;ID3D11PixelShader * PixelShaders[DX11_POST_SIMPLE_EFFECTS];ID3D11PixelShader * ToneMapShader;+ ID3D11PixelShader * ToneMapWideShader; // the tone pass under Internal HDR Tone MappingID3D11PixelShader * SharpenMultisampledShader; // the sharpen pass over a multisampled sceneID3D11PixelShader * BloomExtractShader;ID3D11PixelShader * BloomBlurShader;ID3D11PixelShader * BloomCompositeShader;+ ID3D11PixelShader * BloomCompositeWideShader; // the composite under Internal HDR Tone MappingID3D11PixelShader * WarpShader;ID3D11PixelShader * SceneOcclusionShader;ID3D11PixelShader * HazeShader;diff --git a/GeneralsMD/Code/Tests/test_dx11post.cpp b/GeneralsMD/Code/Tests/test_dx11post.cppindex 8e4254348..e5ec5563d 100644--- a/GeneralsMD/Code/Tests/test_dx11post.cpp+++ b/GeneralsMD/Code/Tests/test_dx11post.cpp@@ -557,6 +557,64 @@ TEST(dx11post_bloom_keeps_ordinary_levels_and_folds_overbright_to_white)}}+// The blue of one whole frame of colour through the chain. pixel_level reads the first byte of a+// pixel, and the back buffer is blue first.+static int frame_blue(DeviceFixture & fixture, float red, float green, float blue, bool chain)+{+ fixture.Get_Post().Begin_Frame();+ ID3D11RenderTargetView * view = fixture.Get_Post().Scene_View();+ CHECK(view != NULL);+ const float colour[4] = { red, green, blue, 1.0f };+ fixture.Get_Device().Get_Context()->ClearRenderTargetView(view, colour);+ CHECK(chain ? fixture.Get_Post().Run_Chain() : fixture.Get_Post().Copy_Through());+ unsigned pitch = 0;+ unsigned char * result = read_back_buffer(fixture.Get_Device(), pitch);+ CHECK(result != NULL);+ const int level = (result != NULL) ? pixel_level(result, pitch, SURFACE_SIZE / 2, SURFACE_SIZE / 2) : -1;+ delete [] result;+ return level;+}++TEST(dx11post_internal_hdr_keeps_colour_past_white_and_moves_nothing_under_it)+{+ DeviceFixture fixture;+ if (!fixture.Create()) {+ printf("skip: no Direct3D 11 device on this machine\n");+ return;+ }++ const DX11PostEffect chain[] = { DX11_POST_BLOOM };+ fixture.Get_Post().Set_Chain(chain, 1);++ // A fire at eight times white, with the option off: every channel is past the curve's room, so+ // it arrives white, blue and all. A pale wall under white is the off figure to hold.+ const int offFire = frame_blue(fixture, 8.0f, 4.0f, 1.6f, true);+ const int offWall = frame_blue(fixture, 0.95f, 0.95f, 0.9f, true);+ CHECK_EQ(255, offFire);++ DX11Post_Set_Internal_Hdr(true);++ // The same fire stays orange, a hotter one is whiter than it, and white-hot still reaches white.+ // Art under white comes out to the bit as it did.+ const int onFire = frame_blue(fixture, 8.0f, 4.0f, 1.6f, true);+ const int onHotter = frame_blue(fixture, 32.0f, 16.0f, 6.4f, true);+ CHECK(onFire < 160);+ CHECK(onHotter > onFire);+ CHECK(frame_blue(fixture, 64.0f, 64.0f, 64.0f, true) >= 250);+ CHECK_EQ(offWall, frame_blue(fixture, 0.95f, 0.95f, 0.9f, true));++ // The plain tone pass, with the Glow option off, takes the same curve.+ DX11Post_Set_Bloom(1.0f, 0.0f, 1.0f, 2);+ CHECK(frame_blue(fixture, 8.0f, 4.0f, 1.6f, true) < 160);+ DX11Post_Set_Bloom(1.0f, 1.5f, 1.0f, 2);++ // A frame with no match on it, a loading screen with its interface in the scene, keeps the old one.+ CHECK(frame_blue(fixture, 8.0f, 4.0f, 1.6f, false) >= 250);++ DX11Post_Set_Internal_Hdr(false);+ CHECK_EQ(offFire, frame_blue(fixture, 8.0f, 4.0f, 1.6f, true));+}+TEST(dx11post_bloom_spreads_light_past_the_pixels_that_carry_it){DeviceFixture fixture;diff --git a/GeneralsMD/Code/Tools/optionsmenu_layout.py b/GeneralsMD/Code/Tools/optionsmenu_layout.pyindex 8965e436a..43a1fde14 100644--- a/GeneralsMD/Code/Tools/optionsmenu_layout.py+++ b/GeneralsMD/Code/Tools/optionsmenu_layout.py@@ -242,6 +242,7 @@ NEW_CONTROLS = [(CHECK, "CheckFirelight", "GUI:Firelight"),(CHECK, "CheckHemiAmbient", "GUI:HemiAmbient"),(CHECK, "CheckAmbientOcclusion", "GUI:AmbientOcclusion"),+ (CHECK, "CheckInternalHdr", "GUI:InternalHdr"),(LABEL, "LabelGraphicsQuality", "GUI:GraphicsQuality"),(SLIDER, "SliderGraphicsQuality", None),]@@ -384,6 +385,7 @@ GROUP_LAYOUT = [("check", "CheckGroundMarks"),("check", "CheckHemiAmbient"),("check", "CheckAmbientOcclusion"),+ ("check", "CheckInternalHdr"),("check", "CheckExtraAnimations"),("check", "CheckTreeSway"),("check", "CheckBehindBuilding")]),