Skip to content

Commit

Permalink
Add post-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBigz committed Nov 7, 2024
1 parent 50a6a98 commit 2fb3295
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 14 additions & 6 deletions TABGVR/Patches/CameraPatch.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using DeepSky.Haze;
using HarmonyLib;
using TABGVR.Player;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.SpatialTracking;

namespace TABGVR.Patches;
Expand All @@ -11,14 +13,14 @@ public class CameraPatch
public static void Postfix(PlayerCamera __instance)
{
Plugin.Logger.LogInfo($"Camera idle: {__instance.gameObject.name}");
var playerManager = PlayerManager.FromCamera(__instance.GetComponent<Camera>());

var playerManager = PlayerManager.FromCamera(__instance.cam);

var gameObject = new GameObject("VRCamera")
{
transform =
{
parent = __instance.transform.parent.parent.parent.parent.parent.parent.parent,
parent = playerManager.playerRoot.transform.Find("CameraMovement"),
position = __instance.transform.position,
},
tag = "MainCamera",
Expand All @@ -36,11 +38,17 @@ public static void Postfix(PlayerCamera __instance)
var driver = gameObject.AddComponent<TrackedPoseDriver>();
driver.trackingType = TrackedPoseDriver.TrackingType.RotationOnly;
driver.poseSource = TrackedPoseDriver.TrackedPose.Head;


gameObject.AddComponent<FlareLayer>();
gameObject.AddComponent<DS_HazeView>();

var postProcessing = gameObject.AddComponent<PostProcessLayer>();
postProcessing.volumeTrigger = gameObject.transform;
postProcessing.volumeLayer = LayerMask.NameToLayer("Post");
postProcessing.m_Resources = __instance.GetComponent<PostProcessLayer>().m_Resources;

// var playerDriver = playerManager.playerRoot.AddComponent<PlayerDriver>();
// playerDriver.trackingType = TrackedPoseDriver.TrackingType.RotationOnly;
// playerDriver.poseSource = TrackedPoseDriver.TrackedPose.Head;

// Object.Destroy(gameObject.GetComponent<HighlightingRenderer>());
}
}
1 change: 1 addition & 0 deletions TABGVR/TABGVR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<ItemGroup>
<Reference Include="$(TABGManaged)\Assembly-CSharp.dll" Publicize="true" Private="false" />
<Reference Include="$(TABGManaged)\Assembly-CSharp-firstpass.dll" Publicize="true" Private="false" />
<Reference Include="$(TABGManaged)\Unity.Postprocessing.Runtime.dll" Publicize="true" Private="false" />
<Reference Include="$(TABGManaged)\UnityEngine.SpatialTracking.dll" Publicize="true" Private="false" />
<Reference Include="$(GameReferences)\Unity.XR.CoreUtils.dll" Publicize="true" />
<Reference Include="$(GameReferences)\Unity.XR.Interaction.Toolkit.dll" Publicize="true" />
Expand Down

0 comments on commit 2fb3295

Please sign in to comment.