/// <summary> /// Sets the horizon shader material pramaters /// </summary> /// <param name="profile"></param> /// <param name="enableSystem"></param> public static void SetHorizonShaderSettings(AmbientSkyProfiles skyProfiles, AmbientSkyboxProfile profile, AmbientProceduralSkyboxProfile proceduralProfile, AmbientGradientSkyboxProfile gradientProfile, bool hasChanged) { if (skyProfiles.m_selectedRenderPipeline == AmbientSkiesConsts.RenderPipelineSettings.BuiltIn) { if (skyProfiles.m_useSkies) { if (skyProfiles.m_systemTypes == AmbientSkiesConsts.SystemTypes.AmbientHDRISkies) { if (profile.horizonSkyEnabled) { AddHorizonSky("Ambient Skies Horizon"); if (horizonMaterial == null) { horizonMaterial = GetHorizonMaterial(); } else { if (hasChanged) { ApplyHorizonSettings(skyProfiles, profile, proceduralProfile, horizonMaterial); } } } else { RemoveHorizonSky(); } } else if (skyProfiles.m_systemTypes == AmbientSkiesConsts.SystemTypes.AmbientProceduralSkies) { if (proceduralProfile.horizonSkyEnabled) { AddHorizonSky("Ambient Skies Horizon"); if (horizonMaterial == null) { horizonMaterial = GetHorizonMaterial(); } else { if (hasChanged) { ApplyHorizonSettings(skyProfiles, profile, proceduralProfile, horizonMaterial); } } } else { RemoveHorizonSky(); } } else { if (gradientProfile.horizonSkyEnabled) { AddHorizonSky("Ambient Skies Horizon"); if (horizonMaterial == null) { horizonMaterial = GetHorizonMaterial(); } else { ApplyHorizonSettings(skyProfiles, profile, proceduralProfile, horizonMaterial); } } else { RemoveHorizonSky(); } } } else { RemoveHorizonSky(); } } else { RemoveHorizonSky(); } }
/// <summary> /// Applies the settings to the horizons material and gameobject /// </summary> /// <param name="profile"></param> /// <param name="horizonMaterial"></param> public static void ApplyHorizonSettings(AmbientSkyProfiles skyProfiles, AmbientSkyboxProfile profile, AmbientProceduralSkyboxProfile proceduralProfile, Material horizonMaterial) { if (skyProfiles.m_systemTypes == AmbientSkiesConsts.SystemTypes.AmbientHDRISkies) { horizonMaterial.SetFloat("_Scattering", profile.horizonScattering); horizonMaterial.SetFloat("_FogDensity", profile.horizonFogDensity); horizonMaterial.SetFloat("_HorizonFalloff", profile.horizonFalloff); horizonMaterial.SetFloat("_HorizonBlend", profile.horizonBlend); if (horizonSkyObject == null) { horizonSkyObject = GameObject.Find("Ambient Skies Horizon"); if (profile.scaleHorizonObjectWithFog && profile.fogType == AmbientSkiesConsts.VolumeFogType.Linear) { horizonSkyObject.transform.localScale = new Vector3(profile.fogDistance, profile.fogDistance * 1.2f, profile.fogDistance); } else { horizonSkyObject.transform.localScale = profile.horizonSize; } if (!profile.followPlayer) { horizonSkyObject.transform.position = profile.horizonPosition; } } else { if (profile.scaleHorizonObjectWithFog && profile.fogType == AmbientSkiesConsts.VolumeFogType.Linear) { horizonSkyObject.transform.localScale = new Vector3(profile.fogDistance, profile.fogDistance * 1.2f, profile.fogDistance); } else { horizonSkyObject.transform.localScale = profile.horizonSize; } if (!profile.followPlayer) { horizonSkyObject.transform.position = profile.horizonPosition; } } if (horizonSettings == null) { horizonSettings = Object.FindObjectOfType <HorizonSky>(); horizonSettings.m_followsCameraPosition = profile.followPlayer; horizonSettings.m_positionUpdate = profile.horizonUpdateTime; horizonSettings.UpdatePosition(); } else { horizonSettings.m_followsCameraPosition = profile.followPlayer; horizonSettings.m_positionUpdate = profile.horizonUpdateTime; horizonSettings.UpdatePosition(); } } else if (skyProfiles.m_systemTypes == AmbientSkiesConsts.SystemTypes.AmbientProceduralSkies) { horizonMaterial.SetFloat("_Scattering", proceduralProfile.horizonScattering); horizonMaterial.SetFloat("_FogDensity", proceduralProfile.horizonFogDensity); horizonMaterial.SetFloat("_HorizonFalloff", proceduralProfile.horizonFalloff); horizonMaterial.SetFloat("_HorizonBlend", proceduralProfile.horizonBlend); if (horizonSkyObject == null) { horizonSkyObject = GameObject.Find("Ambient Skies Horizon"); if (proceduralProfile.scaleHorizonObjectWithFog && proceduralProfile.fogType == AmbientSkiesConsts.VolumeFogType.Linear) { horizonSkyObject.transform.localScale = new Vector3(proceduralProfile.proceduralFogDistance, proceduralProfile.proceduralFogDistance * 1.2f, proceduralProfile.proceduralFogDistance); } else { horizonSkyObject.transform.localScale = proceduralProfile.horizonSize; } if (!proceduralProfile.followPlayer) { horizonSkyObject.transform.position = proceduralProfile.horizonPosition; } } else { if (proceduralProfile.scaleHorizonObjectWithFog && proceduralProfile.fogType == AmbientSkiesConsts.VolumeFogType.Linear) { horizonSkyObject.transform.localScale = new Vector3(proceduralProfile.proceduralFogDistance, proceduralProfile.proceduralFogDistance * 1.2f, proceduralProfile.proceduralFogDistance); } else { horizonSkyObject.transform.localScale = proceduralProfile.horizonSize; } if (!proceduralProfile.followPlayer) { horizonSkyObject.transform.position = proceduralProfile.horizonPosition; } } if (horizonSettings == null) { horizonSettings = Object.FindObjectOfType <HorizonSky>(); horizonSettings.m_followsCameraPosition = proceduralProfile.followPlayer; horizonSettings.m_positionUpdate = proceduralProfile.horizonUpdateTime; horizonSettings.UpdatePosition(); } else { horizonSettings.m_followsCameraPosition = proceduralProfile.followPlayer; horizonSettings.m_positionUpdate = proceduralProfile.horizonUpdateTime; horizonSettings.UpdatePosition(); } } }