Brak opisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AdaptiveShadowQuality.cs 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. namespace UnityEngine.AdaptivePerformance
  2. {
  3. /// <summary>
  4. /// A scaler used by <see cref="AdaptivePerformanceIndexer"/> to adjust the quality of shadows.
  5. /// </summary>
  6. public class AdaptiveShadowQuality : AdaptivePerformanceScaler
  7. {
  8. int m_DefaultShadowQualityBias;
  9. /// <summary>
  10. /// Ensures settings are applied during startup.
  11. /// </summary>
  12. protected override void Awake()
  13. {
  14. base.Awake();
  15. if (m_Settings == null)
  16. return;
  17. ApplyDefaultSetting(m_Settings.scalerSettings.AdaptiveShadowQuality);
  18. }
  19. /// <summary>
  20. /// Callback when scaler gets disabled and removed from indexer
  21. /// </summary>
  22. protected override void OnDisabled()
  23. {
  24. AdaptivePerformanceRenderSettings.ShadowQualityBias = m_DefaultShadowQualityBias;
  25. }
  26. /// <summary>
  27. /// Callback when scaler gets enabled and added to the indexer
  28. /// </summary>
  29. protected override void OnEnabled()
  30. {
  31. m_DefaultShadowQualityBias = AdaptivePerformanceRenderSettings.ShadowQualityBias;
  32. }
  33. /// <summary>
  34. /// Callback for any level change.
  35. /// </summary>
  36. protected override void OnLevel()
  37. {
  38. if (ScaleChanged())
  39. AdaptivePerformanceRenderSettings.MainLightShadowCascadesCountBias = (int)(3 - 3 * Scale);
  40. }
  41. }
  42. }