VFXExpressionLoadTexture.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Linq;
  3. using System.Runtime.CompilerServices;
  4. using UnityEngine;
  5. using UnityEngine.VFX;
  6. namespace UnityEditor.VFX
  7. {
  8. class VFXExpressionLoadTexture2D : VFXExpression
  9. {
  10. public VFXExpressionLoadTexture2D() : this(VFXTexture2DValue.Default, VFXValue<Vector3>.Default)
  11. {
  12. }
  13. public VFXExpressionLoadTexture2D(VFXExpression texture, VFXExpression location)
  14. : base(Flags.InvalidOnCPU, new VFXExpression[2] { texture, location })
  15. { }
  16. sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.None; } }
  17. sealed public override VFXValueType valueType { get { return VFXValueType.Float4; } }
  18. public sealed override string GetCodeString(string[] parents)
  19. {
  20. return string.Format("LoadTexture(VFX_SAMPLER({0}),(int3){1})", parents[0], parents[1]);
  21. }
  22. }
  23. class VFXExpressionLoadTexture2DArray : VFXExpression
  24. {
  25. public VFXExpressionLoadTexture2DArray() : this(VFXTexture2DArrayValue.Default, VFXValue<Vector4>.Default)
  26. {
  27. }
  28. public VFXExpressionLoadTexture2DArray(VFXExpression texture, VFXExpression location)
  29. : base(Flags.InvalidOnCPU, new VFXExpression[2] { texture, location })
  30. { }
  31. sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.None; } }
  32. sealed public override VFXValueType valueType { get { return VFXValueType.Float4; } }
  33. public sealed override string GetCodeString(string[] parents)
  34. {
  35. return string.Format("LoadTexture(VFX_SAMPLER({0}),(int4){1})", parents[0], parents[1]);
  36. }
  37. }
  38. class VFXExpressionLoadTexture3D : VFXExpression
  39. {
  40. public VFXExpressionLoadTexture3D() : this(VFXTexture3DValue.Default, VFXValue<Vector4>.Default)
  41. {
  42. }
  43. public VFXExpressionLoadTexture3D(VFXExpression texture, VFXExpression location)
  44. : base(Flags.InvalidOnCPU, new VFXExpression[2] { texture, location })
  45. { }
  46. sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.None; } }
  47. sealed public override VFXValueType valueType { get { return VFXValueType.Float4; } }
  48. public sealed override string GetCodeString(string[] parents)
  49. {
  50. return string.Format("LoadTexture(VFX_SAMPLER({0}),(int4){1})", parents[0], parents[1]);
  51. }
  52. }
  53. }