Skip to content

Commit

Permalink
ycbcr colour filter
Browse files Browse the repository at this point in the history
  • Loading branch information
aap committed Sep 19, 2017
1 parent 0e1058b commit 5566d42
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 97 deletions.
8 changes: 5 additions & 3 deletions src/buildingPipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum {

};

float &CCoronas__LightsMult = *(float*)0x8D4B5C;
bool &CWeather__LightningFlash = *(bool*)0xC812CC;
WRAPPER bool CPostEffects__IsVisionFXActive(void) { EAXJMP(0x7034F0); }

Expand All @@ -38,10 +39,11 @@ CustomBuildingPipeline__Update(void)
{
CustomBuildingPipeline__Update_orig();


// do *not* use pAmbient light. It causes so many problems
buildingAmbient.red = CTimeCycle_GetAmbientRed();
buildingAmbient.green = CTimeCycle_GetAmbientGreen();
buildingAmbient.blue = CTimeCycle_GetAmbientBlue();
buildingAmbient.red = CTimeCycle_GetAmbientRed()*CCoronas__LightsMult;
buildingAmbient.green = CTimeCycle_GetAmbientGreen()*CCoronas__LightsMult;
buildingAmbient.blue = CTimeCycle_GetAmbientBlue()*CCoronas__LightsMult;

if(config->lightningIlluminatesWorld && CWeather__LightningFlash && !CPostEffects__IsVisionFXActive())
buildingAmbient = { 1.0, 1.0, 1.0, 0.0 };
Expand Down
12 changes: 6 additions & 6 deletions src/debugmenu_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ inline bool DebugMenuLoad(void)
{
if(gDebugMenuAPI.isLoaded)
return true;
HMODULE mod = LoadLibrary("debugmenu.dll");
HMODULE mod = LoadLibraryA("debugmenu");
if(mod == 0){
char modulePath[MAX_PATH];
HMODULE dllModule;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR)&gDebugMenuAPI, &dllModule);
GetModuleFileName(dllModule, modulePath, MAX_PATH);
char *p = strrchr(modulePath, '\\');
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCTSTR)&gDebugMenuAPI, &dllModule);
GetModuleFileNameA(dllModule, modulePath, MAX_PATH);
char *p = strchr(modulePath, '\\');
if(p) p[1] = '\0';
strcat(modulePath, "debugmenu.dll");
mod = LoadLibrary(modulePath);
strcat(modulePath, "debugmenu");
mod = LoadLibraryA(modulePath);
}
if(mod == 0)
return false;
Expand Down
33 changes: 25 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ resetValues(void)
CPostEffects::m_InfraredVisionGrainStrength = 0x40;
CPostEffects::m_NightVisionGrainStrength = 0x30;
}

CPostEffects::m_bYCbCrFilter = config->bYCbCrFilter;
CPostEffects::m_lumaScale = config->lumaScale;
CPostEffects::m_lumaOffset = config->lumaOffset;
CPostEffects::m_crScale = config->crScale;
CPostEffects::m_crOffset = config->crOffset;
CPostEffects::m_cbScale = config->cbScale;
CPostEffects::m_cbOffset = config->cbOffset;

// night vision ambient green
// not if this is the correct switch, maybe ps2ModulateWorld?
//if(config->nightVision == 0)
Expand Down Expand Up @@ -770,6 +779,14 @@ readIni(int n)
}
c->neoBloodDrops = readint(cfg.get("SkyGfx", "neoBloodDrops", ""), 0);
fixPcCarLight = readint(cfg.get("SkyGfx", "fixPcCarLight", ""), 0);

c->bYCbCrFilter = readint(cfg.get("SkyGfx", "YCbCrCorrection", ""), 0);
c->lumaScale = readfloat(cfg.get("SkyGfx", "lumaScale", ""), 219.0f/255.0f);
c->lumaOffset = readfloat(cfg.get("SkyGfx", "lumaOffset", ""), 16.0f/255.0f);
c->cbScale = readfloat(cfg.get("SkyGfx", "CbScale", ""), 1.23f);
c->cbOffset = readfloat(cfg.get("SkyGfx", "CbOffset", ""), 0.0f);
c->crScale = readfloat(cfg.get("SkyGfx", "CrScale", ""), 1.23f);
c->crOffset = readfloat(cfg.get("SkyGfx", "CrOffset", ""), 0.0f);
}

