R.E.P.O.
Install

Details

Last Updated
First Uploaded
Downloads
11K
Likes
2
Size
44KB
Dependency string
Rbmukthegreat-REPOTrueUltrawide-1.0.0
Dependants

Categories

True Ultrawide Mod

This is only current mod that gives ultrawide without that awful stretching. It works by removing the black bars and then changing the vertical FOV (which is more complicated than it should be). I have only tested this on 32:9. If 21:9 looks bad, compile it yourself and change the FOV. Finally, I have taken the creative liberty to remove the post processing.

Source code:

using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

namespace REPOTrueUltrawide
{
    [BepInPlugin("REPOTrueUltrawide", "REPO True Ultrawide", "1.0.0")]
    public class REPOTrueUltrawidePlugin : BaseUnityPlugin
    {
        public static ConfigEntry<float> BaseFov;

        private void Awake()
        {
            Logger.LogInfo("REPO True Ultrawide v1.0.0 loaded!");
            Logger.LogInfo($"Aspect ratio: {(float)Screen.width / (float)Screen.height}");

            BaseFov = Config.Bind(
                "FOV",
                "FOV",
                70f,
                new ConfigDescription(
                    "The FOV, 90 is good for 32:9.",
                    new AcceptableValueRange<float>(50f, 110f)
                )
            );

            Harmony harmony = new Harmony("REPOTrueUltrawide");
            harmony.PatchAll();
        }
    }

    [HarmonyPatch(typeof(GraphicsManager), "Update")]
    public class StretchingPatch
    {
        public static void Postfix()
        {
            float aspectRatio = (float)Screen.width / (float)Screen.height;
            var rto = GameObject.Find("Render Texture Overlay");
            var rtm = GameObject.Find("Render Texture Main");

            // Remove Black Bars!
            if (rto && rtm)
            {
                var rtort = rto.GetComponent<RectTransform>();
                var rtmrt = rtm.GetComponent<RectTransform>();
                if (rtort && rtmrt)
                {
                    rtort.sizeDelta = new Vector2(428 * aspectRatio, 428);
                    rtmrt.sizeDelta = new Vector2(428 * aspectRatio, 428);
                }
                else
                {
                    rtort.sizeDelta = new Vector2(750, 750 / aspectRatio);
                    rtmrt.sizeDelta = new Vector2(750, 750 / aspectRatio);
                }
            }

            // Fix Vertical FOV!
            Camera mainCamera = GameDirector.instance.MainCamera;
            float baseFOV = REPOTrueUltrawidePlugin.BaseFov.Value;
            float correctedFOV = 2f * Mathf.Atan(
                Mathf.Tan(baseFOV * Mathf.Deg2Rad / 2f) * (16f / 9f) / aspectRatio
            ) * Mathf.Rad2Deg;

            mainCamera.aspect = aspectRatio;
            mainCamera.fieldOfView = correctedFOV;

            // DESTROY POST PROCESSING
            var postprocessing = GameObject.Find("Post Processing Overlay");
            if (postprocessing)
                postprocessing.SetActive(false);
        }
    }
}```
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.