diff --git a/CyberFSR.sln b/CyberFSR.sln index 0194284..2d7f2f2 100644 --- a/CyberFSR.sln +++ b/CyberFSR.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.2.32602.215 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CyberFSR", "CyberFSR\CyberFSR.vcxproj", "{8D2B73FB-EECD-45CE-B8E5-335610462F58}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvngxLoader", "nvngxLoader\nvngxLoader.vcxproj", "{9033F8A6-879A-4FF1-A374-3F089856B05C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -21,6 +23,14 @@ Global {8D2B73FB-EECD-45CE-B8E5-335610462F58}.Release|x64.Build.0 = Release|x64 {8D2B73FB-EECD-45CE-B8E5-335610462F58}.Release|x86.ActiveCfg = Release|Win32 {8D2B73FB-EECD-45CE-B8E5-335610462F58}.Release|x86.Build.0 = Release|Win32 + {9033F8A6-879A-4FF1-A374-3F089856B05C}.Debug|x64.ActiveCfg = Debug|x64 + {9033F8A6-879A-4FF1-A374-3F089856B05C}.Debug|x64.Build.0 = Debug|x64 + {9033F8A6-879A-4FF1-A374-3F089856B05C}.Debug|x86.ActiveCfg = Debug|Win32 + {9033F8A6-879A-4FF1-A374-3F089856B05C}.Debug|x86.Build.0 = Debug|Win32 + {9033F8A6-879A-4FF1-A374-3F089856B05C}.Release|x64.ActiveCfg = Release|x64 + {9033F8A6-879A-4FF1-A374-3F089856B05C}.Release|x64.Build.0 = Release|x64 + {9033F8A6-879A-4FF1-A374-3F089856B05C}.Release|x86.ActiveCfg = Release|Win32 + {9033F8A6-879A-4FF1-A374-3F089856B05C}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CyberFSR/Dx12ParameterImpl.cpp b/CyberFSR/Dx12ParameterImpl.cpp index f7b21c2..0479803 100644 --- a/CyberFSR/Dx12ParameterImpl.cpp +++ b/CyberFSR/Dx12ParameterImpl.cpp @@ -24,7 +24,12 @@ void Dx12ParameterImpl::Set(const char* InName, float InValue) JitterOffsetY = InValue; break; case Util::NvParameter::Sharpness: - Sharpness = InValue; + if (InValue >= 1.0f) { + Sharpness = 1; + } + else { + Sharpness = (InValue + 0.99f) / 2.0f; + } break; } } diff --git a/CyberFSR/ViewMatrixHook.cpp b/CyberFSR/ViewMatrixHook.cpp index 02144da..5718cc8 100644 --- a/CyberFSR/ViewMatrixHook.cpp +++ b/CyberFSR/ViewMatrixHook.cpp @@ -3,15 +3,8 @@ ViewMatrixHook::ViewMatrixHook() { - //TODO check for different executable versions - - /* - Protip for future self to get the offsets, search for the vertical FOV to get the structure, then look for references to that structure and afterwards look for static references - */ - - auto mod = (uint64_t)GetModuleHandleW(L"Cyberpunk2077.exe"); - auto ptr1 = *((uintptr_t*)(mod + 0x4B6F888)); - camParams = ((CameraParams*)(ptr1 + 0x60)); + uintptr_t mod = (uintptr_t)GetModuleHandle(NULL); + camParams = (CameraParams*)(mod + 0x3E806E0); } float ViewMatrixHook::GetFov() diff --git a/CyberFSR/ViewMatrixHook.h b/CyberFSR/ViewMatrixHook.h index b4b78ff..9d5d2b3 100644 --- a/CyberFSR/ViewMatrixHook.h +++ b/CyberFSR/ViewMatrixHook.h @@ -2,9 +2,7 @@ struct CameraParams { - unsigned char unknown0[0x20]; float FoV; - unsigned char unknown1[0x1C]; float NearPlane; float FarPlane; }; diff --git a/README.md b/README.md index f273051..e894083 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,17 @@ -# FidelityFx Super Resolution 2.0 for Cyberpunk 2077 +# FidelityFx Super Resolution 2.0 for Red Dead Redemption 2 - This mod is a library for Cyberpunk which replaces Nvidia DLSS with AMD FidelityFX Super Resolution 2.0 + This mod is a library for RDR2 which replaces Nvidia DLSS with AMD FidelityFX Super Resolution 2.0 ## Compilation * Clone this repo including all submodules * Compile the FSR 2.0 submodule in external/FidelityFX-FSR2 like it is described in their Readme https://github.com/GPUOpen-Effects/FidelityFX-FSR2#quick-start-checklist. Note: I used the GenerateSolutionsDLL.bat but I am sure static libraries will work fine too * Open the CyberFSR.sln with Visual Studio 2022 -* Hit Compile -* Copy the compiled DLL, ffx_fsr2_api_dx12_x64.dll and ffx_fsr2_api_x64.dll from the FidelityFX Directory to your Cyberpunk 2077 executable directory. -* Rename the compiled DLL to nvngx.dll -* Run the EnableSignatureOverride.reg to allow Cyberpunks DLSS implementation to load unsigned DLSS versions +* Compile the entire solution +* Copy the compiled DLLs (nvngx.dll & d3d11.dll), ffx_fsr2_api_dx12_x64.dll and ffx_fsr2_api_x64.dll from the FidelityFX Directory to your RDR2 executable directory +* Run the EnableSignatureOverride.reg to allow RDR2s DLSS implementation to load unsigned DLSS versions * Run the game and set the quality in the DLSS settings * Play the game with FSR 2.0 + +## Advisory +* Like all mods for Rockstar games, please avoid using this online as I am unsure if you will get banned. diff --git a/nvngxLoader/dllmain.cpp b/nvngxLoader/dllmain.cpp new file mode 100644 index 0000000..9340b8f --- /dev/null +++ b/nvngxLoader/dllmain.cpp @@ -0,0 +1,27 @@ +// dllmain.cpp : Defines the entry point for the DLL application. +#include "pch.h" +#include + +void Patch() { + DWORD jzAddress = 0x26C4CCD; + uintptr_t base = (uintptr_t)GetModuleHandle(NULL); + *(BYTE*)(base + jzAddress) = 0x85; //JZ > JNZ +} + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + Patch(); + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + diff --git a/nvngxLoader/framework.h b/nvngxLoader/framework.h new file mode 100644 index 0000000..54b83e9 --- /dev/null +++ b/nvngxLoader/framework.h @@ -0,0 +1,5 @@ +#pragma once + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files +#include diff --git a/nvngxLoader/nvngxLoader.vcxproj b/nvngxLoader/nvngxLoader.vcxproj new file mode 100644 index 0000000..160eee5 --- /dev/null +++ b/nvngxLoader/nvngxLoader.vcxproj @@ -0,0 +1,160 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {9033f8a6-879a-4ff1-a374-3f089856b05c} + nvngxLoader + 10.0 + + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + d3d11 + + + + Level3 + true + WIN32;_DEBUG;NVNGXLOADER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + false + + + + + Level3 + true + true + true + WIN32;NDEBUG;NVNGXLOADER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + true + true + false + + + + + Level3 + true + _DEBUG;NVNGXLOADER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + false + + + + + Level3 + true + true + true + NDEBUG;NVNGXLOADER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + true + true + false + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/nvngxLoader/nvngxLoader.vcxproj.filters b/nvngxLoader/nvngxLoader.vcxproj.filters new file mode 100644 index 0000000..1e57c7b --- /dev/null +++ b/nvngxLoader/nvngxLoader.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/nvngxLoader/pch.cpp b/nvngxLoader/pch.cpp new file mode 100644 index 0000000..64b7eef --- /dev/null +++ b/nvngxLoader/pch.cpp @@ -0,0 +1,5 @@ +// pch.cpp: source file corresponding to the pre-compiled header + +#include "pch.h" + +// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/nvngxLoader/pch.h b/nvngxLoader/pch.h new file mode 100644 index 0000000..885d5d6 --- /dev/null +++ b/nvngxLoader/pch.h @@ -0,0 +1,13 @@ +// pch.h: This is a precompiled header file. +// Files listed below are compiled only once, improving build performance for future builds. +// This also affects IntelliSense performance, including code completion and many code browsing features. +// However, files listed here are ALL re-compiled if any one of them is updated between builds. +// Do not add files here that you will be updating frequently as this negates the performance advantage. + +#ifndef PCH_H +#define PCH_H + +// add headers that you want to pre-compile here +#include "framework.h" + +#endif //PCH_H