mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-07 08:49:15 +00:00
Compare commits
No commits in common. "c455d20f9c22ec85b156ec750618e912af2f4cd7" and "bf877124c1dc44395ef3e05a307d0301c2e7fa3a" have entirely different histories.
c455d20f9c
...
bf877124c1
5 changed files with 13 additions and 117 deletions
|
@ -1,106 +0,0 @@
|
||||||
namespace NAK.SuperAwesomeMod;
|
|
||||||
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
|
|
||||||
[RequireComponent(typeof(Camera))]
|
|
||||||
public class DepthTextureFix : MonoBehaviour
|
|
||||||
{
|
|
||||||
private Camera cam;
|
|
||||||
private CommandBuffer beforeCommandBuffer;
|
|
||||||
private CommandBuffer afterCommandBuffer;
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
cam = GetComponent<Camera>();
|
|
||||||
|
|
||||||
// Ensure camera generates depth texture
|
|
||||||
cam.depthTextureMode |= DepthTextureMode.Depth;
|
|
||||||
|
|
||||||
// Create command buffers
|
|
||||||
beforeCommandBuffer = new CommandBuffer();
|
|
||||||
beforeCommandBuffer.name = "DepthTextureFix_Before";
|
|
||||||
|
|
||||||
afterCommandBuffer = new CommandBuffer();
|
|
||||||
afterCommandBuffer.name = "DepthTextureFix_After";
|
|
||||||
|
|
||||||
// Add command buffers at the right events
|
|
||||||
cam.AddCommandBuffer(CameraEvent.BeforeDepthTexture, beforeCommandBuffer);
|
|
||||||
cam.AddCommandBuffer(CameraEvent.AfterDepthTexture, afterCommandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnPreRender()
|
|
||||||
{
|
|
||||||
// Set up command buffers each frame to handle dynamic changes
|
|
||||||
SetupCommandBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetupCommandBuffers()
|
|
||||||
{
|
|
||||||
// Get current camera viewport in pixels
|
|
||||||
Rect pixelRect = cam.pixelRect;
|
|
||||||
|
|
||||||
// Before depth texture: override viewport to full screen
|
|
||||||
beforeCommandBuffer.Clear();
|
|
||||||
beforeCommandBuffer.SetViewport(new Rect(0, 0, Screen.width, Screen.height));
|
|
||||||
|
|
||||||
// After depth texture: restore original viewport
|
|
||||||
afterCommandBuffer.Clear();
|
|
||||||
afterCommandBuffer.SetViewport(pixelRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDestroy()
|
|
||||||
{
|
|
||||||
// Clean up
|
|
||||||
if (cam != null)
|
|
||||||
{
|
|
||||||
if (beforeCommandBuffer != null)
|
|
||||||
{
|
|
||||||
cam.RemoveCommandBuffer(CameraEvent.BeforeDepthTexture, beforeCommandBuffer);
|
|
||||||
beforeCommandBuffer.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (afterCommandBuffer != null)
|
|
||||||
{
|
|
||||||
cam.RemoveCommandBuffer(CameraEvent.AfterDepthTexture, afterCommandBuffer);
|
|
||||||
afterCommandBuffer.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDisable()
|
|
||||||
{
|
|
||||||
if (cam != null)
|
|
||||||
{
|
|
||||||
if (beforeCommandBuffer != null)
|
|
||||||
cam.RemoveCommandBuffer(CameraEvent.BeforeDepthTexture, beforeCommandBuffer);
|
|
||||||
if (afterCommandBuffer != null)
|
|
||||||
cam.RemoveCommandBuffer(CameraEvent.AfterDepthTexture, afterCommandBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnEnable()
|
|
||||||
{
|
|
||||||
if (cam != null && beforeCommandBuffer != null && afterCommandBuffer != null)
|
|
||||||
{
|
|
||||||
cam.AddCommandBuffer(CameraEvent.BeforeDepthTexture, beforeCommandBuffer);
|
|
||||||
cam.AddCommandBuffer(CameraEvent.AfterDepthTexture, afterCommandBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -13,6 +13,7 @@ internal static class CameraLogic
|
||||||
private static float _dist;
|
private static float _dist;
|
||||||
private static float _scale = 1f;
|
private static float _scale = 1f;
|
||||||
private static Camera _thirdPersonCam;
|
private static Camera _thirdPersonCam;
|
||||||
|
private static Camera _uiCam;
|
||||||
private static Camera _desktopCam;
|
private static Camera _desktopCam;
|
||||||
private static int _storedCamMask;
|
private static int _storedCamMask;
|
||||||
private static CameraFovClone _cameraFovClone;
|
private static CameraFovClone _cameraFovClone;
|
||||||
|
@ -50,10 +51,11 @@ internal static class CameraLogic
|
||||||
|
|
||||||
_cameraFovClone = _thirdPersonCam.gameObject.AddComponent<CameraFovClone>();
|
_cameraFovClone = _thirdPersonCam.gameObject.AddComponent<CameraFovClone>();
|
||||||
|
|
||||||
_desktopCam = PlayerSetup.Instance.desktopCam;
|
_desktopCam = PlayerSetup.Instance.desktopCamera.GetComponent<Camera>();
|
||||||
_cameraFovClone.targetCamera = _desktopCam;
|
_cameraFovClone.targetCamera = _desktopCam;
|
||||||
|
|
||||||
_thirdPersonCam.transform.SetParent(_desktopCam.transform);
|
_thirdPersonCam.transform.SetParent(_desktopCam.transform);
|
||||||
|
_uiCam = _desktopCam.transform.Find("_UICamera").GetComponent<Camera>();
|
||||||
|
|
||||||
RelocateCam(CameraLocation.Default);
|
RelocateCam(CameraLocation.Default);
|
||||||
|
|
||||||
|
@ -64,15 +66,15 @@ internal static class CameraLogic
|
||||||
|
|
||||||
internal static void CopyPlayerCamValues()
|
internal static void CopyPlayerCamValues()
|
||||||
{
|
{
|
||||||
Camera activePlayerCam = PlayerSetup.Instance.activeCam;
|
Camera activePlayerCam = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
|
||||||
if (!_thirdPersonCam || !activePlayerCam)
|
if (_thirdPersonCam == null || activePlayerCam == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ThirdPerson.Logger.Msg("Copying active camera settings & components.");
|
ThirdPerson.Logger.Msg("Copying active camera settings & components.");
|
||||||
CVRTools.CopyToDestCam(activePlayerCam, _thirdPersonCam);
|
CVRTools.CopyToDestCam(activePlayerCam, _thirdPersonCam, true);
|
||||||
|
|
||||||
// Remove PlayerClone
|
// Remove PlayerClone
|
||||||
// _thirdPersonCam.cullingMask &= ~(1 << CVRLayers.PlayerClone);
|
_thirdPersonCam.cullingMask &= ~(1 << CVRLayers.PlayerClone);
|
||||||
|
|
||||||
if (!CheckIsRestricted())
|
if (!CheckIsRestricted())
|
||||||
return;
|
return;
|
||||||
|
@ -114,9 +116,9 @@ internal static class CameraLogic
|
||||||
|
|
||||||
private static void ResetDist() => _dist = 0;
|
private static void ResetDist() => _dist = 0;
|
||||||
internal static void ScrollDist(float sign) { _dist += sign * 0.25f; RelocateCam(CurrentLocation); }
|
internal static void ScrollDist(float sign) { _dist += sign * 0.25f; RelocateCam(CurrentLocation); }
|
||||||
internal static void AdjustScale(float avatarScaleRelation) { _scale = avatarScaleRelation; RelocateCam(CurrentLocation); }
|
internal static void AdjustScale(float height) { _scale = height; RelocateCam(CurrentLocation); }
|
||||||
internal static void CheckVRMode() { if (MetaPort.Instance.isUsingVr) State = false; }
|
internal static void CheckVRMode() { if (MetaPort.Instance.isUsingVr) State = false; }
|
||||||
|
|
||||||
private static bool CheckIsRestricted()
|
private static bool CheckIsRestricted()
|
||||||
=> CVRWorld.Instance && !CVRWorld.Instance.enableZoom;
|
=> CVRWorld.Instance != null && !CVRWorld.Instance.enableZoom;
|
||||||
}
|
}
|
|
@ -32,6 +32,6 @@ internal static class Patches
|
||||||
//Copy camera settings & postprocessing components
|
//Copy camera settings & postprocessing components
|
||||||
private static void OnPostWorldStart() => CopyPlayerCamValues();
|
private static void OnPostWorldStart() => CopyPlayerCamValues();
|
||||||
//Adjust camera distance with height as modifier
|
//Adjust camera distance with height as modifier
|
||||||
private static void OnScaleAdjusted(ref float ____avatarScaleRelation) => AdjustScale(____avatarScaleRelation);
|
private static void OnScaleAdjusted(float height) => AdjustScale(height);
|
||||||
private static void OnConfigureHudAffinity() => CheckVRMode();
|
private static void OnConfigureHudAffinity() => CheckVRMode();
|
||||||
}
|
}
|
|
@ -27,6 +27,6 @@ using System.Reflection;
|
||||||
namespace NAK.ThirdPerson.Properties;
|
namespace NAK.ThirdPerson.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "1.1.2";
|
public const string Version = "1.1.1";
|
||||||
public const string Author = "Davi & NotAKidoS";
|
public const string Author = "Davi & NotAKidoS";
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
"_id": 16,
|
"_id": 16,
|
||||||
"name": "ThirdPerson",
|
"name": "ThirdPerson",
|
||||||
"modversion": "1.1.2",
|
"modversion": "1.1.1",
|
||||||
"gameversion": "2025r179",
|
"gameversion": "2025r179",
|
||||||
"loaderversion": "0.6.1",
|
"loaderversion": "0.6.1",
|
||||||
"modtype": "Mod",
|
"modtype": "Mod",
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
"requirements": [],
|
"requirements": [],
|
||||||
"downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/ThirdPerson.dll",
|
"downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/ThirdPerson.dll",
|
||||||
"sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/ThirdPerson",
|
"sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/ThirdPerson",
|
||||||
"changelog": "- Adjusted the local player scaled event patch to work both on Stable and Nightly (r179 & r180)",
|
"changelog": "- Recompiled for 2025r179",
|
||||||
"embedcolor": "#F61961"
|
"embedcolor": "#F61961"
|
||||||
}
|
}
|
||||||
]
|
]
|
Loading…
Add table
Add a link
Reference in a new issue