Skip to content

Commit

Permalink
More immersion settings (#422)
Browse files Browse the repository at this point in the history
* Added some immersion settings (HUD opacity, Feet/Hand laser visibility)

* UnityExplorer compatibility

* Bump version
  • Loading branch information
artumino authored Jul 2, 2021
1 parent 08f86b7 commit bb2360d
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 18 deletions.
6 changes: 5 additions & 1 deletion NomaiVR/Hands/LaserPointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,14 @@ private void UpdateLineVisibility()
{
_lineRenderer.enabled = false;
}
else if (!_lineRenderer.enabled && !isUsingTool)
else if(!_lineRenderer.enabled && InputHelper.IsUIInteractionMode(true))
{
_lineRenderer.enabled = true;
}
else if (!isUsingTool && !InputHelper.IsUIInteractionMode(true) && _lineRenderer.enabled != ModSettings.EnableHandLaser)
{
_lineRenderer.enabled = ModSettings.EnableHandLaser;
}
}

private bool IsPaused()
Expand Down
6 changes: 6 additions & 0 deletions NomaiVR/ModConfig/ModSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ public static class ModSettings
public static int OverrideRefreshRate { get; private set; }
public static float VibrationStrength { get; private set; }
public static bool EnableGesturePrompts { get; private set; }
public static bool EnableHandLaser { get; private set; }
public static bool EnableFeetMarker { get; private set; }
public static bool ControllerOrientedMovement { get; private set; }
public static bool AutoHideToolbelt { get; private set; }
public static bool BypassFatalErrors { get; private set; }
public static float ToolbeltHeight { get; private set; }
public static float HudScale { get; private set; }
public static float HudOpacity { get; private set; }