void
Expand Down Expand Up @@ -903,14 +920,6 @@ installMenu(void)
DebugMenuEntrySetWrap(e, true);
DebugMenuAddCmd("SkyGFX", "Reload Inis", reloadAllInis);

DebugMenuAddVarBool8("YCbCr", "Enable colour filter", (int8_t*)&CPostEffects::m_bYCbCrFilter, nil);
DebugMenuAddVar("YCbCr", "Y scale", &CPostEffects::m_lumaScale, nil, 0.004f, 0.0f, 10.0f);
DebugMenuAddVar("YCbCr", "Y offset", &CPostEffects::m_lumaOffset, nil, 0.004f, -1.0f, 1.0f);
DebugMenuAddVar("YCbCr", "Cb scale", &CPostEffects::m_cbScale, nil, 0.004f, 0.0f, 10.0f);
DebugMenuAddVar("YCbCr", "Cb offset", &CPostEffects::m_cbOffset, nil, 0.004f, -1.0f, 1.0f);
DebugMenuAddVar("YCbCr", "Cr scale", &CPostEffects::m_crScale, nil, 0.004f, 0.0f, 10.0f);
DebugMenuAddVar("YCbCr", "Cr offset", &CPostEffects::m_crOffset, nil, 0.004f, -1.0f, 1.0f);

menu.dualPassGlobal = DebugMenuAddVarBool32("SkyGFX", "Dual-pass Global", &config->dualPassGlobal, toggledDual);
menu.ps2ModulateGlobal = DebugMenuAddVarBool32("SkyGFX", "PS2-modulate Global", &config->ps2ModulateGlobal, toggledModulation);
if(iCanHasbuildingPipe){
Expand Down Expand Up @@ -959,6 +968,14 @@ installMenu(void)
menu.grainFilter = DebugMenuAddVar("SkyGFX|Advanced", "Grain filter", &config->grainFilter, resetValues, 1, 0, 1, ps2pcStr);
DebugMenuEntrySetWrap(menu.grainFilter, true);

DebugMenuAddVarBool8("SkyGFX|ScreenFX", "Enable YCbCr tweak", (int8_t*)&config->bYCbCrFilter, resetValues);
DebugMenuAddVar("SkyGFX|ScreenFX", "Y scale", &config->lumaScale, resetValues, 0.004f, 0.0f, 10.0f);
DebugMenuAddVar("SkyGFX|ScreenFX", "Y offset", &config->lumaOffset, resetValues, 0.004f, -1.0f, 1.0f);
DebugMenuAddVar("SkyGFX|ScreenFX", "Cb scale", &config->cbScale, resetValues, 0.004f, 0.0f, 10.0f);
DebugMenuAddVar("SkyGFX|ScreenFX", "Cb offset", &config->cbOffset, resetValues, 0.004f, -1.0f, 1.0f);
DebugMenuAddVar("SkyGFX|ScreenFX", "Cr scale", &config->crScale, resetValues, 0.004f, 0.0f, 10.0f);
DebugMenuAddVar("SkyGFX|ScreenFX", "Cr offset", &config->crOffset, resetValues, 0.004f, -1.0f, 1.0f);

hasMenu = true;
//void privatepatches(void);
//privatepatches();
Expand Down
1 change: 1 addition & 0 deletions src/neo.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class WaterDrops

static void RegisterSplash(CPlaceable_III *plc, float distance = 20.0f);
static void WaterDrops::RegisterSplash(RwV3d* point, float distance = 20.0f, int duration = 14);
static bool NoDrops(void);
static bool NoRain(void);

// Rendering
Expand Down
Loading

0 comments on commit 5566d42

Please sign in to comment.