private IEnumerator Take360Screenshot(bool in3D)
        {
            yield return(new WaitForEndOfFrame());

            if (!in3D)
            {
                yield return(new WaitForEndOfFrame());

                var output  = I360Render.CaptureTex(Resolution360.Value);
                var capture = EncodeToXmpFile(output);

                var filename = GetUniqueFilename("360");
                File.WriteAllBytes(filename, capture);

                Logger.Log(ScreenshotMessage.Value ? LogLevel.Message : LogLevel.Info, $"360 screenshot saved to {filename}");

                Destroy(output);
            }
            else
            {
                var targetTr = Camera.main.transform;

                ToggleCameraControllers(targetTr, false);
                Time.timeScale = 0.01f;
                yield return(new WaitForEndOfFrame());

                targetTr.position += targetTr.right * EyeSeparation.Value / 2;
                // Let the game render at the new position
                yield return(new WaitForEndOfFrame());

                var capture = I360Render.CaptureTex(Resolution360.Value);

                targetTr.position -= targetTr.right * EyeSeparation.Value;
                yield return(new WaitForEndOfFrame());

                var capture2 = I360Render.CaptureTex(Resolution360.Value);

                targetTr.position += targetTr.right * EyeSeparation.Value / 2;

                ToggleCameraControllers(targetTr, true);
                Time.timeScale = 1;

                // Overlap is useless for these so don't use
                var result = StitchImages(capture, capture2, 0);

                var filename = GetUniqueFilename("3D-360");
                File.WriteAllBytes(filename, EncodeToXmpFile(result));

                Logger.Log(ScreenshotMessage.Value ? LogLevel.Message : LogLevel.Info, $"3D 360 screenshot saved to {filename}");

                Destroy(result);
                Destroy(capture);
                Destroy(capture2);
            }

            Utils.Sound.Play(SystemSE.photo);
        }
        protected void Awake()
        {
            if (Instance)
            {
                DestroyImmediate(this);
                return;
            }
            Instance = this;
            Logger   = base.Logger;

            KeyCapture      = new SavedKeyboardShortcut(Config, "Take UI screenshot", "Capture a simple \"as you see it\" screenshot of the game. Not affected by settings for rendered screenshots.", new KeyboardShortcut(KeyCode.F9));
            KeyCaptureAlpha = new SavedKeyboardShortcut(Config, "Take rendered screenshot", null, new KeyboardShortcut(KeyCode.F11));
            KeyCapture360   = new SavedKeyboardShortcut(Config, "Take 360 screenshot", "Captures a 360 screenshot around current camera. The created image is in equirectangular format and can be viewed by most 360 image viewers (e.g. Google Cardboard).", new KeyboardShortcut(KeyCode.F11, KeyCode.LeftControl));
            KeyGui          = new SavedKeyboardShortcut(Config, "Open settings window", null, new KeyboardShortcut(KeyCode.F11, KeyCode.LeftShift));

            KeyCaptureAlphaIn3D = new SavedKeyboardShortcut(Config, "Take rendered 3D screenshot", "Capture a high quality screenshot without UI in stereoscopic 3D (2 captures for each eye in one image). These images can be viewed by crossing your eyes or any stereoscopic image viewer.", new KeyboardShortcut(KeyCode.F11, KeyCode.LeftAlt));
            KeyCapture360in3D   = new SavedKeyboardShortcut(Config, "Take 360 3D screenshot", "Captures a 360 screenshot around current camera in stereoscopic 3D (2 captures for each eye in one image). These images can be viewed by image viewers supporting 3D stereo format (e.g. VR Media Player - 360° Viewer).", new KeyboardShortcut(KeyCode.F11, KeyCode.LeftControl, KeyCode.LeftShift));

            Resolution360 = Config.Wrap("360 Screenshots", "360 screenshot resolution", "Horizontal resolution (width) of 360 degree/panorama screenshots. Decrease if you have issues. WARNING: Memory usage can get VERY high - 4096 needs around 4GB of free RAM/VRAM to create, 8192 will need much more.", 4096);

            DownscalingRate       = Config.Wrap("Render Settings", "Screenshot upsampling ratio", "Capture screenshots in a higher resolution and then downscale them to desired size. Prevents aliasing, perserves small details and gives a smoother result, but takes longer to create.", 2);
            CardDownscalingRate   = Config.Wrap("Render Settings", "Card image upsampling ratio", "Capture character card images in a higher resolution and then downscale them to desired size. Prevents aliasing, perserves small details and gives a smoother result, but takes longer to create.", 3);
            CaptureAlpha          = Config.Wrap("Render Settings", "Transparency in rendered screenshots", "Replaces background with transparency in rendered image. Works only if there are no 3D objects covering the background (e.g. the map). Works well in character creator and studio.", true);
            ScreenshotMessage     = Config.Wrap("General", "Show messages on screen", "Whether screenshot messages will be displayed on screen. Messages will still be written to the log.", true);
            ResolutionX           = Config.Wrap("Render Output Resolution", "Horizontal", "Horizontal size (width) of rendered screenshots in pixels. Doesn't affect UI and 360 screenshots.", Screen.width);
            ResolutionY           = Config.Wrap("Render Output Resolution", "Vertical", "Vertical size (height) of rendered screenshots in pixels. Doesn't affect UI and 360 screenshots.", Screen.height);
            EyeSeparation         = Config.Wrap("3D Settings", "3D screenshot eye separation", "Distance between the two captured stereoscopic screenshots in arbitrary units.", 0.18f);
            ImageSeparationOffset = Config.Wrap("3D Settings", "3D screenshot image separation offset", "Move images in stereoscopic screenshots closer together by this percentage (discards overlapping parts). Useful for viewing with crossed eyes. Does not affect 360 stereoscopic screenshots.", 0.25f);
            UseJpg     = Config.Wrap("JPG Settings", "Save screenshots as .jpg instead of .png", "Save screenshots in lower quality in return for smaller file sizes. Transparency is NOT supported in .jpg screenshots. Strongly consider not using this option if you want to share your work.", false);
            JpgQuality = Config.Wrap("3D Settings", "Quality of .jpg files", "Lower quality = lower file sizes. Even 100 is worse than a .png file.", 100);
            //TODO:ScreenshotNameFormat = Config.Wrap("General", "Screenshot filename format", "Screenshots will be saved with names of the selected format. Name stands for the current game name (CharaStudio, Koikatu, etc.)", NameFormat.NameDateType);
            ScreenshotNameOverride = Config.Wrap("General", "Screenshot filename Name override", "Forces the Name part of the filename to always be this instead of varying depending on the name of the current game. Use \"Koikatsu\" to get the old filename behaviour.", "");

            ResolutionX.SettingChanged += (sender, args) => ResolutionXBuffer = ResolutionX.Value.ToString();
            ResolutionY.SettingChanged += (sender, args) => ResolutionYBuffer = ResolutionY.Value.ToString();

            SceneManager.sceneLoaded += (s, a) => InstallSceenshotHandler();
            InstallSceenshotHandler();

            if (!Directory.Exists(screenshotDir))
            {
                Directory.CreateDirectory(screenshotDir);
            }

            Hooks.InstallHooks();

            I360Render.Init();
        }