public static void SetConfig(IModConfig config)
{
Expand All @@ -29,10 +32,13 @@ public static void SetConfig(IModConfig config)
ShowHelmet = config.GetSettingsValue<bool>("helmetVisibility");
ControllerOrientedMovement = config.GetSettingsValue<bool>("movementControllerOriented");
EnableGesturePrompts = config.GetSettingsValue<bool>("showGesturePrompts");
EnableHandLaser = config.GetSettingsValue<bool>("showHandLaser");
EnableFeetMarker = config.GetSettingsValue<bool>("showFeetMarker");
PreventCursorLock = config.GetSettingsValue<bool>("disableCursorLock");
DebugMode = config.GetSettingsValue<bool>("debug");
AutoHideToolbelt = config.GetSettingsValue<bool>("autoHideToolbelt");
HudScale = config.GetSettingsValue<float>("hudScale");
HudOpacity = config.GetSettingsValue<float>("hudOpacity");
BypassFatalErrors = config.GetSettingsValue<bool>("bypassFatalErrors");

// OWML doesn't support negative slider values so I subtract it here.
Expand Down
25 changes: 23 additions & 2 deletions NomaiVR/ModConfig/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"refreshRateOverride": {
"type": "selector",
"value": 0,
"options": [0, 30, 60, 70, 72, 80, 90, 120, 144],
"options": [ 0, 30, 60, 70, 72, 80, 90, 120, 144 ],
"title": "Physics refresh rate (zero = sync with HMD)"
},
"vibrationIntensity": {
Expand Down Expand Up @@ -49,6 +49,13 @@
"max": 1.8,
"title": "Helmet HUD scale"
},
"hudOpacity": {
"type": "slider",
"value": 1,
"min": 0,
"max": 1,
"title": "Helmet HUD Opacity"
},
"movementControllerOriented": {
"type": "toggle",
"value": false,
Expand All @@ -63,6 +70,20 @@
"yes": "Enabled",
"no": "Disabled"
},
"showHandLaser": {
"type": "toggle",
"value": true,
"title": "Hand laser pointer",
"yes": "Show",
"no": "Hide"
},
"showFeetMarker": {
"type": "toggle",
"value": true,
"title": "Feet markers",
"yes": "Show",
"no": "Hide"
},
"disableCursorLock": {
"type": "toggle",
"value": true,
Expand All @@ -72,7 +93,7 @@
},
"debug": {
"type": "toggle",
"value": true,
"value": false,
"title": "Debug mode (more logs)",
"yes": "Enabled",
"no": "Disabled"
Expand Down
19 changes: 18 additions & 1 deletion NomaiVR/Player/FeetMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ internal class FeetMarker : NomaiVRModule<FeetMarker.Behaviour, NomaiVRModule.Em

public class Behaviour : MonoBehaviour
{
private SpriteRenderer _renderer;

internal void Start()
{
var marker = Instantiate(AssetLoader.FeetPositionPrefab).transform;
Expand All @@ -18,7 +20,22 @@ internal void Start()
marker.localScale *= 0.75f;
LayerHelper.ChangeLayerRecursive(marker.gameObject, "VisibleToPlayer");

marker.GetComponentInChildren<SpriteRenderer>().material = MaterialHelper.GetOverlayMaterial();
_renderer = marker.GetComponentInChildren<SpriteRenderer>();
_renderer.material = MaterialHelper.GetOverlayMaterial();

SetFeetMarkerVisibility();

ModSettings.OnConfigChange += SetFeetMarkerVisibility;
}

internal void OnDestroy()
{
ModSettings.OnConfigChange -= SetFeetMarkerVisibility;
}

void SetFeetMarkerVisibility()
{
_renderer.enabled = ModSettings.EnableFeetMarker;
}
}
}
Expand Down
26 changes: 14 additions & 12 deletions NomaiVR/UI/HelmetHUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,40 @@ public class Behaviour : MonoBehaviour
{
private static Transform _thrusterHUD;
private Transform _helmet;
private HUDHelmetAnimator _helmetAnimator;
private static Behaviour _instance;

internal void Awake()
{
_instance = this;

FixCameraClipping();
var helmetAnimator = SetUpHelmetAnimator();
var helmet = SetUpHelmet(helmetAnimator);
_helmetAnimator = SetUpHelmetAnimator();
var helmet = SetUpHelmet(_helmetAnimator);
CreateForwardIndicator(helmet);
ReplaceHelmetModel(helmet);
AdjustHudRenderer(helmetAnimator);
AdjustHudRenderer(_helmetAnimator);
var playerHud = GetPlayerHud(helmet);
FixLockOnUI(playerHud);
HideHudDuringDialogue(playerHud);
SetHelmetScale();
ModSettings.OnConfigChange += SetHelmetScale;
SetHelmetScaleAndHUDOpacity();
ModSettings.OnConfigChange += SetHelmetScaleAndHUDOpacity;
}

internal void OnDestroy()
{
ModSettings.OnConfigChange -= SetHelmetScale;
ModSettings.OnConfigChange -= SetHelmetScaleAndHUDOpacity;
}

public static void SetHelmetScale()
public void SetHelmetScaleAndHUDOpacity()
{
var helmet = _instance?._helmet;
if (!helmet)
if (_helmet)
{
return;
_helmet.localScale = new Vector3(ModSettings.HudScale, ModSettings.HudScale, 1f) * 0.5f;
var uiColor = _helmetAnimator._hudRenderer.material.color;
uiColor.a = ModSettings.HudOpacity * ModSettings.HudOpacity; //Squared for more drastic changes
_helmetAnimator._hudRenderer.material.SetColor("_Color", uiColor);
}
helmet.localScale = new Vector3(ModSettings.HudScale, ModSettings.HudScale, 1f) * 0.5f;
}

private void FixCameraClipping()
Expand Down Expand Up @@ -103,7 +105,7 @@ private void AdjustHudRenderer(HUDHelmetAnimator helmetAnimator)

// HUD shader looks funky in stereo, so it needs to be replaced.
var surfaceRenderer = hudRenderer.GetComponent<MeshRenderer>();
surfaceRenderer.material.SetColor("_Color", new Color(1.5f, 1.5f, 1.5f, 1));
surfaceRenderer.material.SetColor("_Color", new Color(1.5f, 1.5f, 1.5f, surfaceRenderer.material.color.a));
MaterialHelper.MakeMaterialDrawOnTop(surfaceRenderer.material);
}

Expand Down
2 changes: 1 addition & 1 deletion NomaiVR/UI/Menus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Behaviour : MonoBehaviour
{
private static bool _shouldRenderStarLogos;
private static readonly List<Canvas> patchedCanvases = new List<Canvas>();
private static readonly string[] _ignoredCanvases = { "LoadManagerFadeCanvas", "PauseBackdropCanvas", "Reticule" };
private static readonly string[] _ignoredCanvases = { "LoadManagerFadeCanvas", "PauseBackdropCanvas", "Reticule", "ExplorerCanvas" };
private readonly List<GameObject> _canvasObjectsToHide = new List<GameObject>();
private Camera _flashbackCamera;
private Transform _flashbackCameraParent;
Expand Down
2 changes: 1 addition & 1 deletion NomaiVR/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"title": "Follow these steps before starting the game in VR:",
"body": "- Disable all other mods (can heavily affect performance);\n\n- Close SteamVR (let the game open SteamVR automatically);\n\n- Make sure your headset and both of your VR controllers are connected and working;\n\n- If you have the game on Steam:\n--- Right-click Outer Wilds on your Steam library\n--- Select 'Properties...'\n--- Disable 'Use Desktop Game Theatre.'"
},
"version": "1.2.1",
"version": "1.2.2",
"owmlVersion": "1.0.1",
"requireVR": true
}

0 comments on commit bb2360d

Please sign in to comment.