public void GetFromGaia() { FogVolume gFV = null; FogVolume cloudsFV = null; GameObject groundFog = GameObject.Find("Fog Volume [Ground Fog]"); if (groundFog != null) { gFV = groundFog.GetComponent <FogVolume>(); } if (gFV != null) { fog = gFV; } GameObject cloudsGo = GameObject.Find("Fog Volume [Clouds]"); if (cloudsGo != null) { cloudsFV = cloudsGo.GetComponent <FogVolume>(); } if (cloudsFV != null) { clouds = cloudsFV; } }
void Update() { if (GameCamera == null) { Debug.Log("No Camera available for Fog Volume. Trying to find another one"); Initialize(); } #if UNITY_EDITOR for (int i = 0; i < SceneFogVolumes.Length; i++) { FogVolume SlotFogVolume = SceneFogVolumes[i]; if (SlotFogVolume == null) { //reset and rebuild SceneFogVolumes = null; FindFogVolumes(); } } if (SceneFogVolumes.Length == 0) { DestroyImmediate(gameObject); } #endif }
public void UpdateFog() { sourceFog2 = (environment == Environment.Valfross || environment == Environment.Tolbrynd ? otherFog : ipsilonFog)?.GetComponent <FogVolume>(); if (fog2 == null) { CreateFog(); } else { if (sourceFog2) { if (ignored) { sourceFog2.gameObject.layer = layer; } fog2.enabled = sourceFog2.enabled && sourceFog2.gameObject.activeSelf; ModUtility.CopyComponentValues <FogVolume>(sourceFog2, fog2); } fog2.gameObject.SetActive(false); if (Portal.accurateFog) { fog2.gameObject.SetActive(true); } } }
public void CreateTexturedFog() { fogMode = CurrentFogMode.Textured; //Pick colour of main light Color mainLightColor = Color.white; mainLightColor = EnviroSkyMgr.instance.Components.DirectLight.GetComponent <Light>().color; GameObject groundFogGo = GameObject.Find("Fog Volume [Ground Fog] for Enviro"); DestroyImmediate(groundFogGo); if (groundFogGo == null) { groundFogGo = new GameObject(); groundFogGo.name = "Fog Volume [Ground Fog] for Enviro"; Renderer rend = groundFogGo.AddComponent <MeshRenderer>(); if (rend != null) { rend.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; rend.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off; rend.receiveShadows = false; rend.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; } groundFogGo.AddComponent <FogVolume>(); } //Adjust Fog Settings FogVolume fVolume = groundFogGo.GetComponent <FogVolume>(); if (fVolume != null) { fVolume.transform.position = fogPosition; fVolume.fogVolumeScale = new Vector3(EnviroSkyMgr.instance.Camera.farClipPlane, EnviroSkyMgr.instance.Camera.farClipPlane * 0.2f, EnviroSkyMgr.instance.Camera.farClipPlane); fVolume.FogMainColor = Color.grey; fVolume.Visibility = 800f; fVolume._FogType = FogVolume.FogType.Textured; fVolume.EnableGradient = true; fVolume.bVolumeFog = false; fVolume._BlendMode = FogVolumeRenderer.BlendMode.PremultipliedTransparency; fVolume.EnableInscattering = true; fVolume.InscatteringColor = Color.Lerp(mainLightColor, Color.black, 0.8f); fVolume.VolumeFogInscatteringAnisotropy = 0.59f; fVolume.InscatteringIntensity = 0.07f; fVolume.InscatteringStartDistance = 5f; fVolume.InscatteringTransitionWideness = 300f; fVolume.DrawOrder = 3; fVolume._PushAlpha = 1.0025f; fVolume._ztest = UnityEngine.Rendering.CompareFunction.Always; // Assign Fog for runtime Controls fog = fVolume; CheckCamera(); } }
public void CreateFog() { if (ignored) { if (sourceFog2) { sourceFog2.gameObject.layer = layer; } } else if (sourceFog2) { GameObject child = GameObject.Instantiate(sourceFog2.gameObject); DestroyImmediate(child.GetComponent <FollowCam>()); child.transform.parent = transform; child.transform.localPosition = Vector3.zero; child.transform.localRotation = Quaternion.identity; child.transform.localScale = sourceFog2.transform.localScale; fog2 = child.GetComponent <FogVolume>(); fog2.enabled = sourceFog2.enabled && sourceFog2.gameObject.activeSelf; fog2.gameObject.SetActive(Portal.accurateFog); fog2.gameObject.layer = layer; } }
public void AddAllFogVolumesToThisLight() { _ProminentFogVolume = null; var fogVolumes = FindObjectsOfType <FogVolume>(); int validFogVolumeCount = 0; for (int i = 0; i < fogVolumes.Length; i++) { if ((fogVolumes[i] != null) && (fogVolumes[i]._FogType == FogVolume.FogType.Textured)) { validFogVolumeCount++; } } _TargetFogVolumes = new FogVolume[validFogVolumeCount]; int k = 0; for (var i = 0; i < fogVolumes.Length; i++) { var fogVolume = fogVolumes[i]; if ((fogVolume != null) && (fogVolume._FogType == FogVolume.FogType.Textured)) { _TargetFogVolumes[k++] = fogVolumes[i]; } } }
public void Refresh() { if (_TargetFogVolumes == null) { _ProminentFogVolume = null; return; } for (int i = 0; i < _TargetFogVolumes.Length; i++) { var fogVolume = _TargetFogVolumes[i]; if ((fogVolume != null) && (fogVolume._FogType == FogVolume.FogType.Textured)) { if (fogVolume.HasUpdatedBoxMesh) { float largestOfProminent = (_ProminentFogVolume != null) ? _MaxOf(_ProminentFogVolume.fogVolumeScale.x, _ProminentFogVolume.fogVolumeScale.y, _ProminentFogVolume.fogVolumeScale.z) : 0.0f; float largest = _MaxOf(fogVolume.fogVolumeScale.x, fogVolume.fogVolumeScale.y, fogVolume.fogVolumeScale.z); if (largest > largestOfProminent) { _ProminentFogVolume = fogVolume; } } } } }
void OnEnable() { ShaderLoad(); Dad = transform.parent.gameObject; Fog = Dad.GetComponent <FogVolume>(); ThisCamera = gameObject.GetComponent <Camera>(); ThisCamera.depthTextureMode = DepthTextureMode.Depth; CameraTransform(); }
public void ProcessFog() { bool isCampaign = false; int n; if (int.TryParse(SceneManager.GetActiveScene().name, out n)) { isCampaign = true; } if (isCampaign) { environment = (Environment)StatMaster.currentIslandID; } else if (StatMaster.isMP) { if (LevelEditor.Instance != null) { if (LevelEditor.Instance.Settings != null) { environment = MPEnvironmentToSimple((int)LevelEditor.Instance.Settings.Environment); } else { environment = Environment.Other; } LevelEditor.Instance.LevelSettingsChanged += SettingsChanged; } } ipsilonFog = Camera.main.transform.FindChild("Fog Volume"); if (!ipsilonFog) { ipsilonFog = GameObject.Find("MULTIPLAYER LEVEL")?.transform.FindChild("Environments/Ipsilon/Fog Volume"); } Transform darkFog = Camera.main.transform.FindChild("Fog Volume Dark"); otherFog = StatMaster.isMP ? GameObject.Find("MULTIPLAYER LEVEL")?.transform.FindChild("Environments/Tolbrynd/Fog Volume") : darkFog; if (otherFog) { otherFog.gameObject.layer = 0; } if (darkFog) { darkFog.gameObject.layer = 0; } sourceFog2 = (environment == Environment.Valfross || environment == Environment.Tolbrynd ? otherFog : ipsilonFog)?.GetComponent <FogVolume>(); CreateFog(); }
void OnEnable() { _target = (FogVolume)target; Theme1 = new GUIStyle(); ThemeFooter = new GUIStyle(); // ThemeFooter.normal.background = MakeTex(new Color(.31f, 0.2f, .3f)); if (EditorGUIUtility.isProSkin) { ThemeFooter.normal.background = (Texture2D)Resources.Load("RendererInspectorBodyBlack"); } else { ThemeFooter.normal.background = (Texture2D)Resources.Load("RendererInspectorBodyBright"); } }
// Start is called before the first frame update void Start() { colors = new Color[4]; v = GetComponent <Volume>(); if (v.profile.TryGet <FogVolume>(out FogVolume fogVolume)) { // Found fog volume, cache off reference. f = fogVolume; } colors[0] = f.color.value; colors[1] = col1; colors[2] = col2; colors[3] = col3; tempSpeed = lerpSpeed; }
public static void GX_Quality_Low() { //What about ground fog and cloud settings ? GameObject goGroundFog = GameObject.Find("Fog Volume [Ground Fog]"); if (goGroundFog != null) { FogVolume fvGroundFog = goGroundFog.GetComponent <FogVolume>(); if (fvGroundFog != null) { //Make adjustments } } GameObject goClouds = GameObject.Find("Fog Volume [Clouds]"); if (goClouds != null) { FogVolume fvClouds = goClouds.GetComponent <FogVolume>(); if (fvClouds != null) { //Make adjustments } } //Update renderer settings FogVolumeRenderer fvRenderer = GameObject.FindObjectOfType <FogVolumeRenderer>(); if (fvRenderer != null) { fvRenderer._Downsample = 8; fvRenderer._BlendMode = FogVolumeRenderer.BlendMode.PremultipliedTransparency; } //Update screen settings FogVolumeScreen fvScreen = GameObject.FindObjectOfType <FogVolumeScreen>(); if (fvScreen != null) { } }
void EnableVolumetricShadow(bool b) { if (_TargetFogVolumes == null) { return; } if (_TargetFogVolumes.Length > 0) { float largestAxis = 0.0f; int largestIndex = 0; for (int FVindex = 0; FVindex < _TargetFogVolumes.Length; FVindex++) { var fogVolume = _TargetFogVolumes[FVindex]; if ((fogVolume != null) && (fogVolume._FogType == FogVolume.FogType.Textured)) { if (fogVolume.enabled) { FogVolumeMaterial = fogVolume.FogMaterial; FogVolumeMaterial.SetInt("_VolumetricShadowsEnabled", b ? 1 : 0); } float largest = _MaxOf(fogVolume.fogVolumeScale.x, fogVolume.fogVolumeScale.y, fogVolume.fogVolumeScale.z); if (largest > largestAxis) { largestAxis = largest; largestIndex = FVindex; } } } _ProminentFogVolume = _TargetFogVolumes[largestIndex]; } }
/// <summary> /// Creates a Clouds Layer for Enviro. /// </summary> public void CreateCloudLayer() { //Pick colour of main light Color mainLightColor = Color.white; mainLightColor = EnviroSkyMgr.instance.Components.DirectLight.GetComponent <Light>().color; //Get the main camera Camera mainCamera = Camera.main; //First make sure its not already in scene - if it isnt then add it FogVolume fVolume; GameObject goClouds = GameObject.Find("Fog Volume [Clouds] for Enviro"); if (goClouds == null) { goClouds = new GameObject(); goClouds.name = "Fog Volume [Clouds] for Enviro"; Renderer rend = goClouds.AddComponent <MeshRenderer>(); if (rend != null) { rend.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; rend.receiveShadows = false; rend.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off; rend.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; } fVolume = goClouds.AddComponent <FogVolume>(); //Create the horizon GameObject goHorizon = GameObject.CreatePrimitive(PrimitiveType.Plane); goHorizon.name = "Horizon"; goHorizon.transform.parent = goClouds.transform; goHorizon.transform.localPosition = new Vector3(0f, -79f, 0f); goHorizon.GetComponent <MeshRenderer>().enabled = false; goHorizon.GetComponent <MeshCollider>().enabled = false; //Create the priority script FogVolumePriority fogVolumePrio = goClouds.AddComponent <FogVolumePriority>(); fogVolumePrio.GameCamera = mainCamera; fogVolumePrio.FogOrderCameraAbove = 4; fogVolumePrio.FogOrderCameraBelow = -1; fogVolumePrio.thisFog = fVolume; fogVolumePrio.Horizon = goHorizon; CheckCamera(); } //Setup our clouds fVolume = goClouds.GetComponent <FogVolume>(); if (fVolume != null) { clouds = fVolume; //Location and scale fVolume.transform.position = cloudsPosition; fVolume.fogVolumeScale = new Vector3(EnviroSkyMgr.instance.Camera.farClipPlane - 50f, 100f, EnviroSkyMgr.instance.Camera.farClipPlane - 50f); //Fog type and blend mode fVolume._FogType = FogVolume.FogType.Textured; fVolume._BlendMode = FogVolumeRenderer.BlendMode.TraditionalTransparency; //Lighting fVolume._AmbientColor = Color.Lerp(mainLightColor, Color.black, 0.1f); fVolume.useHeightGradient = true; fVolume.Absorption = 0.8f; fVolume.HeightAbsorption = 0.185f; fVolume.bAbsorption = true; fVolume.EnableInscattering = true; fVolume.InscatteringColor = mainLightColor; fVolume.InscatteringShape = 0.05f; fVolume.InscatteringIntensity = 0.882f; fVolume.InscatteringStartDistance = 0f; fVolume.InscatteringTransitionWideness = 1f; fVolume._DirectionalLighting = true; fVolume.LightExtinctionColor = Color.Lerp(mainLightColor, Color.black, 0.8f); fVolume._DirectionalLightingDistance = 0.0008f; fVolume.DirectLightingShadowDensity = 6f; fVolume.DirectLightingShadowSteps = 1; //Renderer fVolume.NoiseIntensity = 1f; fVolume.SceneCollision = true; fVolume.Iterations = 500; fVolume.IterationStep = 100; fVolume._OptimizationFactor = 0.0000005f; fVolume.GradMin = 0.19f; fVolume.GradMax = 0.06f; fVolume.GradMin2 = -0.25f; fVolume.GradMax2 = 0.21f; //Noise fVolume.EnableNoise = true; fVolume._3DNoiseScale = 0.15f; fVolume.Speed = new Vector4(0.49f, 0f, 0f, 0f); fVolume.Vortex = 0.47f; fVolume.RotationSpeed = 0f; fVolume.rotation = 324f; fVolume._VortexAxis = FogVolume.VortexAxis.Y; fVolume.Coverage = 2.44f; fVolume.NoiseContrast = 12.9f; fVolume.NoiseDensity = 0.2f; fVolume.Octaves = 3; fVolume.BaseTiling = 150f; fVolume._BaseRelativeSpeed = 0.85f; fVolume.DetailTiling = 285.3f; fVolume._DetailRelativeSpeed = 16.6f; fVolume.DetailDistance = 5000f; fVolume._NoiseDetailRange = 0.337f; fVolume._DetailMaskingThreshold = 8f; fVolume._Curl = 0.364f; //Other fVolume.DrawOrder = 4; fVolume._PushAlpha = 1.5f; fVolume._ztest = UnityEngine.Rendering.CompareFunction.LessEqual; if (fogMode != CurrentFogMode.Textured) { fVolume.CreateSurrogate = true; } else { fVolume.CreateSurrogate = false; } CheckCamera(); } }
// Use this for initialization void OnEnable() { thisFog = GetComponent <FogVolume>(); }
// Use this for initialization void OnEnable() { thisFog = GetComponent <FogVolume>(); _FogVolumeData = thisFog._FogVolumeData; }
//Texture2D[] _InspectorBackground; void OnEnable() { _target = (FogVolume)target; string m_ScriptFilePath; string BackgroundImagesPath; MonoScript ms = MonoScript.FromScriptableObject(this); m_ScriptFilePath = AssetDatabase.GetAssetPath(ms); FileInfo fi = new FileInfo(m_ScriptFilePath); BackgroundImagesPath = fi.Directory.ToString(); BackgroundImagesPath = BackgroundImagesPath.Replace("\\", "/"); BackgroundImagesPath += "/Themes/png"; _target.BackgroundImagesPath = BackgroundImagesPath; int ImageIndex = 0; foreach (string filePath in System.IO.Directory.GetFiles(BackgroundImagesPath)) { if (!filePath.Contains(".meta")) { // print(filePath); ImageIndex++; } } _target._InspectorBackground = null; _target._InspectorBackground = new Texture2D[ImageIndex]; // print(ImageIndex); int i = 0; foreach (string filePath in System.IO.Directory.GetFiles(BackgroundImagesPath)) { if (!filePath.Contains(".meta")) { byte[] fileData; // print(filePath); fileData = File.ReadAllBytes(filePath); //init Texture2D tex = new Texture2D(1, 32, TextureFormat.RHalf, false, true); tex.filterMode = FilterMode.Trilinear; tex.LoadImage(fileData); _target._InspectorBackground[i] = tex; i++; } } Theme1 = new GUIStyle(); ThemeFooter = new GUIStyle(); // ThemeFooter.normal.background = MakeTex(new Color(.31f, 0.2f, .3f)); if (EditorGUIUtility.isProSkin) { ThemeFooter.normal.background = (Texture2D)Resources.Load("RendererInspectorBodyBlack"); } else { ThemeFooter.normal.background = (Texture2D)Resources.Load("RendererInspectorBodyBright"); } }
public static bool BoxUnderPlane(ref float4 plane, ref FogVolume fog, int i) { float3 absNormal = abs(normalize(mul(plane.xyz, fog.localToWorld))); return(dot(fog.position, plane.xyz) - dot(absNormal, fog.extent) < -plane.w); }
public void RemoveAllFogVolumesFromThisLight() { _ProminentFogVolume = null; _TargetFogVolumes = null; }
public static void GX_Setup_AddGroundFog() { //Pick colour of main light GameObject goLight = GameObject.Find("Directional Light"); Light mainLight = null; if (goLight != null) { mainLight = goLight.GetComponent <Light>(); } else { mainLight = GameObject.FindObjectOfType <Light>(); } Color mainLightColor = Color.white; if (mainLight != null) { mainLightColor = mainLight.color; } //First make sure its not already in scene GameObject fvGroundFog = GameObject.Find("Fog Volume [Ground Fog]"); if (fvGroundFog == null) { fvGroundFog = new GameObject(); fvGroundFog.name = "Fog Volume [Ground Fog]"; fvGroundFog.AddComponent <MeshRenderer>(); fvGroundFog.AddComponent <FogVolume>(); fvGroundFog.GetComponent <Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; fvGroundFog.GetComponent <Renderer>().receiveShadows = false; fvGroundFog.GetComponent <Renderer>().reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off; fvGroundFog.GetComponent <Renderer>().lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; } //Adjust its position and size FogVolume fvVolume = fvGroundFog.GetComponent <FogVolume>(); if (fvVolume != null) { GaiaSceneInfo info = GaiaSceneInfo.GetSceneInfo(); Debug.Log(info.m_seaLevel); fvVolume.transform.position = new Vector3(info.m_sceneBounds.center.x, info.m_seaLevel + 0.01f + (info.m_sceneBounds.extents.y / 4f), info.m_sceneBounds.center.z); // info.m_sceneBounds.center; fvVolume.fogVolumeScale = new Vector3(info.m_sceneBounds.size.x * 3, info.m_sceneBounds.extents.y / 2f, info.m_sceneBounds.size.z * 3); //And adjust camera far clip as well float maxClip = Math.Max(info.m_sceneBounds.size.x, info.m_sceneBounds.size.z) * 3f; Camera mainCamera = Camera.main; if (mainCamera != null) { if (mainCamera.farClipPlane < maxClip) { mainCamera.farClipPlane = maxClip + 200f; } } fvVolume.FogMainColor = new Color(53f / 255f, 76f / 255f, 114f / 255f); //fvVolume.Visibility = maxClip; fvVolume.Visibility = 800f; fvVolume.EnableInscattering = true; fvVolume.InscatteringColor = Color.Lerp(mainLightColor, Color.black, 0.8f); fvVolume.VolumeFogInscatteringAnisotropy = 0.59f; fvVolume.InscatteringIntensity = 0.07f; fvVolume.InscatteringStartDistance = 5f; fvVolume.InscatteringTransitionWideness = 300f; //Other fvVolume.DrawOrder = 3; fvVolume._PushAlpha = 1.0025f; fvVolume._ztest = CompareFunction.Always; } }