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.

Texture2DArrayShaderProperty.cs 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.ShaderGraph.Internal
  4. {
  5. [Serializable]
  6. [FormerName("UnityEditor.ShaderGraph.Texture2DArrayShaderProperty")]
  7. [BlackboardInputInfo(51)]
  8. public class Texture2DArrayShaderProperty : AbstractShaderProperty<SerializableTextureArray>
  9. {
  10. internal Texture2DArrayShaderProperty()
  11. {
  12. displayName = "Texture2D Array";
  13. value = new SerializableTextureArray();
  14. }
  15. public override PropertyType propertyType => PropertyType.Texture2DArray;
  16. internal override bool isExposable => true;
  17. internal override bool isRenamable => true;
  18. internal string modifiableTagString => modifiable ? "" : "[NonModifiableTextureData]";
  19. internal override string GetPropertyBlockString()
  20. {
  21. return $"{hideTagString}{modifiableTagString}[NoScaleOffset]{referenceName}(\"{displayName}\", 2DArray) = \"\" {{}}";
  22. }
  23. internal override bool AllowHLSLDeclaration(HLSLDeclaration decl) => (decl != HLSLDeclaration.HybridPerInstance) && (decl != HLSLDeclaration.DoNotDeclare);
  24. internal override void ForeachHLSLProperty(Action<HLSLProperty> action)
  25. {
  26. action(new HLSLProperty(HLSLType._Texture2DArray, referenceName, HLSLDeclaration.Global));
  27. action(new HLSLProperty(HLSLType._SamplerState, "sampler" + referenceName, HLSLDeclaration.Global));
  28. }
  29. internal override string GetPropertyAsArgumentString(string precisionString)
  30. {
  31. return "UnityTexture2DArray " + referenceName;
  32. }
  33. internal override string GetPropertyAsArgumentStringForVFX(string precisionString)
  34. {
  35. return "TEXTURE2D_ARRAY(" + referenceName + ")";
  36. }
  37. internal override string GetHLSLVariableName(bool isSubgraphProperty, GenerationMode mode)
  38. {
  39. if (isSubgraphProperty)
  40. return referenceName;
  41. else
  42. return $"UnityBuildTexture2DArrayStruct({referenceName})";
  43. }
  44. [SerializeField]
  45. bool m_Modifiable = true;
  46. internal bool modifiable
  47. {
  48. get => m_Modifiable;
  49. set => m_Modifiable = value;
  50. }
  51. internal override AbstractMaterialNode ToConcreteNode()
  52. {
  53. return new Texture2DArrayAssetNode { texture = value.textureArray };
  54. }
  55. internal override PreviewProperty GetPreviewMaterialProperty()
  56. {
  57. return new PreviewProperty(propertyType)
  58. {
  59. name = referenceName,
  60. textureValue = value.textureArray
  61. };
  62. }
  63. internal override ShaderInput Copy()
  64. {
  65. return new Texture2DArrayShaderProperty()
  66. {
  67. displayName = displayName,
  68. value = value,
  69. };
  70. }
  71. }
  72. }