Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

Commit

Permalink
Improved reflections on most maps (not death star) and improved perfo…
Browse files Browse the repository at this point in the history
…rmance
  • Loading branch information
Ethan committed Jan 10, 2024
1 parent 1b449b6 commit 22dbf09
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
8 changes: 6 additions & 2 deletions src/BF2VR/BF2Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ namespace BF2VR {
if (worldRenderSettings->aaDisocclusionFactor != 1.f) {
worldRenderSettings->aaDisocclusionFactor = 1.f;
}
if (worldRenderSettings->localReflectionEnable) {
worldRenderSettings->localReflectionEnable = false;
}
}

// Set post options for the user
if (isValidPtr(postSettings)) {
postSettings->ScreenSpaceRaytraceUseVelocityVectorsForTemporal = true;
postSettings->ScreenSpaceRaytraceEnable = false;
postSettings->LensDistortionAllowed = false;
postSettings->forceDofEnable = true;
postSettings->forceDofBlurFactor = 0.f;
Expand Down Expand Up @@ -139,7 +142,7 @@ namespace BF2VR {
return;
}
view->projectionMatrix = projMatrix;
// view->aspectRatio = static_cast<float>(OpenXRService::swapchainWidth) / static_cast<float>(OpenXRService::swapchainHeight);
view->aspectRatio = static_cast<float>(OpenXRService::swapchainWidth) / static_cast<float>(OpenXRService::swapchainHeight);
}

__int64 BF2Service::PostUpdate(void* a1, __int64 a2, GlobalPostProcessSettings* settings) {
Expand Down Expand Up @@ -237,6 +240,7 @@ namespace BF2VR {

if (isValidPtr(postSettings)) {
postSettings->forceDofEnable = false;
postSettings->ScreenSpaceRaytraceEnable = true;
}

return 0;
Expand Down
28 changes: 19 additions & 9 deletions src/BF2VR/D3DService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ namespace BF2VR {
return;
}

if (!hasBeganFrame && OpenXRService::leftEye) {
// Start on left eye
OpenXRService::WaitBeginFrame();
hasBeganFrame = true;
}

if (!hasBeganDrawing) {
// Start on left eye
OpenXRService::BeforeDraw();
hasBeganDrawing = true;
}

// Aquire openxr RTV
int CurrentEye = OpenXRService::leftEye ? 0 : 1;
ID3D11RenderTargetView* xrRTV = OpenXRService::xrRTVs.at(CurrentEye).at(OpenXRService::swapchainImageIndex);
Expand Down Expand Up @@ -82,17 +94,15 @@ namespace BF2VR {
toReturn = presentHook.call<HRESULT>(swapChain, syncInterval, flags);
}

// Present implies all drawing is done for the game's frame
OpenXRService::AfterDraw();

// On the right eye present, the entire VR frame loop is complete, so end and begin for next time
if (!OpenXRService::leftEye) {
OpenXRService::EndFrame(); // This may be called on the very fist frame resulting in invalid call order
OpenXRService::WaitBeginFrame();
if (hasBeganDrawing) {
OpenXRService::AfterDraw();
hasBeganDrawing = false;
}

// Before draw in anticipation for next draw calls
OpenXRService::BeforeDraw();
if (!OpenXRService::leftEye && hasBeganFrame) {
OpenXRService::EndFrame();
hasBeganFrame = false;
}

// Clear the RTV for the HUD
ID3D11RenderTargetView* uiRTV = OpenXRService::xrRTVs.at(2).at(OpenXRService::swapchainImageIndex);
Expand Down
3 changes: 3 additions & 0 deletions src/BF2VR/D3DService.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class D3DService {

static inline ID3D11VertexShader* pVertexShader = nullptr;
static inline ID3D11PixelShader* pPixelShader = nullptr;

static inline bool hasBeganFrame = false;
static inline bool hasBeganDrawing = false;
};

} // namespace BF2VR
Expand Down

0 comments on commit 22dbf09

Please sign in to comment.