diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index ef1b604f3..900a968ef 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -666,7 +666,6 @@ public class ActionGameManager : MonoBehaviour if (menu.activeSelf) { _paused = false; - VolumeRenderer.EnableDepth = true; menu.SetActive(false); UiRoot.SetActive(true); if (!_menuShown) @@ -679,7 +678,6 @@ public class ActionGameManager : MonoBehaviour else { _paused = true; - VolumeRenderer.EnableDepth = false; menu.SetActive(true); UiRoot.SetActive(false); _menuShown = Menu.gameObject.activeSelf; @@ -1071,7 +1069,6 @@ public class ActionGameManager : MonoBehaviour var deathTime = Time.time; UnbindEntity(); CurrentEntity = null; - VolumeRenderer.EnableDepth = false; MainMenu.gameObject.SetActive(true); Menu.gameObject.SetActive(false); CurrentGalaxy = null; diff --git a/Assets/Scripts/Zone Display/VolumeCloudRenderer.cs b/Assets/Scripts/Zone Display/VolumeCloudRenderer.cs index 689af861c..d7434c113 100644 --- a/Assets/Scripts/Zone Display/VolumeCloudRenderer.cs +++ b/Assets/Scripts/Zone Display/VolumeCloudRenderer.cs @@ -40,7 +40,7 @@ public enum Quality /// /// Cloud renderer post processing. /// -//[ImageEffectAllowedInSceneView] +[ImageEffectAllowedInSceneView] [ExecuteInEditMode,RequireComponent(typeof(Camera))] [ImageEffectOpaque] public class VolumeCloudRenderer : EffectBase @@ -134,6 +134,7 @@ public class VolumeCloudRenderer : EffectBase mat.EnableKeyword("LOW_QUALITY"); } + mat.SetMatrix("_CamInvProj", (Camera.current.projectionMatrix * Camera.current.worldToCameraMatrix).inverse); mat.SetVector("_ProjectionExtents", mcam.GetProjectionExtents()); mat.SetFloat("_RaymarchOffset", sequence.Get()); mat.SetVector("_TexelSize", undersampleBuffer.texelSize); diff --git a/Assets/Scripts/Zone Display/VolumeSampling.cs b/Assets/Scripts/Zone Display/VolumeSampling.cs index cc3bafe6c..a5efa036a 100644 --- a/Assets/Scripts/Zone Display/VolumeSampling.cs +++ b/Assets/Scripts/Zone Display/VolumeSampling.cs @@ -6,6 +6,7 @@ using System; using UnityEngine; using Unity.Mathematics; using UnityEngine.Experimental.Rendering; +using UnityEngine.Rendering; using UnityEngine.Serialization; using static Unity.Mathematics.math; using static Unity.Mathematics.noise; @@ -17,68 +18,22 @@ using static Unity.Mathematics.noise; [RequireComponent( typeof( Camera ) )] public class VolumeSampling : MonoBehaviour { - //public Material VolMaterial; public Transform GridTransform; public GameSettings Settings; - //public int DownsampleBlurMask = 2; - // private Camera _camera; - // private RenderBuffer[] _mrt; - private Texture2D _blurMask; - private Texture2D _disabledBlurMask; private float _flowScroll; public RenderTexture NebulaSurfaceHeight; public RenderTexture NebulaPatchHeight; public RenderTexture NebulaPatch; public RenderTexture NebulaTint; - private Camera _camera; - public bool EnableDepth { get; set; } = true; - - - private void Start() - { - //Debug.Log($"Supported MRT count: {SystemInfo.supportedRenderTargetCount}"); - _camera = GetComponent(); - // _mrt = new RenderBuffer[2]; - //_blurMask = new RenderTexture(Screen.width, Screen.height, 0, GraphicsFormat.R8_UNorm); - _blurMask = Color.white.ToTexture(); - _disabledBlurMask = Color.black.ToTexture(); - } - - //[ImageEffectOpaque] void Update() { - // // check for no shader / shader compile error - // if( VolMaterial == null ) - // { - // Graphics.Blit(source, destination); - // return; - // } - // - // Shader needs to know the position and scale of cameras used to render input textures if(GridTransform != null) Shader.SetGlobalVector("_GridTransform", new Vector4(GridTransform.position.x,GridTransform.position.z,GridTransform.localScale.x)); - // - // Shader needs this matrix to generate world space rays - Shader.SetGlobalMatrix("_CamProj", (_camera.projectionMatrix * _camera.worldToCameraMatrix).inverse); - Shader.SetGlobalMatrix("_CamInvProj", (_camera.projectionMatrix * _camera.worldToCameraMatrix).inverse); - // _mrt[0] = destination.colorBuffer; - // _mrt[1] = _blurMask.colorBuffer; - // - // // Blit with a MRT. - // Graphics.SetRenderTarget(_mrt, source.depthBuffer); - // - // Graphics.Blit( source, VolMaterial, 0 ); - - //Graphics.Blit(rt1, destination); - - if(EnableDepth) - Shader.SetGlobalTexture("_DoFBlurTex", _blurMask); - else - Shader.SetGlobalTexture("_DoFBlurTex", _disabledBlurMask); - + + // Volumetric sampling parameters are used by several shaders Shader.SetGlobalTexture("_NebulaSurfaceHeight", NebulaSurfaceHeight); Shader.SetGlobalTexture("_NebulaPatchHeight", NebulaPatchHeight); Shader.SetGlobalTexture("_NebulaPatch", NebulaPatch); diff --git a/Assets/Shaders/Raymarching/CloudShader.shader b/Assets/Shaders/Raymarching/CloudShader.shader index 4073108a9..c67c17b39 100644 --- a/Assets/Shaders/Raymarching/CloudShader.shader +++ b/Assets/Shaders/Raymarching/CloudShader.shader @@ -42,7 +42,6 @@ Shader "Aetheria/CloudShader" float4 _ProjectionExtents; sampler2D _DitheringTex; float4 _DitheringCoords; - uniform float4x4 _CamProj; uniform float4x4 _CamInvProj; struct appdata @@ -95,7 +94,7 @@ Shader "Aetheria/CloudShader" float3 worldDepth = DepthToWorld(screenPos, depthSample); float raymarchEnd = length(worldDepth-worldPos.xyz); - float sceneDepth = Linear01Depth(depthSample); + //float sceneDepth = Linear01Depth(depthSample); //bool occluded = GetRaymarchEndFromSceneDepth(sceneDepth, raymarchEnd); float3 viewDir = normalize(worldPos.xyz - _WorldSpaceCameraPos);