FoliageBender.cs 781 B

123456789101112131415161718192021222324252627282930313233
  1. // Fantasy Adventure Environment
  2. // Copyright Staggart Creations
  3. // staggart.xyz
  4. using UnityEngine;
  5. using System.Collections;
  6. namespace FAE
  7. {
  8. #if UNITY_EDITOR
  9. using UnityEditor;
  10. [ExecuteInEditMode]
  11. #endif
  12. /// <summary>
  13. /// Sets world-space obstacle position and bending strength on the FAE foliage shader
  14. /// </summary>
  15. public class FoliageBender : MonoBehaviour
  16. {
  17. [Range(0f, 100f)]
  18. public float strength = 20f;
  19. [Range(0f, 5f)]
  20. public float radius = 1.5f;
  21. void Update()
  22. {
  23. Shader.SetGlobalVector("_ObstaclePosition", this.transform.position);
  24. Shader.SetGlobalFloat("_BendingStrength", strength);
  25. Shader.SetGlobalFloat("_BendingRadius", radius);
  26. }
  27. }
  28. }