FAEGrassShaderController.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #if VEGETATION_STUDIO_PRO
  2. using AwesomeTechnologies.VegetationSystem;
  3. using UnityEngine;
  4. namespace AwesomeTechnologies.Shaders
  5. {
  6. public class FAEGrassShaderController : IShaderController
  7. {
  8. public bool MatchShader(string shaderName)
  9. {
  10. if (string.IsNullOrEmpty(shaderName)) return false;
  11. return (shaderName == "FAE/Grass") ? true : false;
  12. }
  13. public bool MatchBillboardShader(Material[] materials)
  14. {
  15. return false;
  16. }
  17. public ShaderControllerSettings Settings { get; set; }
  18. public void CreateDefaultSettings(Material[] materials)
  19. {
  20. Settings = new ShaderControllerSettings
  21. {
  22. Heading = "Fantasy Adventure Environment Grass",
  23. Description = "Description text",
  24. LODFadePercentage = false,
  25. LODFadeCrossfade = false,
  26. SampleWind = true,
  27. SupportsInstantIndirect = true
  28. };
  29. bool hasPigmentMap = Shader.GetGlobalTexture("_PigmentMap");
  30. Settings.AddLabelProperty("Color");
  31. Settings.AddBooleanProperty("EnablePigmentMap", "Use pigment map", "", hasPigmentMap);
  32. Settings.AddColorProperty("TopColor", "Top", "", ShaderControllerSettings.GetColorFromMaterials(materials, "_ColorTop"));
  33. Settings.AddColorProperty("BottomColor", "Bottom", "", ShaderControllerSettings.GetColorFromMaterials(materials, "_ColorBottom"));
  34. Settings.AddFloatProperty("WindTint", "Wind tint", "", ShaderControllerSettings.GetFloatFromMaterials(materials, "_ColorVariation"), 0, 1);
  35. Settings.AddFloatProperty("AmbientOcclusion", "Ambient Occlusion", "", ShaderControllerSettings.GetFloatFromMaterials(materials, "_AmbientOcclusion"), 0, 1);
  36. Settings.AddLabelProperty("Translucency");
  37. Settings.AddFloatProperty("TranslucencyAmount", "Amount", "", ShaderControllerSettings.GetFloatFromMaterials(materials, "_TransmissionAmount"), 0, 10);
  38. Settings.AddFloatProperty("TranslucencySize", "Size", "", ShaderControllerSettings.GetFloatFromMaterials(materials, "_TransmissionSize"), 1, 20);
  39. Settings.AddLabelProperty("Wind");
  40. Settings.AddFloatProperty("WindInfluence", "Influence", "", ShaderControllerSettings.GetFloatFromMaterials(materials, "_MaxWindStrength"), 0, 1);
  41. Settings.AddFloatProperty("WindSwinging", "Swinging", "", ShaderControllerSettings.GetFloatFromMaterials(materials, "_WindSwinging"), 0, 1);
  42. Settings.AddFloatProperty("WindAmplitude", "Amplitude Multiplier", "", ShaderControllerSettings.GetFloatFromMaterials(materials, "_WindAmplitudeMultiplier"), 0, 10);
  43. #if TOUCH_REACT
  44. Settings.AddLabelProperty("Touch React");
  45. #else
  46. Settings.AddLabelProperty("Player bending");
  47. #endif
  48. Settings.AddFloatProperty("BendingInfluence", "Influence", "", ShaderControllerSettings.GetFloatFromMaterials(materials, "_BendingInfluence"), 0, 1);
  49. }
  50. public void UpdateMaterial(Material material, EnvironmentSettings environmentSettings)
  51. {
  52. if (Settings == null) return;
  53. //Force enable touch react usage
  54. #if TOUCH_REACT
  55. material.SetFloat("_VS_TOUCHBEND", 0);
  56. #endif
  57. material.SetFloat("_PigmentMapInfluence", Settings.GetBooleanPropertyValue("EnablePigmentMap") ? 1 : 0);
  58. //Allow VS heightmaps to control the height
  59. material.SetFloat("_MaxHeight", 0.5f);
  60. material.SetColor("_ColorTop", Settings.GetColorPropertyValue("TopColor"));
  61. material.SetColor("_ColorBottom", Settings.GetColorPropertyValue("BottomColor"));
  62. material.SetFloat("_ColorVariation", Settings.GetFloatPropertyValue("WindTint"));
  63. material.SetFloat("_AmbientOcclusion", Settings.GetFloatPropertyValue("AmbientOcclusion"));
  64. material.SetFloat("_TransmissionAmount", Settings.GetFloatPropertyValue("TranslucencyAmount"));
  65. material.SetFloat("_TransmissionSize", Settings.GetFloatPropertyValue("TranslucencySize"));
  66. material.SetFloat("_MaxWindStrength", Settings.GetFloatPropertyValue("WindInfluence"));
  67. material.SetFloat("_WindSwinging", Settings.GetFloatPropertyValue("WindSwinging"));
  68. material.SetFloat("_WindAmplitudeMultiplier", Settings.GetFloatPropertyValue("WindAmplitude"));
  69. material.SetFloat("_BendingInfluence", Settings.GetFloatPropertyValue("BendingInfluence"));
  70. }
  71. public void UpdateWind(Material material, WindSettings windSettings)
  72. {
  73. }
  74. }
  75. }
  76. #endif