VFXExpressionSampleCameraBuffer.cs 1.0 KB

12345678910111213141516171819202122232425262728
  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 VFXExpressionSampleCameraBuffer : VFXExpression
  9. {
  10. public VFXExpressionSampleCameraBuffer() : this(VFXCameraBufferValue.Default, VFXValue<Vector2>.Default, VFXValue<Vector2>.Default)
  11. {
  12. }
  13. public VFXExpressionSampleCameraBuffer(VFXExpression cameraBuffer, VFXExpression pixelDimensions, VFXExpression uv)
  14. : base(Flags.InvalidOnCPU, new VFXExpression[3] { cameraBuffer, pixelDimensions, uv })
  15. {
  16. }
  17. sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.None; } }
  18. sealed public override VFXValueType valueType { get { return VFXValueType.Float4; } }
  19. public sealed override string GetCodeString(string[] parents)
  20. {
  21. return string.Format("SAMPLE_TEXTURE2D_X_LOD({0}, sampler{0}, {2}*{1}*{0}_TexelSize, 0)", parents[0], parents[1], parents[2]);
  22. }
  23. }
  24. }