%YAML 1.1 %TAG !u! tag:unity3d.com,2011: --- !u!114 &11400000 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 4510294d23d964fe59443526f1ca7c4b, type: 3} m_Name: Environment Transitions m_EditorClassIdentifier: m_displayName: Environment Transitions m_hierarchyName: Environment Transitions m_context: {fileID: 11400000, guid: ff4555072d80cd748acc8ec51a4a47e5, type: 2} m_markdownFile: {fileID: 0} m_priority: 1005 m_overrideMarkdownText: "# Implementing Environment Transitions\n\n## Overview\n\nScenes often need environment transitions to show changes in time, like moving from midnight to late morning. Each transition uses a new Environment Profile and can be either quick (0.01 seconds) or extended (5\u201350 seconds).\n\nMost transitions happen during teleport warps, limiting the number of transitions per scene. We manage these transitions carefully to ensure smooth shifts between different weather and time profiles.\n\n## Managing Transitions\n\nSometimes, we need duplicate Environment Profiles with slight variations, such as different cloud textures or ocean wind speeds, to ensure natural-looking transitions. This prevents clouds and oceans from appearing like an unnatural timelapse.\n\n**Example Scenes:**\n\n- Beat6 \u2013 Rapid time-of-day shifts within 5 teleport warps.\n- Beat3and4 \u2013 Transitioning from a clear day to a stormy night.\n\n## Environment Profile\n\nEnvironment Profiles are data assets with several parameters that allow us to create various environmental, ocean, and weather changes throughout a scene. See below for a screenshot of the data asset.\n\n![](./Images/EnvImplementation/Fig4.png)\n\n## Beat6 Scene: Example of Environment Profile Transitions\n\nTransitions in the Beat6 scene were challenging due to rapid time-of-day changes, which are difficult to convey in a few minutes and within 5 teleport warps. Beat6 required transitioning from the stormy dark weather of Beat5 to a late morning profile by the end of Beat6.\n\nBeat6 uses 6 Environment Profiles, starting with one nearly identical to the stormy night profile that ends Beat5. Key changes were crucial for seamless transitions from the dark storm profile to late morning profiles in Beat6.\n\n- The Skybox\n\n - To ensure seamless transitions, the skybox was updated so that cloud values matched the rest of the scene transitions. These include:\n\n - Cloud Offset\n - Cloud Scale\n - Cloud Speed\n - Cloud Direction\n\n - Drastic differences in these values can cause clouds to appear to lower or move unnaturally across the sky.\n\n - Different cloud textures can be used, but matching these values reduces unintended effects. Using the same cloud texture is preferable to minimize issues during longer transitions.\n\n![](./Images/EnvImplementation/Fig6.gif)\n\n- The Ocean\n\n - At the end of Beat5, the ocean is choppy with a large patch size and high wind speed. By the end of Beat6, the weather needs to be calmer and sunnier. The following were adjusted for seamless transitions:\n\n - Environment Profile Parameters:\n\n - Wind Speed\n - Directionality\n - Patch Size\n\n - Large changes in patch size were hidden behind instant transitions.\n\n - Ocean Material\n\n - Ocean Normal Map texture\n - Normals parameters\n - Smoothness\n - Displacement noise\n\nAdjusting these parameters ensures consistency between Beat4 and Beat5's stormy weather while setting up Beat6 transitions smoothly as players teleport across the boat.\n\nFor nighttime and stormy profiles, we set the Sun Disk Material to the Moon material, so water reflections come from the moon instead of the sun.\n\n- This requires instant transitions to swap the moon and sun.\n\n - A long transition would make the moon's position change rapidly like a timelapse.\n\n - We hide this in Beat6 between the second and third transitions, and this technique is also used in Beat3 and Beat4 scenes transitioning from a clear day to a stormy night.\n\nTo check transition flow, we can drag different environment profiles onto the **\u2018Target Profile\u2019** on the Environment prefab in a scene, like Beat6, and adjust the Transition Time to determine which transitions need to be instant or long-form and their duration.\n\n![](./Images/EnvImplementation/Fig5.gif)\n\nWe set up transitions using Unity Event Receivers on the Environment Profile prefab and assign them to Event Broadcasters on the Teleport Warps in the scene. Once Receivers are set up, we add the Environment Profile for the transition, its duration, and skybox updaters to ensure smooth transitions. See below for an example of Beat6 transitions on the Environment Prefab.\n\n**Starting Environment Profile in Beat6:**\n\n![](./Images/EnvImplementation/Fig2.png)\n\n**Final Environment Profile in Beat6:**\n\n![](./Images/EnvImplementation/Fig1.png)\n\n**Example of the Beat6 Environment Transitions Setup in Scene**\n\n![](./Images/EnvImplementation/Fig0.png)\n\n![](./Images/EnvImplementation/Fig3.png)\n\n# Summary of Things to Look Out For\n\n### Sun and Moon Positions\n\n- Higher or lower in the sky\n\n - Small position changes can be instant or long (5 - 30 seconds).\n\n - Large position changes can be instant or long (20 - 50 seconds).\n\n - NOTE: Large changes need significant time; otherwise, the sun/moon will move quickly and look unnatural.\n\n- Swapping Moon and Sun\n\n - Must be done via an instant transition.\n\n- Keep sun and moon changes on the X-axis only, moving up or down, not horizontally (Y-axis changes between scenes are acceptable if necessary).\n\n### Ocean Patch Sizes\n\n- Longer transitions require the same patch size, as it limits max wave size. Different patch sizes can cause visual inconsistencies during transitions, like noticeable shifting/scrolling as the ocean patch size changes.\n\n### Same Skybox Cloud Values for Longer Transitions\n\n- Cloud Offset should be consistent to avoid clouds moving up and down.\n\n- Cloud Speed should be consistent to prevent noticeable scrolling as clouds shift.\n\n- Cloud Scaling, like Cloud Speed, can cause noticeable scrolling if different between profiles.\n\n - NOTE: Consistent cloud values are necessary for extended transitions.\n\n### Colours\n\n- Managing colour changes between profiles can be challenging, especially with rapid time-of-day changes.\n\n- Smaller changes in instant or short transitions (3 - 5 seconds) can help achieve smoother colour transitions over longer periods.\n\n- In a Beat6 profile, when the moon was in the \u2018sun\u2019 position, I edited the Skybox \u2018Cloud Back Color\u2019 to appear more orange, typically a darker version of the \u2018Cloud Sun Color\u2019, to simulate the sun about to crest the ocean.\n\n - Tricks like this can help create transitions between very different profile setups.\n\n- Experimenting with Post Processing profiles can also aid in smooth colour transitions between profiles.\n\n### Relevant Files\n- [EnvironmentSystem.cs](https://github.com/meta-quest/Unity-UtilityPackages/tree/main/com.meta.utilities.environment/Runtime/Scripts/Environment/EnvironmentSystem.cs)\n- [EnvironmentProfile.cs](https://github.com/meta-quest/Unity-UtilityPackages/tree/main/com.meta.utilities.environment/Runtime/Scripts/Water/EnvironmentProfile.cs)\n" m_overrideMarkdownRoot: .\Documentation/