File tree Expand file tree Collapse file tree 4 files changed +77
-1
lines changed
resources/BreathOfTheWild_BetterVR Expand file tree Collapse file tree 4 files changed +77
-1
lines changed Original file line number Diff line number Diff line change 1+ [BetterVR_StereoRendering_ScreenChecks_V208]
2+ moduleMatches = 0x6267BFD0
3+
4+ .origin = codecave
5+
6+ ; disable agl::fx::Cloud::drawSunOcc which uses texture readback
7+ ;0x0340425C = cmpwi r1, 0
8+
9+ ; disable peekTexture_checksQueuedRegions to narrow down interesting readback function
10+ ;0x030F1B78 = nop
11+
12+ ; hook GX2SetPixelUniformBlock to hook the right pixels
13+ hook_GX2SetPixelUniformBlock:
14+ mflr r0
15+ stwu r1 , - 0x20 (r1)
16+ stw r0 , 0x24 (r1)
17+ stw r3 , 0x1C (r1)
18+ stw r4 , 0x18 (r1)
19+ stw r5 , 0x14 (r1)
20+ stw r6 , 0x10 (r1)
21+ stw r7 , 0x0C (r1)
22+
23+ ; check size of uniform block being set
24+ ; r3 is uniform block handle
25+ ; r4 is the size of the uniform block data in bytes
26+ ; r5 is the pointer to the uniform block data to be set
27+ cmpwi r4 , 0x20
28+ bne skipHook_GX2SetPixelUniformBlock
29+
30+ ; modify values in the uniform block data to be set
31+ bla import.coreinit.hook_ModifyPixelUniformBlockData
32+
33+ skipHook_GX2SetPixelUniformBlock:
34+ bla import.gx2.GX2SetPixelUniformBlock
35+
36+ lwz r7 , 0x0C (r1)
37+ lwz r6 , 0x10 (r1)
38+ lwz r5 , 0x14 (r1)
39+ lwz r4 , 0x18 (r1)
40+ ;lwz r3, 0x1C(r1) ; r3 should be the return value of GX2SetPixelUniformBlock
41+ lwz r0 , 0x24 (r1)
42+ addi r1 , r1 , 0x20
43+ mtlr r0
44+ blr
45+
46+ 0x038B2B2C = bla hook_GX2SetPixelUniformBlock
Original file line number Diff line number Diff line change @@ -741,6 +741,28 @@ void CemuHooks::hook_CheckIfCameraCanSeePos(PPCInterpreter_t* hCPU) {
741741 hCPU->gpr [3 ] = visible ? 1 : 0 ;
742742}
743743
744+
745+
746+ void CemuHooks::hook_ModifyPixelUniformBlockData (PPCInterpreter_t* hCPU) {
747+ hCPU->instructionPointer = hCPU->sprNew .LR ;
748+
749+ auto currFovOpt = VRManager::instance ().XR ->GetRenderer ()->GetFOV (EyeSide::RIGHT);
750+ if (!currFovOpt.has_value ()) {
751+ return ;
752+ }
753+
754+ glm::fvec4 ubData = {};
755+ readMemory (hCPU->gpr [5 ], &ubData);
756+
757+ XrFovf currFOV = currFovOpt.value ();
758+ auto newProjection = calculateFOVAndOffset (currFOV);
759+
760+ ubData.x = 0 .5f +newProjection.offsetX .getLE ();
761+ ubData.y = 0 .5f +newProjection.offsetY .getLE ();
762+
763+ writeMemory (hCPU->gpr [5 ], &ubData);
764+ }
765+
744766void CemuHooks::hook_EndCameraSide (PPCInterpreter_t* hCPU) {
745767 hCPU->instructionPointer = hCPU->sprNew .LR ;
746768
Original file line number Diff line number Diff line change 22#include " entity_debugger.h"
33#include " utils/mod_settings.h"
44
5-
65class CemuHooks {
76public:
87 CemuHooks () {
@@ -49,6 +48,7 @@ class CemuHooks {
4948 osLib_registerHLEFunction (" coreinit" , " hook_PlayerIsRidingSandSeal" , &hook_PlayerIsRidingSandSeal);
5049 osLib_registerHLEFunction (" coreinit" , " hook_FixStaminaGaugeScreenPosition" , &hook_FixStaminaGaugeScreenPosition);
5150 osLib_registerHLEFunction (" coreinit" , " hook_FixExtraStaminaGaugeIconPositions" , &hook_FixExtraStaminaGaugeIconPositions);
51+ osLib_registerHLEFunction (" coreinit" , " hook_ModifyPixelUniformBlockData" , &hook_ModifyPixelUniformBlockData);
5252
5353 // First-Person Model Hooks
5454 osLib_registerHLEFunction (" coreinit" , " hook_SetActorOpacity" , &hook_SetActorOpacity);
@@ -245,6 +245,7 @@ class CemuHooks {
245245 static void hook_FixLadder (PPCInterpreter_t* hCPU);
246246 static void hook_PlayerIsRiding (PPCInterpreter_t* hCPU);
247247 static void hook_PlayerIsRidingSandSeal (PPCInterpreter_t* hCPU);
248+ static void hook_ModifyPixelUniformBlockData (PPCInterpreter_t* hCPU);
248249
249250 // First-Person Model Hooks
250251 static void hook_SetActorOpacity (PPCInterpreter_t* hCPU);
Original file line number Diff line number Diff line change @@ -100,6 +100,13 @@ struct std::formatter<glm::fvec3> : std::formatter<string> {
100100 }
101101};
102102
103+ template <>
104+ struct std ::formatter<glm::fvec4> : std::formatter<string> {
105+ auto format (const glm::fvec4& vec, std::format_context& ctx) const {
106+ return std::format_to (ctx.out (), " {}" , glm::to_string (vec));
107+ }
108+ };
109+
103110template <>
104111struct std ::formatter<glm::fquat> : std::formatter<string> {
105112 auto format (const glm::fquat& quat, std::format_context& ctx) const {
You can’t perform that action at this time.
0 commit comments