Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

VFXURPLitMeshOutput.cs 3.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #if HAS_VFX_GRAPH
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. namespace UnityEditor.VFX.URP
  6. {
  7. [VFXHelpURL("Context-OutputPrimitive")]
  8. [VFXInfo(name = "Output Particle|URP Lit|Mesh", category = "#2Output Basic")]
  9. class VFXURPLitMeshOutput : VFXAbstractParticleURPLitOutput, IVFXMultiMeshOutput
  10. {
  11. public override string name => "Output Particle".AppendLabel("URP Lit").AppendLabel("Mesh");
  12. public override string codeGeneratorTemplate => RenderPipeTemplate("VFXParticleLitMesh");
  13. public override VFXTaskType taskType => VFXTaskType.ParticleMeshOutput;
  14. public override bool supportsUV => GetOrRefreshShaderGraphObject() == null;
  15. public override bool implementsMotionVector => true;
  16. public override CullMode defaultCullMode => CullMode.Back;
  17. [VFXSetting(VFXSettingAttribute.VisibleFlags.InInspector), Range(1, 4), Tooltip("Specifies the number of different meshes (up to 4). Mesh per particle can be specified with the meshIndex attribute."), SerializeField]
  18. private uint MeshCount = 1;
  19. [VFXSetting(VFXSettingAttribute.VisibleFlags.InInspector), Tooltip("When enabled, screen space LOD is used to determine with meshIndex to use per particle."), SerializeField]
  20. private bool lod = false;
  21. public uint meshCount => HasStrips(true) ? 1 : MeshCount;
  22. public override VFXOutputUpdate.Features outputUpdateFeatures
  23. {
  24. get
  25. {
  26. VFXOutputUpdate.Features features = base.outputUpdateFeatures;
  27. if (!HasStrips(true)) // TODO make it compatible with strips
  28. {
  29. if (MeshCount > 1)
  30. features |= VFXOutputUpdate.Features.MultiMesh;
  31. if (lod)
  32. features |= VFXOutputUpdate.Features.LOD;
  33. }
  34. if (HasSorting() && VFXOutputUpdate.HasFeature(features, VFXOutputUpdate.Features.IndirectDraw))
  35. features |= VFXOutputUpdate.Features.Sort;
  36. return features;
  37. }
  38. }
  39. protected override IEnumerable<VFXPropertyWithValue> inputProperties
  40. {
  41. get
  42. {
  43. foreach (var property in base.inputProperties)
  44. yield return property;
  45. foreach (var property in VFXMultiMeshHelper.GetInputProperties(MeshCount, outputUpdateFeatures))
  46. yield return property;
  47. }
  48. }
  49. protected override IEnumerable<string> filteredOutSettings
  50. {
  51. get
  52. {
  53. foreach (var s in base.filteredOutSettings)
  54. yield return s;
  55. // TODO Add a experimental bool to setting attribute
  56. if (!VFXViewPreference.displayExperimentalOperator)
  57. {
  58. yield return "MeshCount";
  59. yield return "lod";
  60. }
  61. }
  62. }
  63. public override VFXExpressionMapper GetExpressionMapper(VFXDeviceTarget target)
  64. {
  65. var mapper = base.GetExpressionMapper(target);
  66. switch (target)
  67. {
  68. case VFXDeviceTarget.CPU:
  69. {
  70. foreach (var name in VFXMultiMeshHelper.GetCPUExpressionNames(MeshCount))
  71. mapper.AddExpression(inputSlots.First(s => s.name == name).GetExpression(), name, -1);
  72. break;
  73. }
  74. default:
  75. {
  76. break;
  77. }
  78. }
  79. return mapper;
  80. }
  81. }
  82. }
  83. #endif