mirror of
https://github.com/Raicuparta/nomai-vr.git
synced 2025-12-11 20:15:08 +01:00
Fix alarm cones, add UnityExplorer support (#479)
* Add unityexplorer code, fix issues for DebugCheats early adopters * Fix alarm cones * Set projection matrices once, swapped shader for hands to avoid glow * Use proper material for hands * Moved UnityExplorer to a better place Co-authored-by: Raicuparta <raicuparta@gmail.com>
This commit is contained in:
parent
d79e304505
commit
0259bd184c
@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using Valve.VR;
|
||||
|
||||
namespace NomaiVR
|
||||
@ -19,13 +20,14 @@ namespace NomaiVR
|
||||
// Wake up in dream (requires invincibility).
|
||||
if (SteamVR_Actions.default_Interact.stateDown)
|
||||
{
|
||||
var workingLantern = FindObjectsOfType<DreamLanternItem>().Where(x => x._lanternType == DreamLanternType.Functioning).FirstOrDefault();
|
||||
var dreamWorldController = FindObjectOfType<DreamWorldController>();
|
||||
dreamWorldController._dreamCampfire = FindObjectOfType<DreamCampfire>();
|
||||
dreamWorldController._dreamArrivalPoint = FindObjectOfType<DreamArrivalPoint>();
|
||||
dreamWorldController._relativeSleepLocation = new RelativeLocationData(new Vector3(0f, 1f, -2f), Quaternion.identity, Vector3.zero);
|
||||
dreamWorldController._playerLantern = FindObjectOfType<DreamLanternItem>();
|
||||
dreamWorldController._playerLantern = workingLantern;
|
||||
dreamWorldController._enteringDream = true;
|
||||
FindObjectOfType<ItemTool>().MoveItemToCarrySocket(FindObjectOfType<DreamLanternItem>());
|
||||
FindObjectOfType<ItemTool>().MoveItemToCarrySocket(workingLantern);
|
||||
}
|
||||
|
||||
// Start mind projection.
|
||||
|
||||
@ -10,6 +10,7 @@ namespace NomaiVR.EffectFixes
|
||||
protected override OWScene[] Scenes => PlayableScenes;
|
||||
private static float prePauseFovFactor = 1;
|
||||
private static bool isPaused;
|
||||
internal static Material totemEyeMaterial;
|
||||
|
||||
public class Patch : NomaiVRPatch
|
||||
{
|
||||
@ -38,6 +39,9 @@ namespace NomaiVR.EffectFixes
|
||||
Postfix<SimulationCamera>(nameof(SimulationCamera.DeallocateRenderTex), nameof(Post_SimulationCamera_DeallocateRenderTex));
|
||||
Prefix<SimulationCamera>(nameof(SimulationCamera.AllocateRenderTex), nameof(Pre_SimulationCamera_AllocateRenderTex));
|
||||
Prefix<SimulationCamera>(nameof(SimulationCamera.VerifyRenderTexResolution), nameof(Pre_SimulationCamera_VerifyRenderTexResolution));
|
||||
|
||||
//Hand materials
|
||||
Postfix<AlarmTotem>(nameof(AlarmTotem.Start), nameof(Post_AlarmTotem_Start));
|
||||
}
|
||||
|
||||
public static void DisableScreenSpaceReflections(PostProcessingGameplaySettings __instance)
|
||||
@ -158,6 +162,7 @@ namespace NomaiVR.EffectFixes
|
||||
if (__instance._targetCamera != null && __instance._targetCamera.mainCamera.stereoEnabled)
|
||||
{
|
||||
__instance.GetComponentInChildren<SupportSimulationCamera>().enabled = true;
|
||||
GraphicsHelper.SetCameraEyeProjectionMatrix(__instance._camera, Valve.VR.EVREye.Eye_Left);
|
||||
}
|
||||
|
||||
GlobalMessenger.FireEvent("SimulationEnter");
|
||||
@ -179,7 +184,7 @@ namespace NomaiVR.EffectFixes
|
||||
{
|
||||
return;
|
||||
}
|
||||
GraphicsHelper.ForceCameraToEye(__instance._camera, __instance._targetCamera.mainCamera, Valve.VR.EVREye.Eye_Left);
|
||||
GraphicsHelper.ForceCameraToEye(__instance._camera, __instance._targetCamera.mainCamera.transform, Valve.VR.EVREye.Eye_Left);
|
||||
}
|
||||
|
||||
private static void Pre_SimulationCamera_VerifyRenderTexResolution(SimulationCamera __instance)
|
||||
@ -196,6 +201,12 @@ namespace NomaiVR.EffectFixes
|
||||
{
|
||||
__instance.GetComponentInChildren<SupportSimulationCamera>().DeallocateTexture();
|
||||
}
|
||||
|
||||
private static void Post_AlarmTotem_Start(AlarmTotem __instance)
|
||||
{
|
||||
if (totemEyeMaterial == null)
|
||||
totemEyeMaterial = new Material(__instance._origSimEyeMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NomaiVR.Assets;
|
||||
using NomaiVR.EffectFixes;
|
||||
using NomaiVR.Helpers;
|
||||
using NomaiVR.ReusableBehaviours;
|
||||
using NomaiVR.Tools;
|
||||
@ -33,6 +34,8 @@ namespace NomaiVR.Hands
|
||||
|
||||
private Renderer handRenderer;
|
||||
private Renderer gloveRenderer;
|
||||
private Material[] originalHandMaterials;
|
||||
private Material[] originalGloveMaterials;
|
||||
private EHandState handState = EHandState.Free;
|
||||
private EHandState lastHandState = EHandState.Free;
|
||||
private NomaiVRHandSkeleton skeleton;
|
||||
@ -130,16 +133,32 @@ namespace NomaiVR.Hands
|
||||
{
|
||||
handRenderer.gameObject.layer = LayerMask.NameToLayer("DreamSimulation");
|
||||
gloveRenderer.gameObject.layer = LayerMask.NameToLayer("DreamSimulation");
|
||||
SetUpShaders(handRenderer, "Outer Wilds/Environment/Invisible Planet/Cyberspace", "Outer Wilds/Environment/Invisible Planet/Cyberspace");
|
||||
SetUpShaders(gloveRenderer, "Outer Wilds/Environment/Invisible Planet/Cyberspace");
|
||||
|
||||
if(originalHandMaterials == null)
|
||||
originalHandMaterials = handRenderer.sharedMaterials;
|
||||
if (originalGloveMaterials == null)
|
||||
originalGloveMaterials = gloveRenderer.sharedMaterials;
|
||||
|
||||
handRenderer.sharedMaterials = MakeSimulationMaterials(originalHandMaterials.Length);
|
||||
gloveRenderer.sharedMaterials = MakeSimulationMaterials(originalGloveMaterials.Length);
|
||||
}
|
||||
|
||||
private Material[] MakeSimulationMaterials(int size)
|
||||
{
|
||||
Material[] mats = new Material[size];
|
||||
for (int i = 0; i < mats.Length; i++)
|
||||
mats[i] = DreamFix.totemEyeMaterial;
|
||||
return mats;
|
||||
}
|
||||
|
||||
private void OnSimulationExit()
|
||||
{
|
||||
handRenderer.gameObject.layer = LayerMask.NameToLayer("Default");
|
||||
gloveRenderer.gameObject.layer = LayerMask.NameToLayer("Default");
|
||||
SetUpShaders(handRenderer, "Outer Wilds/Character/Skin", "Outer Wilds/Character/Skin");
|
||||
SetUpShaders(gloveRenderer, "Outer Wilds/Character/Clothes");
|
||||
handRenderer.sharedMaterials = originalHandMaterials;
|
||||
gloveRenderer.sharedMaterials = originalGloveMaterials;
|
||||
originalHandMaterials = null;
|
||||
originalGloveMaterials = null;
|
||||
}
|
||||
|
||||
private void SetUpShaders(Renderer renderer, params string[] shader)
|
||||
|
||||
@ -5,11 +5,16 @@ namespace NomaiVR.Helpers
|
||||
{
|
||||
public static class GraphicsHelper
|
||||
{
|
||||
public static void ForceCameraToEye(Camera targetCamera, Camera monoCamera, EVREye eye)
|
||||
private static readonly Matrix4x4 scaleBiasDXToGL = Matrix4x4.TRS(Vector3.back, Quaternion.identity, new Vector3(1, 1, 2));
|
||||
public static void ForceCameraToEye(Camera targetCamera, Transform headTransform, EVREye eye)
|
||||
{
|
||||
targetCamera.transform.position = monoCamera.transform.TransformPoint(SteamVR.instance.eyes[(int)eye].pos);
|
||||
targetCamera.transform.rotation = monoCamera.transform.rotation * SteamVR.instance.eyes[(int)eye].rot;
|
||||
targetCamera.projectionMatrix = GetSteamVREyeProjection(monoCamera, eye);
|
||||
targetCamera.transform.position = headTransform.TransformPoint(SteamVR.instance.eyes[(int)eye].pos);
|
||||
targetCamera.transform.rotation = headTransform.rotation * SteamVR.instance.eyes[(int)eye].rot;
|
||||
}
|
||||
|
||||
public static void SetCameraEyeProjectionMatrix(Camera targetCamera, EVREye eye)
|
||||
{
|
||||
targetCamera.projectionMatrix = scaleBiasDXToGL * GetSteamVREyeProjection(targetCamera, eye);
|
||||
}
|
||||
|
||||
public static Matrix4x4 GetSteamVREyeProjection(Camera cam, EVREye eye)
|
||||
|
||||
@ -66,6 +66,11 @@ namespace NomaiVR
|
||||
new VirtualKeyboard();
|
||||
new Menus();
|
||||
new FixProbeCannonVisibility();
|
||||
|
||||
//Load UnityExplorer if enabled
|
||||
#if UNITYEXPLORER
|
||||
UnityExplorer.ExplorerStandalone.CreateInstance();
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void InitSteamVR()
|
||||
|
||||
@ -57,8 +57,8 @@
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="netstandard">
|
||||
<HintPath>$(GameDir)\OuterWilds_Data\Managed\netstandard.dll</HintPath>
|
||||
<Reference Include="UnityExplorer.STANDALONE.Mono">
|
||||
<HintPath>$(OwmlDir)\$(ModDir)\UnityExplorer.STANDALONE.Mono.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Valve.Newtonsoft.Json">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
||||
@ -46,6 +46,7 @@ namespace NomaiVR.ReusableBehaviours.Dream
|
||||
private void OnEnable()
|
||||
{
|
||||
camera.enabled = true;
|
||||
GraphicsHelper.SetCameraEyeProjectionMatrix(camera, Valve.VR.EVREye.Eye_Right);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@ -97,7 +98,7 @@ namespace NomaiVR.ReusableBehaviours.Dream
|
||||
private void OnPreRender()
|
||||
{
|
||||
if (simulationCamera == null || simulationCamera._targetCamera == null) return;
|
||||
GraphicsHelper.ForceCameraToEye(camera, simulationCamera._targetCamera.mainCamera, Valve.VR.EVREye.Eye_Right);
|
||||
GraphicsHelper.ForceCameraToEye(camera, simulationCamera._targetCamera.mainCamera.transform, Valve.VR.EVREye.Eye_Right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,11 +110,13 @@ namespace NomaiVRPatcher
|
||||
|
||||
var replacers = new List<AssetsReplacer>();
|
||||
|
||||
#if !UNITYEXPLORER
|
||||
var playerSettings = assetsFileTable.GetAssetInfo(1);
|
||||
var playerSettingsBase = assetsManager.GetTypeInstance(assetsFile, playerSettings).GetBaseField();
|
||||
var disableOldInputManagerSupport = playerSettingsBase.Get("enableNativePlatformBackendsForNewInputSystem");
|
||||
disableOldInputManagerSupport.value = new AssetTypeValue(EnumValueTypes.ValueType_Bool, false);
|
||||
replacers.Add(new AssetsReplacerFromMemory(0, playerSettings.index, (int)playerSettings.curFileType, 0xffff, playerSettingsBase.WriteToByteArray()));
|
||||
#endif
|
||||
|
||||
|
||||
var buildSettings = assetsFileTable.GetAssetInfo(11);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user