Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Generals/Code/GameEngine/Include/GameClient/CommandXlat.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ enum FilterTypes CPP_11(: Int)
FT_VIEW_BW_FILTER, //filter to apply a black & white filter to the screen.
FT_VIEW_MOTION_BLUR_FILTER, //filter to apply motion blur filter to screen.
FT_VIEW_CROSSFADE, ///<filter to apply a cross blend between previous/current views.
FT_VIEW_BRIGHTNESS_FILTER, //filter to apply brightness/gamma adjustment to the screen.
FT_MAX
};

Expand All @@ -101,7 +102,8 @@ enum FilterModes CPP_11(: Int)
FM_VIEW_MB_OUT_SATURATE, // Motion blur filter out saturated blur
FM_VIEW_MB_END_PAN_ALPHA, // Moton blur on screen pan (for camera tracks object mode)


// These apply to FT_VIEW_BRIGHTNESS_FILTER
FM_VIEW_BRIGHTNESS_ADJUST, // Brightness/gamma adjustment

// NOTE: This has to be the last entry in this enum.
// Add new entries before this one. jba.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,17 @@ static void saveOptions( void )
{ TheWritableGlobalData->m_displayGamma = gammaval;
TheDisplay->setGamma(TheGlobalData->m_displayGamma,0.0f, 1.0f, FALSE);
}

// TheSuperHackers @feature bobtista 11/02/2025 Map slider value to GenTool brightness range (-128 to +256)
// Slider: 0=darkest, 50=neutral, 100=brightest
// Formula: brightness = (val - 50) * 7.68, clamped to [-128, 256]
Int brightness = static_cast<Int>((val - 50) * 7.68f);
if (brightness < -128) brightness = -128;
if (brightness > 256) brightness = 256;

// Apply brightness to post-processing filter
extern void setBrightnessFilterValue(Int value); // Forward declaration
setBrightnessFilterValue(brightness);
}

//-------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions Generals/Code/GameEngineDevice/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ set(GAMEENGINEDEVICE_SRC
Source/W3DDevice/GameClient/W3DPoly.cpp
Source/W3DDevice/GameClient/W3DRoadBuffer.cpp
Source/W3DDevice/GameClient/W3DScene.cpp
Source/W3DDevice/GameClient/W3DBrightnessFilter.cpp
Source/W3DDevice/GameClient/W3DShaderManager.cpp
Source/W3DDevice/GameClient/W3DShroud.cpp
Source/W3DDevice/GameClient/W3DStatusCircle.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2025 //
// //
////////////////////////////////////////////////////////////////////////////////

// FILE: W3DBrightnessFilter.h /////////////////////////////////////////////////
//
// Brightness adjustment post-processing filter
// Implements GenTool-style brightness control (-128 to +256 range)
// - Range 1-128: lifts black level linearly
// - Range 129-256: lifts brightness while preserving black level
//
// Author: @bobtista, November 2025
//
///////////////////////////////////////////////////////////////////////////////

#pragma once

#include "W3DShaderManager.h"

/*========= ScreenBrightnessFilter =============================================================*/
/// Applies brightness/gamma adjustment to the viewport using pixel shaders
class ScreenBrightnessFilter : public W3DFilterInterface
{
public:
virtual Int set(FilterModes mode); ///<setup shader for the specified rendering pass.
virtual Int init(void); ///<perform any one time initialization and validation
virtual void reset(void); ///<do any custom resetting necessary to bring W3D in sync.
virtual Int shutdown(void); ///<release resources used by shader
virtual Bool preRender(Bool &skipRender, CustomScenePassModes &scenePassMode); ///< Set up at start of render.
virtual Bool postRender(FilterModes mode, Coord2D &scrollDelta, Bool &doExtraRender); ///< Called after render.
virtual Bool setup(FilterModes mode); ///< Called when the filter is started.

static void setBrightnessValue(Int value); ///< Set brightness value (-128 to +256, GenTool range)
static Int getBrightnessValue(); ///< Get current brightness value

protected:
static DWORD m_pixelShaderHandle; ///< Handle to pixel shader
static Int m_brightnessValue; ///< Current brightness value (-128 to +256)
static Bool m_isEnabled; ///< Whether brightness adjustment is enabled (disabled when value is 0)
};

/*========= ScreenBrightnessFilterFixedFunction =============================================================*/
/// Fallback brightness filter using fixed-function pipeline for cards without pixel shader support
class ScreenBrightnessFilterFixedFunction : public W3DFilterInterface
{
public:
virtual Int set(FilterModes mode);
virtual Int init(void);
virtual void reset(void);
virtual Int shutdown(void);
virtual Bool preRender(Bool &skipRender, CustomScenePassModes &scenePassMode);
virtual Bool postRender(FilterModes mode, Coord2D &scrollDelta, Bool &doExtraRender);
virtual Bool setup(FilterModes mode);

static void setBrightnessValue(Int value);
static Int getBrightnessValue();

protected:
static Int m_brightnessValue;
static Bool m_isEnabled;
};

Loading
Loading