示例#3
0
        protected void Awake()
        {
            if (Instance)
            {
                DestroyImmediate(this);
                return;
            }
            Instance            = this;
            CK_Capture          = new SavedKeyboardShortcut("Take UI screenshot", this, new KeyboardShortcut(KeyCode.F9));
            CK_CaptureAlpha     = new SavedKeyboardShortcut("Take rendered screenshot", this, new KeyboardShortcut(KeyCode.F11));
            CK_Capture360       = new SavedKeyboardShortcut("Take 360 screenshot", this, new KeyboardShortcut(KeyCode.F11, KeyCode.LeftControl));
            CK_CaptureAlphaIn3D = new SavedKeyboardShortcut("Take rendered 3D screenshot", this, new KeyboardShortcut(KeyCode.F11, KeyCode.LeftAlt));
            CK_Capture360in3D   = new SavedKeyboardShortcut("Take 360 3D screenshot", this, new KeyboardShortcut(KeyCode.F11, KeyCode.LeftControl, KeyCode.LeftShift));
            CK_Gui = new SavedKeyboardShortcut("Open settings window", this, new KeyboardShortcut(KeyCode.F11, KeyCode.LeftShift));

            ResolutionX           = new ConfigWrapper <int>("resolution-x", this, Screen.width);
            ResolutionY           = new ConfigWrapper <int>("resolution-y", this, Screen.height);
            Resolution360         = new ConfigWrapper <int>("resolution-360", this, 4096);
            EyeSeparation         = new ConfigWrapper <float>("3d-eye-separation", this, 0.18f);
            ImageSeparationOffset = new ConfigWrapper <float>("3d-image-stitching-offset", this, 0.25f);

            ResolutionX.SettingChanged += (sender, args) => ResolutionXBuffer = ResolutionX.Value.ToString();
            ResolutionY.SettingChanged += (sender, args) => ResolutionYBuffer = ResolutionY.Value.ToString();

            DownscalingRate     = new ConfigWrapper <int>("downscalerate", this, 2);
            CardDownscalingRate = new ConfigWrapper <int>("carddownscalerate", this, 3);
            CaptureAlpha        = new ConfigWrapper <bool>("capturealpha", this, true);

            UseJpg     = new ConfigWrapper <bool>("jpg", this, false);
            JpgQuality = new ConfigWrapper <int>("jpg-quality", this, 100);

            ScreenshotMessage      = new ConfigWrapper <bool>("screenshotmessage", this, true);
            ScreenshotNameFormat   = new ConfigWrapper <NameFormat>("screenshot-name-format", this, NameFormat.NameDateType);
            ScreenshotNameOverride = new ConfigWrapper <string>("screenshot-name-override", this, "");

            SceneManager.sceneLoaded += (s, a) => InstallSceenshotHandler();
            InstallSceenshotHandler();

            if (!Directory.Exists(screenshotDir))
            {
                Directory.CreateDirectory(screenshotDir);
            }

            Hooks.InstallHooks();

            I360Render.Init();
        }
