From ce04ed7da678bfecbdb90d186b00ba9ea26ff4a5 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 21 Sep 2017 17:14:49 +0200 Subject: [PATCH] raindrop fixes; SAMP fixes; moon phase --- premake5.lua | 5 +- resources/VersionInfo.rc | Bin 2968 -> 2968 bytes src/buildingPipe.cpp | 7 +++ src/gta.cpp | 4 +- src/main.cpp | 126 +++++++++++++++++++++++++++++++++++---- src/neo.h | 12 ++-- src/neoWaterdrops.cpp | 30 ++++------ src/postfx.cpp | 15 +++-- src/skygfx.h | 5 +- src/vehiclePipe.cpp | 17 ++++-- 10 files changed, 168 insertions(+), 53 deletions(-) diff --git a/premake5.lua b/premake5.lua index 36a0e44..7cdcd19 100644 --- a/premake5.lua +++ b/premake5.lua @@ -4,8 +4,8 @@ workspace "skygfx" defines { "rsc_CompanyName=\"aap\"" } defines { "rsc_LegalCopyright=\"\""} - defines { "rsc_FileVersion=\"3.2.0.0\"", "rsc_ProductVersion=\"3.2.0.0\"" } - defines { "rsc_InternalName=\"%{prj.name}\"", "rsc_ProductName=\"%{prj.name}\"", "rsc_OriginalFilename=\"%{prj.name}.asi\"" } + defines { "rsc_FileVersion=\"3.6.0.0\"", "rsc_ProductVersion=\"3.6.0.0\"" } + defines { "rsc_InternalName=\"%{prj.name}\"", "rsc_ProductName=\"%{prj.name}\"", "rsc_OriginalFilename=\"%{prj.name}.dll\"" } defines { "rsc_FileDescription=\"https://github.com/aap\"" } defines { "rsc_UpdateUrl=\"https://github.com/aap/skygfx\"" } @@ -36,6 +36,7 @@ project "skygfx" filter "configurations:Debug" defines { "DEBUG" } symbols "On" + flags { "StaticRuntime" } debugdir "C:/Users/aap/games/gtasa" debugcommand "C:/Users/aap/games/gtasa/gta_sa.exe" postbuildcommands "copy /y \"$(TargetPath)\" \"C:\\Users\\aap\\games\\gtasa\\dlls\\skygfx.dll\"" diff --git a/resources/VersionInfo.rc b/resources/VersionInfo.rc index fdc9b79d7f4aa7e3b231c6f18014ee8a3444d9c3..fedcdc14d67ea74d2c540237169b283310d5b14e 100644 GIT binary patch delta 24 fcmbOsK0|zi7z?X0gARk)WN8*dMzhVnEZ*z@M=b?2 delta 24 fcmbOsK0|zi7z?W*gARkyWN8*dMuW}1EZ*z@M!5wi diff --git a/src/buildingPipe.cpp b/src/buildingPipe.cpp index e1b4c9a..eefd84e 100644 --- a/src/buildingPipe.cpp +++ b/src/buildingPipe.cpp @@ -6,6 +6,7 @@ RxPipeline *buildingPipeline, *buildingDNPipeline; float &CWeather__WetRoads = *(float*)0xC81308; + enum { // common REG_transform = 0, @@ -127,6 +128,8 @@ CCustomBuildingDNPipeline__CustomPipeRenderCB_PS2(RwResEntry *repEntry, void *ob RwMatrix envmat; float transform[16]; + _rwD3D9EnableClippingIfNeeded(object, type); + atomic = (RpAtomic*)object; pipeGetComposedTransformMatrix(atomic, transform); @@ -248,6 +251,8 @@ CCustomBuildingDNPipeline__CustomPipeRenderCB_PC(RwResEntry *repEntry, void *obj atomic = (RpAtomic*)object; + _rwD3D9EnableClippingIfNeeded(object, type); + colorScale = 1.0f; RwD3D9SetPixelShaderConstant(0, &colorScale, 1); @@ -335,6 +340,7 @@ CCustomBuildingDNPipeline__CustomPipeRenderCB_PC(RwResEntry *repEntry, void *obj RwD3D9SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); RwD3D9SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); RwD3D9SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); + } void @@ -348,6 +354,7 @@ CCustomBuildingDNPipeline__CustomPipeRenderCB_Switch(RwResEntry *repEntry, void CCustomBuildingDNPipeline__CustomPipeRenderCB_PC(repEntry, object, type, flags); else CCustomBuildingDNPipeline__CustomPipeRenderCB_PS2(repEntry, object, type, flags); + fixSAMP(); } static RwBool diff --git a/src/gta.cpp b/src/gta.cpp index be989a2..7f7a8af 100644 --- a/src/gta.cpp +++ b/src/gta.cpp @@ -149,4 +149,6 @@ WRAPPER RwFrame *RwFrameUpdateObjects(RwFrame*) { EAXJMP(0x7F0910); } WRAPPER RwFrame *RwFrameSetIdentity(RwFrame*) { EAXJMP(0x7F10B0); } WRAPPER RwMatrix *RwMatrixOrthoNormalize(RwMatrix*, const RwMatrix*) { EAXJMP(0x7F1920); } WRAPPER RwMatrix *RwMatrixTransform(RwMatrix*, const RwMatrix*, RwOpCombineType) { EAXJMP(0x7F25A0); } -WRAPPER RwMatrix *RwMatrixOptimize(RwMatrix*, const RwMatrixTolerance*) { EAXJMP(0x7F17E0); } \ No newline at end of file +WRAPPER RwMatrix *RwMatrixOptimize(RwMatrix*, const RwMatrixTolerance*) { EAXJMP(0x7F17E0); } + +WRAPPER void _rwD3D9EnableClippingIfNeeded(void *object, RwUInt32 type) { EAXJMP(0x756D90); } diff --git a/src/main.cpp b/src/main.cpp index 1d78f4c..458e06f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,6 +18,8 @@ bool iCanHasbuildingPipe = true; bool iCanHasvehiclePipe = true; bool iCanHasSunGlare = true; +int fixingSAMP; + int numConfigs; int currentConfig; Config *config, configs[10]; @@ -26,7 +28,6 @@ int original_bRadiosity = 0; void *grassPixelShader; void *simplePS; void *gpCurrentShaderForDefaultCallbacks; -//void (*TimecycInit)(void) = (void (*)(void))0x5BBAC0; float *gfLaRiotsLightMult = (float*)0x8CD060; float *ambientColors = (float*)0xB7C4A0; @@ -68,11 +69,41 @@ getpath(char *path) return NULL; } +WRAPPER void _rwD3D9RenderStateFlushCache(void) { EAXJMP(0x7FC200); } +// SAMP fucks with the render states directly instead of using RW. Synching the fog states +// before and after rendering and using SAMP graphics restore seems to make things work. +void +fixSAMP(void) +{ + static D3DCAPS9 *Caps=(D3DCAPS9*)0xC9BF00; + static int *FogConvTable=(int*)0x8848FC; + if(fixingSAMP){ + int fog, fogtype; + RwRenderStateGet(rwRENDERSTATEFOGENABLE, &fog); + RwRenderStateGet(rwRENDERSTATEFOGTYPE, &fogtype); + _rwD3D9RenderStateFlushCache(); + RwD3D9SetRenderState(D3DRS_FOGENABLE, fog); + d3d9device->SetRenderState(D3DRS_FOGENABLE, fog); + int table, vertex; + if((Caps->RasterCaps & D3DPRASTERCAPS_FOGTABLE) && (Caps->RasterCaps & D3DPRASTERCAPS_WFOG)){ + table = FogConvTable[fogtype]; + vertex = D3DFOG_NONE; + }else{ + table = D3DFOG_NONE; + vertex = FogConvTable[fogtype]; + } + RwD3D9SetRenderState(D3DRS_FOGTABLEMODE, table); + RwD3D9SetRenderState(D3DRS_FOGVERTEXMODE, vertex); + d3d9device->SetRenderState(D3DRS_FOGTABLEMODE, table); + d3d9device->SetRenderState(D3DRS_FOGVERTEXMODE, vertex); + } +} void D3D9Render(RxD3D9ResEntryHeader *resEntryHeader, RxD3D9InstanceData *instanceData) { + fixSAMP(); if(resEntryHeader->indexBuffer) RwD3D9DrawIndexedPrimitive(resEntryHeader->primType, instanceData->baseIndex, 0, instanceData->numVertices, instanceData->startIndex, instanceData->numPrimitives); else @@ -91,7 +122,7 @@ D3D9RenderDual(int dual, RxD3D9ResEntryHeader *resEntryHeader, RxD3D9InstanceDat RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTION, &alphafunc); if(dual && hasAlpha && zwrite){ RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTIONREF, &alpharef); - RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)128); + RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)config->zwriteThreshold); RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, (void*)rwALPHATESTFUNCTIONGREATEREQUAL); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); D3D9Render(resEntryHeader, instanceData); @@ -224,7 +255,7 @@ grassRenderCallback(RpAtomic *atomic) RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTION, (void*)&alphatest); RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)&alpharef); - RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)128); + RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)config->zwriteThreshold); RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, (void*)rwALPHATESTFUNCTIONGREATEREQUAL); RxPipelineExecute(pipe, atomic, 1); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); @@ -263,7 +294,7 @@ myDefaultCallback(RpAtomic *atomic) if(dodual){ RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTION, (void*)&alphatest); RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)&alpharef); - RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)128); + RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)config->zwriteThreshold); RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, (void*)rwALPHATESTFUNCTIONGREATEREQUAL); RxPipelineExecute(pipe, atomic, 1); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); @@ -521,6 +552,32 @@ CWaterLevel__CalculateWavesForCoordinate_hook(int x, int y, float a3, float a4, } */ +static int alphafunc; +static void setMoonAlphaBlendStates(void){ + RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTION, &alphafunc); + RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, (void*)rwALPHATESTFUNCTIONALWAYS); + RwD3D9SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, 1); + RwD3D9SetRenderState(D3DRS_BLENDOPALPHA, D3DBLENDOP_ADD); + RwD3D9SetRenderState(D3DRS_SRCBLENDALPHA, D3DBLEND_SRCALPHA); + RwD3D9SetRenderState(D3DRS_DESTBLENDALPHA, D3DBLEND_ZERO); +} +static void restoreMoonAlphaBlendStates(void){ + RwD3D9SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, 0); + RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, (void*)alphafunc); +} +void __declspec(naked) renderMoonMask(void) +{ + _asm { + call setMoonAlphaBlendStates + mov eax,0x70D000 + call eax + call restoreMoonAlphaBlendStates + push 0x713C51 + retn + } +} + + void (*CSkidmarks__Render_orig)(void); void CSkidmarks__Render(void) { @@ -540,6 +597,20 @@ InitialiseGame_hook(void) InitialiseGame(); } +void __declspec(naked) selectVM(void) +{ + _asm { + test [esp+0x20],1 + jz window + + push 0x7463B8 + retn + + window: + push 0x7462C5 + retn + } +} @@ -780,6 +851,10 @@ readIni(int n) c->neoBloodDrops = readint(cfg.get("SkyGfx", "neoBloodDrops", ""), 0); fixPcCarLight = readint(cfg.get("SkyGfx", "fixPcCarLight", ""), 0); + c->zwriteThreshold = readint(cfg.get("SkyGfx", "zwriteThreshold", ""), 128); + if(c->zwriteThreshold < 0) c->zwriteThreshold = 0; + if(c->zwriteThreshold > 255) c->zwriteThreshold = 255; + 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); @@ -865,7 +940,15 @@ afterStreamIni(void) X(offBottom) \ X(radiosityFilterPasses) \ X(radiosityRenderPasses) \ - X(radiosityIntensity) + X(radiosityIntensity) \ + X(zwriteThreshold) \ + X(bYCbCrFilter) \ + X(lumaScale) \ + X(lumaOffset) \ + X(cbScale) \ + X(cbOffset) \ + X(crScale) \ + X(crOffset) struct SkyGfxMenu { @@ -943,6 +1026,10 @@ installMenu(void) if(iCanHasNeoDrops){ menu.neoWaterDrops = DebugMenuAddVarBool32("SkyGFX", "Neo Water drops", &config->neoWaterDrops, nil); menu.neoBloodDrops = DebugMenuAddVarBool32("SkyGFX", "Neo-style Blood drops", &config->neoBloodDrops, nil); +#ifdef DEBUG + DebugMenuAddVarBool8("SkyGFX", "Spray Water drops", (int8*)&WaterDrops::sprayWater, nil); + DebugMenuAddVarBool8("SkyGFX", "Spray Blood drops", (int8*)&WaterDrops::sprayBlood, nil); +#endif } DebugMenuAddVarBool8("SkyGFX|Misc", "Blur PS2 Colour Filter", (int8_t*)&CPostEffects::m_bBlurColourFilter, nil); @@ -959,6 +1046,7 @@ installMenu(void) menu.dualPassVehicle = DebugMenuAddVarBool32("SkyGFX|Advanced", "Dual-pass Vehicles", &config->dualPassVehicle, nil); menu.dualPassPed = DebugMenuAddVarBool32("SkyGFX|Advanced", "Dual-pass Peds", &config->dualPassPed, nil); menu.dualPassGrass = DebugMenuAddVarBool32("SkyGFX|Advanced", "Dual-pass Grass", &config->dualPassGrass, nil); + menu.zwriteThreshold = DebugMenuAddVar("SkyGFX|Advanced", "Dual-pass Alpha Threshold", &config->zwriteThreshold, nil, 1, 0, 255, nil); menu.ps2ModulateBuilding = DebugMenuAddVarBool32("SkyGFX|Advanced", "PS2-modulate Buildings", &config->ps2ModulateBuilding, nil); menu.ps2ModulateGrass = DebugMenuAddVarBool32("SkyGFX|Advanced", "PS2-modulate Grass", &config->ps2ModulateGrass, nil); menu.infraredVision = DebugMenuAddVar("SkyGFX|Advanced", "Infrared vision", &config->infraredVision, nil, 1, 0, 1, ps2pcStr); @@ -968,13 +1056,13 @@ 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); + menu.bYCbCrFilter = DebugMenuAddVarBool8("SkyGFX|ScreenFX", "Enable YCbCr tweak", (int8_t*)&config->bYCbCrFilter, resetValues); + menu.lumaScale = DebugMenuAddVar("SkyGFX|ScreenFX", "Y scale", &config->lumaScale, resetValues, 0.004f, 0.0f, 10.0f); + menu.lumaOffset = DebugMenuAddVar("SkyGFX|ScreenFX", "Y offset", &config->lumaOffset, resetValues, 0.004f, -1.0f, 1.0f); + menu.cbScale = DebugMenuAddVar("SkyGFX|ScreenFX", "Cb scale", &config->cbScale, resetValues, 0.004f, 0.0f, 10.0f); + menu.cbOffset = DebugMenuAddVar("SkyGFX|ScreenFX", "Cb offset", &config->cbOffset, resetValues, 0.004f, -1.0f, 1.0f); + menu.crScale = DebugMenuAddVar("SkyGFX|ScreenFX", "Cr scale", &config->crScale, resetValues, 0.004f, 0.0f, 10.0f); + menu.crOffset = DebugMenuAddVar("SkyGFX|ScreenFX", "Cr offset", &config->crOffset, resetValues, 0.004f, -1.0f, 1.0f); hasMenu = true; //void privatepatches(void); @@ -997,6 +1085,8 @@ InjectDelayedPatches() readIni(1); // only load one ini for now, others are loaded later by readInis() + fixingSAMP = GetModuleHandle("samp") != 0 || GetModuleHandle("SAMPGraphicRestore") != 0 || GetModuleHandle("SAMPGraphicRestore.asi") != 0; + InterceptCall(&InitialiseGame, InitialiseGame_hook, 0x748CFB); // Stop timecycle from converting colour filter alphas @@ -1095,6 +1185,7 @@ DllMain(HINSTANCE hInst, DWORD reason, LPVOID) freopen("CONOUT$", "w", stderr); } + config = &configs[0]; // so GetConfig returns something for(int i = 0; i < 10; i++) configs[i].version = VERSION; @@ -1103,6 +1194,17 @@ DllMain(HINSTANCE hInst, DWORD reason, LPVOID) defaultColourTopVOffset = CPostEffects::m_colourTopVOffset; defaultColourBottomVOffset = CPostEffects::m_colourBottomVOffset; + // nvidia is not the way it's meant to be played + Nop(0x748AA8, 0x748AE7-0x748AA8); + + // windowed +// Nop(0x7462FF, 2); +// Nop(0x745B55, 2); +/// InjectHook(0x74639B, selectVM, PATCH_JUMP); + + // moon mask + InjectHook(0x713C4C, renderMoonMask, PATCH_JUMP); + IsAlreadyRunning = (BOOL(*)())(*(int*)(0x74872D+1) + 0x74872D + 5); InjectHook(0x74872D, InjectDelayedPatches); diff --git a/src/neo.h b/src/neo.h index df9e59e..7ef0c1d 100644 --- a/src/neo.h +++ b/src/neo.h @@ -110,12 +110,6 @@ struct CMatrix int haveRwMatrix; }; -struct CPlaceable_III -{ - void *vmt; - CMatrix matrix; -}; - struct VertexTex2 { RwReal x; @@ -177,7 +171,10 @@ class WaterDrops static RwV3d ms_posDelta; static int ms_splashDuration; - static CPlaceable_III *ms_splashObject; + + // debugging + static bool sprayWater; + static bool sprayBlood; static void Process(void); static void CalculateMovement(void); @@ -195,7 +192,6 @@ class WaterDrops static void Clear(void); static void Reset(void); - 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); diff --git a/src/neoWaterdrops.cpp b/src/neoWaterdrops.cpp index fa67f6e..5935ce6 100644 --- a/src/neoWaterdrops.cpp +++ b/src/neoWaterdrops.cpp @@ -93,6 +93,10 @@ typedef uintptr_t addr; float scaling; #define SC(x) ((int)((x)*scaling)) +// debuggin +bool WaterDrops::sprayWater = false; +bool WaterDrops::sprayBlood = false; + float WaterDrops::ms_xOff, WaterDrops::ms_yOff; // not quite sure what these are WaterDrop WaterDrops::ms_drops[MAXDROPS]; int WaterDrops::ms_numDrops; @@ -103,7 +107,6 @@ bool WaterDrops::ms_enabled; bool WaterDrops::ms_movingEnabled; int WaterDrops::ms_splashDuration; -CPlaceable_III *WaterDrops::ms_splashObject; float WaterDrops::ms_distMoved, WaterDrops::ms_vecLen, WaterDrops::ms_rainStrength; RwV3d WaterDrops::ms_vec; @@ -270,19 +273,6 @@ WaterDrops::RegisterSplash(RwV3d* point, float distance, int duration) ms_splashDuration = duration; } -void -WaterDrops::RegisterSplash(CPlaceable_III *plc, float distance) -{ - RwV3d dist; - RwV3dSub(&dist, &plc->matrix.matrix.pos, &ms_lastPos); - //RwV3dSub(&dist, &((CPlaceable*)plc)->matrix.matrix.pos, &ms_lastPos); - - if(RwV3dLength(&dist) <= distance){ - ms_splashDuration = 14; - ms_splashObject = plc; - } -} - void WaterDrops::InitialiseRender(RwCamera *cam) { @@ -466,6 +456,10 @@ WaterDrops::SprayDrops(void) if (tmp < 40) tmp = 40; FillScreenMoving((tmp - 40.0f) / 150.0f * CWeather__Rain * 0.5f); } + if(sprayWater) + FillScreenMoving(0.5f, false); + if(sprayBlood) + FillScreenMoving(0.5f, true); if(ms_splashDuration >= 0){ if (ms_numDrops < MAXDROPS) { //if (isIII()) @@ -614,7 +608,7 @@ WaterDrops::AddToRenderList(WaterDrop *drop) scale = drop->size * 0.5f; - for(i = 0; i < 4; i++, ms_vertPtr++){ + for(i = 0; i < 4; i++){ ms_vertPtr->x = drop->x + xy[i * 2] * scale + ms_xOff; ms_vertPtr->y = drop->y + xy[i * 2 + 1] * scale + ms_yOff; ms_vertPtr->z = 0.0f; @@ -624,6 +618,7 @@ WaterDrops::AddToRenderList(WaterDrop *drop) ms_vertPtr->v0 = uv[i * 2 + 1]; ms_vertPtr->u1 = i >= 2 ? u1_2 : u1_1; ms_vertPtr->v1 = i % 3 == 0 ? v1_2 : v1_1; + ms_vertPtr++; } ms_numBatchedDrops++; } @@ -639,7 +634,7 @@ WaterDrops::Render(void) vbuf->Lock(0, 0, (void**)&ms_vertPtr, 0); ms_numBatchedDrops = 0; for(WaterDrop *drop = &ms_drops[0]; drop < &ms_drops[MAXDROPS]; drop++) - if (drop->active) + if(drop->active) AddToRenderList(drop); vbuf->Unlock(); @@ -675,7 +670,7 @@ WaterDrops::Render(void) RwD3D9SetFVF(DROPFVF); RwD3D9SetStreamSource(0, vbuf, 0, sizeof(VertexTex2)); RwD3D9SetIndices(ms_indexBuf); - RwD3D9DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, ms_numBatchedDrops * 4, 0, ms_numBatchedDrops * 6); + RwD3D9DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, ms_numBatchedDrops * 4, 0, ms_numBatchedDrops * 2); RwD3D9SetTexture(NULL, 1); RwD3D9SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); @@ -724,5 +719,4 @@ WaterDrops::Reset(void) { Clear(); ms_splashDuration = -1; - ms_splashObject = NULL; } diff --git a/src/postfx.cpp b/src/postfx.cpp index 1d10f54..7e8ec6a 100644 --- a/src/postfx.cpp +++ b/src/postfx.cpp @@ -816,10 +816,11 @@ CPostEffects::ColourFilter_PS2(RwRGBA rgba1, RwRGBA rgba2) static RwIm2DVertex blurVerts[4]; float rasterWidth = RwRasterGetWidth(CPostEffects::pRasterFrontBuffer); float rasterHeight = RwRasterGetHeight(CPostEffects::pRasterFrontBuffer); - float leftOff = m_colourLeftUOffset/16.0f / rasterWidth; - float rightOff = m_colourRightUOffset/16.0f / rasterWidth; - float topOff = m_colourTopVOffset/16.0f / rasterHeight; - float bottomOff = m_colourBottomVOffset/16.0f / rasterHeight; + float scale = RwRasterGetWidth(RwCameraGetRaster(Camera))/640.0f; + float leftOff = m_colourLeftUOffset*scale / 16.0f / rasterWidth; + float rightOff = m_colourRightUOffset*scale / 16.0f / rasterWidth; + float topOff = m_colourTopVOffset*scale / 16.0f / rasterHeight; + float bottomOff = m_colourBottomVOffset*scale / 16.0f / rasterHeight; memcpy(blurVerts, verts, sizeof(blurVerts)); /* These are our vertices: * 0--3 @@ -1024,8 +1025,10 @@ CPostEffects::ColourFilter_switch(RwRGBA rgb1, RwRGBA rgb2) if(GetAsyncKeyState(config->keys[0]) & 0x8000){ if(!keystate){ keystate = true; - currentConfig = (currentConfig+1) % numConfigs; - setConfig(); + if(numConfigs){ + currentConfig = (currentConfig+1) % numConfigs; + setConfig(); + } } }else keystate = false; diff --git a/src/skygfx.h b/src/skygfx.h index e404fe2..2e9c68a 100644 --- a/src/skygfx.h +++ b/src/skygfx.h @@ -28,7 +28,7 @@ typedef int32_t int32; extern HMODULE dllModule; #define nil NULL -#define VERSION 0x350 +#define VERSION 0x360 struct Config { // these are at fixed offsets @@ -68,6 +68,7 @@ struct Config { float lumaScale, lumaOffset; float cbScale, cbOffset; float crScale, crOffset; + int zwriteThreshold; }; extern int numConfigs; extern int currentConfig; @@ -278,6 +279,8 @@ void hookBuildingPipe(void); void D3D9Render(RxD3D9ResEntryHeader *resEntryHeader, RxD3D9InstanceData *instanceData); void D3D9RenderDual(int dual, RxD3D9ResEntryHeader *resEntryHeader, RxD3D9InstanceData *instancedData); +void fixSAMP(void); + double CTimeCycle_GetAmbientRed(void); double CTimeCycle_GetAmbientGreen(void); double CTimeCycle_GetAmbientBlue(void); diff --git a/src/vehiclePipe.cpp b/src/vehiclePipe.cpp index c2a33ce..290f092 100644 --- a/src/vehiclePipe.cpp +++ b/src/vehiclePipe.cpp @@ -350,6 +350,8 @@ CCustomCarEnvMapPipeline__CustomPipeRenderCB_PS2(RwResEntry *repEntry, void *obj atomic = (RpAtomic*)object; + _rwD3D9EnableClippingIfNeeded(object, type); + float colorscale = 1.0f; RwD3D9SetPixelShaderConstant(0, &colorscale, 1); @@ -515,6 +517,8 @@ CCustomCarEnvMapPipeline__CustomPipeRenderCB_Specular(RwResEntry *repEntry, void atomic = (RpAtomic*)object; + _rwD3D9EnableClippingIfNeeded(object, type); + float colorscale = 1.0f; RwD3D9SetPixelShaderConstant(0, &colorscale, 1); @@ -693,6 +697,8 @@ CCustomCarEnvMapPipeline__CustomPipeRenderCB_Xbox(RwResEntry *repEntry, void *ob float intensity; } reflData; + _rwD3D9EnableClippingIfNeeded(object, type); + atomic = (RpAtomic*)object; noFx = !!(CVisibilityPlugins__GetAtomicId(atomic) & 0x6000); notLit = !((pDirect->object.object.flags & 1) == 0 || @@ -860,21 +866,22 @@ CCustomCarEnvMapPipeline__CustomPipeRenderCB_Switch(RwResEntry *repEntry, void * switch(config->vehiclePipe){ case 0: CCustomCarEnvMapPipeline__CustomPipeRenderCB_PS2(repEntry, object, type, flags); - return; + break; case 1: CCustomCarEnvMapPipeline__CustomPipeRenderCB_exe(repEntry, object, type, flags); - return; + break; case 2: CCustomCarEnvMapPipeline__CustomPipeRenderCB_Xbox(repEntry, object, type, flags); - return; + break; case 3: CCustomCarEnvMapPipeline__CustomPipeRenderCB_Specular(repEntry, object, type, flags); - return; + break; case 4: if(iCanHasNeoCar) CarPipe::RenderCallback(repEntry, object, type, flags); - return; + break; } + fixSAMP(); } void