diff --git a/premake5.lua b/premake5.lua index 2307e4f..0a9a767 100644 --- a/premake5.lua +++ b/premake5.lua @@ -33,6 +33,7 @@ project "skygfx_vc" filter "configurations:DebugIII" defines { "DEBUG" } + flags { "StaticRuntime" } symbols "On" debugdir "C:/Users/aap/games/gta3" debugcommand "C:/Users/aap/games/gta3/gta3.exe" @@ -40,6 +41,7 @@ project "skygfx_vc" filter "configurations:DebugVC" defines { "DEBUG" } + flags { "StaticRuntime" } symbols "On" debugdir "C:/Users/aap/games/gtavc" debugcommand "C:/Users/aap/games/gtavc/gta_vc.exe" diff --git a/resources/Resource.rc b/resources/Resource.rc index f24b265..0c8fa20 100644 --- a/resources/Resource.rc +++ b/resources/Resource.rc @@ -5,6 +5,7 @@ IDR_RIMVS RCDATA "cso\\rimVS.cso" IDR_VEHICLEONEVS RCDATA "cso\\vehiclePass1VS.cso" IDR_VEHICLETWOVS RCDATA "cso\\vehiclePass2VS.cso" IDR_WORLDPS RCDATA "cso\\worldPS.cso" +IDR_VCWORLDPS RCDATA "cso\\vc_worldPS.cso" IDR_GLOSSVS RCDATA "cso\\glossVS.cso" IDR_GLOSSPS RCDATA "cso\\glossPS.cso" IDR_CURVEPS RCDATA "cso\\curvePS.cso" diff --git a/resources/resource.h b/resources/resource.h index a77056a..73f4b90 100644 --- a/resources/resource.h +++ b/resources/resource.h @@ -2,6 +2,7 @@ #define IDR_VEHICLEONEVS 102 #define IDR_VEHICLETWOVS 103 #define IDR_WORLDPS 104 +#define IDR_VCWORLDPS 110 #define IDR_GLOSSVS 105 #define IDR_GLOSSPS 106 #define IDR_CURVEPS 107 diff --git a/src/main.cpp b/src/main.cpp index 81190af..6dd6b06 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -68,6 +68,7 @@ RwImVertexIndex *blurIndices = AddressByVersion(0x5FDD90, 0x5F static addr DefinedState_A = AddressByVersion(0x526330, 0x526570, 0x526500, 0x57F9C0, 0x57F9E0, 0x57F7F0); WRAPPER void DefinedState(void) { VARJMP(DefinedState_A); } +float matFXcoef = 0.7f; int blendstyle, blendkey; int texgenstyle, texgenkey; @@ -266,6 +267,9 @@ rpMatFXD3D8AtomicMatFXEnvRender_dual(RxD3D8InstanceData *inst, int flags, int se static float mult = isIII() ? 2.0f : 4.0f; float factor = env->envCoeff*mult*255.0f; +//if(factor != 0.0f) factor = matFXcoef*255.0f; +//if(strstr(texture->name, "body")) texture = nil; +//envMap = CarPipe::reflectionTex; RwUInt8 intens = (RwUInt8)factor; if(factor == 0.0f || !envMap){ @@ -830,8 +834,8 @@ delayedPatches(int a, int b) DebugMenuAddVarBool32("SkyGFX", "Neo water drops", &neowaterdrops, nil); DebugMenuAddVarBool32("SkyGFX", "Neo-style blood drops", &neoblooddrops, nil); - //void neoMenu(); - //neoMenu(); + void neoMenu(); + neoMenu(); DebugMenuAddVarBool8("SkyGFX|ScreenFX", "Enable YCbCr tweak", (int8_t*)&ScreenFX::m_bYCbCrFilter, nil); DebugMenuAddVar("SkyGFX|ScreenFX", "Y scale", &ScreenFX::m_lumaScale, nil, 0.004f, 0.0f, 10.0f); @@ -840,6 +844,8 @@ delayedPatches(int a, int b) DebugMenuAddVar("SkyGFX|ScreenFX", "Cb offset", &ScreenFX::m_cbOffset, nil, 0.004f, -1.0f, 1.0f); DebugMenuAddVar("SkyGFX|ScreenFX", "Cr scale", &ScreenFX::m_crScale, nil, 0.004f, 0.0f, 10.0f); DebugMenuAddVar("SkyGFX|ScreenFX", "Cr offset", &ScreenFX::m_crOffset, nil, 0.004f, -1.0f, 1.0f); + +// DebugMenuAddVar("SkyGFX", "MatFX coeff", &matFXcoef, nil, 0.1f, 0.0f, 1.0f); } return RsEventHandler_orig(a, b); } diff --git a/src/neo.h b/src/neo.h index 951bf83..b36df39 100644 --- a/src/neo.h +++ b/src/neo.h @@ -103,7 +103,7 @@ class WorldPipe : CustomPipe void CreateShaders(void); void LoadTweakingTable(void); public: - bool isActive; + //bool isActive; bool modulate2x; int setMaterial; int setMaterialColor; @@ -137,7 +137,7 @@ class GlossPipe : public CustomPipe RwTexture *GetGlossTex(RpMaterial *mat); public: Color specular; - bool isActive; + //bool isActive; // uchar b2; RwTexDictionary *texdict; static void *vertexShader; @@ -150,6 +150,38 @@ class GlossPipe : public CustomPipe static void ShaderSetup(RwMatrix *world); }; +class CarPipe : public CustomPipe +{ + void CreateShaders(void); + void LoadTweakingTable(void); + + static void MakeScreenQuad(void); + static void MakeQuadTexCoords(bool textureSpace); + static void RenderReflectionScene(void); +public: + static InterpolatedFloat fresnel; + static InterpolatedFloat power; + static InterpolatedLight diffColor; + static InterpolatedLight specColor; + static void *vertexShaderPass1; + static void *vertexShaderPass2; + // reflection map + static RwCamera *reflectionCam; + static RwTexture *reflectionMask; + static RwTexture *reflectionTex; + static RwIm2DVertex screenQuad[4]; + static RwImVertexIndex screenindices[6]; + + CarPipe(void); + void Init(void); + static void RenderEnvTex(void); + static void SetupEnvMap(void); + static void RenderCallback(RwResEntry *repEntry, void *object, RwUInt8 type, RwUInt32 flags); + static void ShaderSetup(RwMatrix *world); + static void DiffusePass(RxD3D8ResEntryHeader *header); + static void SpecularPass(RxD3D8ResEntryHeader *header); +}; + /* * neo water drops */ diff --git a/src/neoCarpipe.cpp b/src/neoCarpipe.cpp index 4755249..97d2121 100644 --- a/src/neoCarpipe.cpp +++ b/src/neoCarpipe.cpp @@ -8,7 +8,7 @@ static int neoSpecularPass = 1; static int vcsBlend = 0; -static int debugEnvMap; +static int debugEnvMap = 0; static int enableEnv = 1; static uint32_t CRenderer__RenderEverythingBarRoads_A = AddressByVersion(0x4A7930, 0x4A7A20, 0x4A79B0, 0x4C9F40, 0x4C9F60, 0x4C9E00); @@ -21,38 +21,6 @@ int &skyBotGreen = *AddressByVersion(0x8F2BD0, 0x8F2C84, 0x902DC4, 0x97F20 int &skyBotBlue = *AddressByVersion(0x8F625C, 0x8F6414, 0x906554, 0x9B6DF4, 0x9B6DFC, 0x9B5DFC); -class CarPipe : public CustomPipe -{ - void CreateShaders(void); - void LoadTweakingTable(void); - - static void MakeScreenQuad(void); - static void MakeQuadTexCoords(bool textureSpace); - static void RenderReflectionScene(void); -public: - static InterpolatedFloat fresnel; - static InterpolatedFloat power; - static InterpolatedLight diffColor; - static InterpolatedLight specColor; - static void *vertexShaderPass1; - static void *vertexShaderPass2; - // reflection map - static RwCamera *reflectionCam; - static RwTexture *reflectionMask; - static RwTexture *reflectionTex; - static RwIm2DVertex screenQuad[4]; - static RwImVertexIndex screenindices[6]; - - CarPipe(void); - void Init(void); - static void RenderEnvTex(void); - static void SetupEnvMap(void); - static void RenderCallback(RwResEntry *repEntry, void *object, RwUInt8 type, RwUInt32 flags); - static void ShaderSetup(RwMatrix *world); - static void DiffusePass(RxD3D8ResEntryHeader *header); - static void SpecularPass(RxD3D8ResEntryHeader *header); -}; - InterpolatedFloat CarPipe::fresnel(0.4f); InterpolatedFloat CarPipe::power(18.0f); InterpolatedLight CarPipe::diffColor(Color(0.0f, 0.0f, 0.0f, 0.0f)); @@ -119,7 +87,7 @@ void RenderScene_hook(void) { RenderScene(); - if(neocarpipe) +// if(neocarpipe) CarPipe::RenderEnvTex(); } @@ -574,8 +542,10 @@ CarPipe::RenderCallback(RwResEntry *repEntry, void *object, RwUInt8 type, RwUInt void neoMenu(void) { +#ifdef DEBUG DebugMenuAddVarBool32("SkyGFX", "Neo Car env map debug", &debugEnvMap, nil); DebugMenuAddVarBool32("SkyGFX", "Neo Car specular", &neoSpecularPass, nil); DebugMenuAddVarBool32("SkyGFX", "Neo Car VCS blend", &vcsBlend, nil); DebugMenuAddVarBool32("SkyGFX", "Neo Car env", &enableEnv, nil); -} \ No newline at end of file +#endif +} diff --git a/src/neoGlosspipe.cpp b/src/neoGlosspipe.cpp index 7941c40..990ab89 100644 --- a/src/neoGlosspipe.cpp +++ b/src/neoGlosspipe.cpp @@ -42,7 +42,7 @@ GlossPipe::GlossPipe(void) : specular(1.0f, 1.0f, 1.0f, 1.0f) { CreateRwPipeline(); - isActive = config.neoGlossPipe; +// isActive = config.neoGlossPipe; texdict = NULL; } @@ -196,13 +196,15 @@ GlossPipe::RenderCallback(RwResEntry *repEntry, void *object, RwUInt8 type, RwUI if(GetAsyncKeyState(config.neoGlossPipeKey) & 0x8000){ if(!keystate){ keystate = true; - GlossPipe::Get()->isActive = !GlossPipe::Get()->isActive; + config.neoGlossPipe = !config.neoGlossPipe; + // GlossPipe::Get()->isActive = !GlossPipe::Get()->isActive; } }else keystate = false; } WorldPipe::Get()->RenderCallback(repEntry, object, type, flags); - if(GlossPipe::Get()->isActive){ +// if(GlossPipe::Get()->isActive){ + if(config.neoGlossPipe){ ShaderSetup(RwFrameGetLTM(RpAtomicGetFrame((RpAtomic*)object))); RenderGloss(header); } diff --git a/src/neoWorldpipe.cpp b/src/neoWorldpipe.cpp index aa61974..5066b35 100644 --- a/src/neoWorldpipe.cpp +++ b/src/neoWorldpipe.cpp @@ -78,14 +78,14 @@ WorldPipe::WorldPipe(void) { CreateRwPipeline(); modulate2x = false; - isActive = true; +// isActive = true; usePixelShader = RwD3D9Supported(); } void WorldPipe::Attach(RpAtomic *atomic) { - if(isActive && *RWPLUGINOFFSET(int, atomic, MatFXAtomicDataOffset)) + if(/*isActive &&*/ *RWPLUGINOFFSET(int, atomic, MatFXAtomicDataOffset)) CustomPipe::Attach(atomic); } @@ -108,7 +108,10 @@ WorldPipe::CreateShaders(void) if(RwD3D9Supported()){ HRSRC resource; RwUInt32 *shader; - resource = FindResource(dllModule, MAKEINTRESOURCE(IDR_WORLDPS), RT_RCDATA); + if(isIII()) + resource = FindResource(dllModule, MAKEINTRESOURCE(IDR_WORLDPS), RT_RCDATA); + else + resource = FindResource(dllModule, MAKEINTRESOURCE(IDR_VCWORLDPS), RT_RCDATA); shader = (RwUInt32*)LoadResource(dllModule, resource); RwD3D9CreatePixelShader(shader, &pixelShader); assert(WorldPipe::pixelShader); diff --git a/src/screenfx.cpp b/src/screenfx.cpp index 264a8ce..e7a4731 100644 --- a/src/screenfx.cpp +++ b/src/screenfx.cpp @@ -6,10 +6,6 @@ struct Grade }; -// ADDRESS -static uint32_t CMBlur__CreateImmediateModeData_A = AddressByVersion(0x50A800, 0, 0, 0x55F1D0, 0, 0); -WRAPPER void CMBlur__CreateImmediateModeData(RwCamera *cam, RwRect *rect) { VARJMP(CMBlur__CreateImmediateModeData_A); } - RwRaster *ScreenFX::pFrontBuffer; void *ScreenFX::gradingPS; @@ -25,6 +21,59 @@ static int curScreenWidth; static int curScreenHeight; static int curScreenDepth; +RwIm2DVertex screenVertices[4]; +RwImVertexIndex screenIndices[6] = { 0, 1, 2, 0, 2, 3 }; + +void +ScreenFX::CreateImmediateModeData(RwCamera *cam, RwRect *rect) +{ + float zero = 0.0f; + float xmax = rect->w; + float ymax = rect->h; + // whatever this is... + if(RwRasterGetDepth(RwCameraGetRaster(cam)) == 16){ + zero += 0.5f; + xmax += 0.5f; + ymax += 0.5f; + }else{ + zero -= 0.5f; + xmax -= 0.5f; + ymax -= 0.5f; + } + const float recipz = 1.0f/RwCameraGetNearClipPlane(cam); + RwIm2DVertexSetScreenX(&screenVertices[0], zero); + RwIm2DVertexSetScreenY(&screenVertices[0], zero); + RwIm2DVertexSetScreenZ(&screenVertices[0], RwIm2DGetNearScreenZ()); + RwIm2DVertexSetRecipCameraZ(&screenVertices[0], recipz); + RwIm2DVertexSetU(&screenVertices[0], 0.0f, recipz); + RwIm2DVertexSetV(&screenVertices[0], 0.0f, recipz); + RwIm2DVertexSetIntRGBA(&screenVertices[0], 255, 255, 255, 255); + + RwIm2DVertexSetScreenX(&screenVertices[1], zero); + RwIm2DVertexSetScreenY(&screenVertices[1], ymax); + RwIm2DVertexSetScreenZ(&screenVertices[1], RwIm2DGetNearScreenZ()); + RwIm2DVertexSetRecipCameraZ(&screenVertices[1], recipz); + RwIm2DVertexSetU(&screenVertices[1], 0.0f, recipz); + RwIm2DVertexSetV(&screenVertices[1], 1.0f, recipz); + RwIm2DVertexSetIntRGBA(&screenVertices[1], 255, 255, 255, 255); + + RwIm2DVertexSetScreenX(&screenVertices[2], xmax); + RwIm2DVertexSetScreenY(&screenVertices[2], ymax); + RwIm2DVertexSetScreenZ(&screenVertices[2], RwIm2DGetNearScreenZ()); + RwIm2DVertexSetRecipCameraZ(&screenVertices[2], recipz); + RwIm2DVertexSetU(&screenVertices[2], 1.0f, recipz); + RwIm2DVertexSetV(&screenVertices[2], 1.0f, recipz); + RwIm2DVertexSetIntRGBA(&screenVertices[2], 255, 255, 255, 255); + + RwIm2DVertexSetScreenX(&screenVertices[3], xmax); + RwIm2DVertexSetScreenY(&screenVertices[3], zero); + RwIm2DVertexSetScreenZ(&screenVertices[3], RwIm2DGetNearScreenZ()); + RwIm2DVertexSetRecipCameraZ(&screenVertices[3], recipz); + RwIm2DVertexSetU(&screenVertices[3], 1.0f, recipz); + RwIm2DVertexSetV(&screenVertices[3], 0.0f, recipz); + RwIm2DVertexSetIntRGBA(&screenVertices[3], 255, 255, 255, 255); +} + void ScreenFX::Initialise(void) { @@ -53,7 +102,7 @@ ScreenFX::Initialise(void) } r.w = width; r.h = height; - CMBlur__CreateImmediateModeData(Scene.camera, &r); + CreateImmediateModeData(Scene.camera, &r); } void @@ -130,7 +179,7 @@ ScreenFX::AVColourCorrection(void) RwD3D9SetIm2DPixelShader(gradingPS); // don't use these - RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, blurVertices, 4, blurIndices, 6); + RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, screenVertices, 4, screenIndices, 6); RwD3D9SetIm2DPixelShader(nil); RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); diff --git a/src/skygfx.h b/src/skygfx.h index 5480546..093dfc6 100644 --- a/src/skygfx.h +++ b/src/skygfx.h @@ -44,6 +44,7 @@ class ScreenFX static float m_crOffset; static void Initialise(void); + static void CreateImmediateModeData(RwCamera *cam, RwRect *rect); static void UpdateFrontBuffer(void); static void AVColourCorrection(void); static void Render(void);