示例#4
0
        private IEnumerator Take360Screenshot()
        {
            yield return(new WaitForEndOfFrame());

            try
            {
                var filename = GetUniqueFilename();
                File.WriteAllBytes(filename, I360Render.Capture(Resolution360.Value, false));

                Utils.Sound.Play(SystemSE.photo);
                BepInEx.Logger.Log(ScreenshotMessage.Value ? LogLevel.Message : LogLevel.Info, $"360 screenshot saved to {filename}");
            }
            catch (Exception e)
            {
                BepInEx.Logger.Log(LogLevel.Message | LogLevel.Error, "Failed to take a 360 screenshot - " + e.Message);
                BepInEx.Logger.Log(LogLevel.Error, e.StackTrace);
            }
        }
        protected void Awake()
        {
            Instance = this;
            Logger   = base.Logger;

            InitializeSettings();

            ResolutionX.SettingChanged += (sender, args) => ResolutionXBuffer = ResolutionX.Value.ToString();
            ResolutionY.SettingChanged += (sender, args) => ResolutionYBuffer = ResolutionY.Value.ToString();

            SceneManager.sceneLoaded += (s, a) => InstallSceenshotHandler();
            InstallSceenshotHandler();

            if (!Directory.Exists(screenshotDir))
            {
                Directory.CreateDirectory(screenshotDir);
            }

            Hooks.InstallHooks();

            I360Render.Init();
        }
示例#6
0
        protected void Awake()
        {
            if (Instance)
            {
                GameObject.DestroyImmediate(this);
                return;
            }
            Instance        = this;
            CK_Capture      = new SavedKeyboardShortcut("Take UI screenshot", this, new KeyboardShortcut(KeyCode.F9));
            CK_CaptureAlpha = new SavedKeyboardShortcut("Take rendered screenshot", this, new KeyboardShortcut(KeyCode.F11));
            CK_Capture360   = new SavedKeyboardShortcut("Take 360 screenshot", this, new KeyboardShortcut(KeyCode.F11, KeyCode.LeftControl));
            CK_Gui          = new SavedKeyboardShortcut("Open settings window", this, new KeyboardShortcut(KeyCode.F11, KeyCode.LeftShift));

            ResolutionX   = new ConfigWrapper <int>("resolution-x", this, Screen.width);
            ResolutionY   = new ConfigWrapper <int>("resolution-y", this, Screen.height);
            Resolution360 = new ConfigWrapper <int>("resolution-360", this, 4096);

            ResolutionX.SettingChanged += (sender, args) => ResolutionXBuffer = ResolutionX.Value.ToString();
            ResolutionY.SettingChanged += (sender, args) => ResolutionYBuffer = ResolutionY.Value.ToString();

            DownscalingRate     = new ConfigWrapper <int>("downscalerate", this, 2);
            CardDownscalingRate = new ConfigWrapper <int>("carddownscalerate", this, 3);
            CaptureAlpha        = new ConfigWrapper <bool>("capturealpha", this, true);
            ScreenshotMessage   = new ConfigWrapper <bool>("screenshotmessage", this, true);

            SceneManager.sceneLoaded += (s, a) => InstallSceenshotHandler();
            InstallSceenshotHandler();

            if (!Directory.Exists(screenshotDir))
            {
                Directory.CreateDirectory(screenshotDir);
            }

            Hooks.InstallHooks();

            I360Render.Init();
        }
 private static byte[] EncodeToXmpFile(Texture2D result) => UseJpg.Value ? I360Render.InsertXMPIntoTexture2D_JPEG(result, JpgQuality.Value) : I360Render.InsertXMPIntoTexture2D_PNG(result);