No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VectorShaderProperty.cs 1.4KB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Text;
  3. using UnityEditor.Graphing;
  4. using UnityEngine;
  5. namespace UnityEditor.ShaderGraph.Internal
  6. {
  7. [Serializable]
  8. public abstract class VectorShaderProperty : AbstractShaderProperty<Vector4>
  9. {
  10. internal override bool isExposable => true;
  11. internal override bool isRenamable => true;
  12. internal virtual int vectorDimension => 4;
  13. internal override string GetHLSLVariableName(bool isSubgraphProperty, GenerationMode mode)
  14. {
  15. HLSLDeclaration decl = GetDefaultHLSLDeclaration();
  16. if (decl == HLSLDeclaration.HybridPerInstance)
  17. return $"UNITY_ACCESS_HYBRID_INSTANCED_PROP({referenceName}, {concretePrecision.ToShaderString()}{vectorDimension})";
  18. else
  19. return base.GetHLSLVariableName(isSubgraphProperty, mode);
  20. }
  21. internal override string GetPropertyBlockString()
  22. {
  23. return $"{hideTagString}{referenceName}(\"{displayName}\", Vector) = ({NodeUtils.FloatToShaderValueShaderLabSafe(value.x)}, {NodeUtils.FloatToShaderValueShaderLabSafe(value.y)}, {NodeUtils.FloatToShaderValueShaderLabSafe(value.z)}, {NodeUtils.FloatToShaderValueShaderLabSafe(value.w)})";
  24. }
  25. internal override string GetPropertyAsArgumentString(string precisionString)
  26. {
  27. return $"{concreteShaderValueType.ToShaderString(precisionString)} {referenceName}";
  28. }
  29. }
  30. }